게임브리오 2D Line관련
출처 : http://cafe.naver.com/dxgameprogramming/1752
NiLine 클래스는 2.6부터 사라져서 저도 라인 만들 때 NiMesh를 써서 만들었습니다. path에서 waypoint들 나올테니 나온 좌표들 가지고 벡터에 넣어서 그리시면 될겁니다.
TestMakeLine(const NiPoint3 & kStartPos, const NiPoint3 & kEndPos)
{
NiMesh * pkWaypointLine = NiNew NiMesh;
pkWaypointLine->SetPrimitiveType(NiPrimitiveType::PRIMITIVE_LINES);
NiUInt8 uiAccessMask = NiDataStream::ACCESS_CPU_READ |
NiDataStream::ACCESS_CPU_WRITE_MUTABLE | NiDataStream::ACCESS_GPU_READ;
NiDataStreamRef* pkPositionRef = pkWaypointLine->AddStream(
NiCommonSemantics::POSITION(), 0, NiDataStreamElement::F_FLOAT32_3,
4, uiAccessMask, NiDataStream::USAGE_VERTEX);
NIASSERT(pkPositionRef);
NiDataStreamRef* pkIndexRef = pkWaypointLine->AddStream(
NiCommonSemantics::INDEX(), 0, NiDataStreamElement::F_UINT16_1,
4, uiAccessMask, NiDataStream::USAGE_VERTEX_INDEX);
NIASSERT(pkIndexRef);
NiDataStream * pkPositionStream = pkPositionRef->GetDataStream();
NiDataStream * pkIndexStream = pkIndexRef->GetDataStream();
pkPositionStream->GetRegion(0).SetRange(0);
pkIndexStream->GetRegion(0).SetRange(0);
NiDataStreamElementLock kPositionsLock = NiDataStreamElementLock(
pkWaypointLine, NiCommonSemantics::POSITION(), 0,
NiDataStreamElement::F_FLOAT32_3);
NIASSERT(kPositionsLock.IsLocked());
NiDataStreamElementLock kIndicesLock = NiDataStreamElementLock(
pkWaypointLine, NiCommonSemantics::INDEX(), 0,
NiDataStreamElement::F_UINT16_1);
NIASSERT(kIndicesLock.IsLocked());
NiTStridedRandomAccessIterator<NiPoint3> kPositionsIter =
kPositionsLock.begin<NiPoint3>();
NiTStridedRandomAccessIterator<NiUInt16> kIndicesIter =
kIndicesLock.begin<NiUInt16>();
kPositionsIter[0] = kStartPos;
kIndicesIter[0] = 0;
kPositionsIter[1] = kEndPos;
kIndicesIter[1] = 1;
pkPositionStream->GetRegion(0).SetRange(2);
pkIndexStream->GetRegion(0).SetRange(2);
NiVertexColorProperty* pkVC = NiNew NiVertexColorProperty;
pkVC->SetSourceMode(NiVertexColorProperty::SOURCE_IGNORE);
pkVC->SetLightingMode(NiVertexColorProperty::LIGHTING_E);
pkWaypointLine->AttachProperty(pkVC);
NiMaterialProperty* pkMat = NiNew NiMaterialProperty;
pkMat->SetEmittance(NiColor(0.0f, 0.0f, 1.0f));
pkMat->SetAlpha(1.0f);
pkWaypointLine->AttachProperty(pkMat);
pkWaypointLine->RecomputeBounds();
pkWaypointLine->UpdateProperties();
pkWaypointLine->Update(0);
g_vWaypointLine.push_back(pkWaypointLine);
}
저는 2.6에서 위와 같은 방법으로 검출된 path 연결해서 쓰고 있습니다.
'Gamebryo > Lecture' 카테고리의 다른 글
Mesh 만들기 (0) | 2011.11.08 |
---|---|
Mesh의 생성 ( Particle, 검궤적 등 ) (0) | 2011.11.08 |
FrameRenderSystem에서.. 커스텀알파소터프로세스.. (0) | 2011.09.18 |
무기잔상효과 (0) | 2011.02.08 |
캐릭터 기울기 연산 (0) | 2011.02.08 |