#include "stdafx.h" #include "RegenToolView.h" #include "RegenToolApp.h" #include "NpcDialog.h" #include "FreeCamera.h" #include "NaviMesh.h" #include "SceneManager.h" #include "NpcSceneNode.h" int cRegenToolView::CreateNpc( unsigned int index, float x, float y, float zdegree, bool updateDialog, bool updateView ) { /// À妽º °Ë»ç cNpcInfoMap::cIterator ii = mNpcInfoMap.Find( index ); if( ii == mNpcInfoMap.End() ) return 0; /// ¸ðµ¨ ÆÄÀÏ °Ë»ç cNpcInfo* info = ii->mSecond; cModelFileMap::cIterator mi = mModelFileMap.Find( info->mModelIndex ); /// Àå¸é ³ëµå¸¦ »ý¼º float z = 0.0f; mNaviMesh->CalcHeight( &z, x, y ); cNpcSceneNodeParam param; cString str = mi->mSecond; cString pathName; pathName.Format( "./Data/Npc/%s", str.Cstr() ); param.mPathName = pathName; param.mTranslate = NiPoint3( x, y, z ); param.mRotate.FromEulerAnglesXYZ( 0.0f, 0.0f, D3DXToRadian(zdegree) ); cNpcSceneNode* n = SCENEMAN->CreateNPC( param ); if( n == 0 ) return -2; n->SetTargetAnimation( 1 ); n->SetUserData0( index ); /// ³ëµå ¸Ê¿¡ Ãß°¡ mNpcNodeMap.Insert( mNpcListIdx, n ); mNpcListIdx++; /// ´ÙÀ̾ó·Î±×¸¦ °»½Å if( updateDialog ) mNpcDialog->UpdateList( mNpcNodeMap ); /// »ý¼ºµÈ ³ëµå¸¦ ¼±Åà SelectNode( n, updateView ); return 1; } int cRegenToolView::ChangeNpc( unsigned int index ) { if( mSelNode == 0 || mSelNode ->GetType() != SCENENODE_NPC ) return -1; if( mSelNode->GetUserData0() == index ) return -2; /// »õ·Î »ý¼º float xangle = 0.0f, yangle = 0.0f, zangle = 0.0f; NiPoint3 t = mSelNode->GetWorldTranslate(); NiMatrix3 r = mSelNode->GetWorldRotate(); r.ToEulerAnglesXYZ( xangle, yangle, zangle ); DeleteSel(); CreateNpc( index, t.x, t.y, D3DXToDegree(zangle), true, true ); return 1; } int cRegenToolView::DeleteNpc( cNpcSceneNode* node ) { if( mSelNode == 0 || mSelNode != node ) return -1; /// ¼±ÅÃµÈ ³ëµå¸¦ Á¦°Å DeleteSel(); return 1; } void cRegenToolView::SelectNpc( cNpcSceneNode* node ) { if( node ) { NiPoint3 at = node->GetCenter(); NiPoint3 dir = node->GetWorldRotate() * -NiPoint3::UNIT_Y; dir.z = 0.0f; dir.Unitize(); NiPoint3 pos = at + dir * 1200.0f; pos.z += 300.0f; mCamera->SetTranslate( pos ); mCamera->LookAt( at ); } SelectNode( node ); }