블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2794)
Unity3D (852)
Programming (478)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (11)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

출처 : 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
Posted by blueasa
, |