#include "stdafx.h" #include "DynamicSceneNode.h" #include "SceneTree.h" #include "SceneManager.h" #include "ResourceManager.h" #include "RenderSystem.h" #include "CameraManager.h" //#include "LightAgent.h" //#include "FogAgent.h" //#include "SoundSystem.h" //#include "EffectSceneNode.h" //#include "SoundSceneNode.h" //#include "ObjectNameCard.h" #include "TrailGeometry.h" #include "ShadowGeometry.h" // //#include "ChatBubble.h" cDynamicSceneNode::cDynamicSceneNode( eSceneNodeType type ) : cSceneNode( type ) , mTargetAnimation( UINT_MAX ) , mRandomIdle( 0 ) , mModel(0) //, mpNameCard(0) //, mpChatBubble(0) , mLinkInfo(0) , mActorManager(0) , mAmbientLight( 0 ) #ifdef MAP_EDITOR , mRibbonGeom( 0 ) , mShadowGeom( 0 ) , mNeedUpdateShadow( false ) #endif { mHead = 0; mHeadDist = 20.0f; mScaleAccumTime = 0; mLastTime = ULONG_MAX; mScaleFactor = 1.0f; mRadius = 0.0f; } cDynamicSceneNode::~cDynamicSceneNode() { /// µî·ÏµÈ ÀÌÆåÆ®°¡ ÀÖ´Ù¸é ¸ðµÎ Á¦°Å ÇÑ´Ù. //NiTListIterator pos = mEffectList.GetHeadPos(); //while( pos ) //{ // cEffectSceneNode* pnode = mEffectList.GetNext(pos); // SCENEMAN->DestroyEffectNode( pnode, true ); //} //mEffectList.RemoveAll(); //pos = mSoundList.GetHeadPos(); //while( pos ) //{ // cSoundSceneNode* pnode = mSoundList.GetNext(pos); // SCENEMAN->DestroySoundNode( pnode, true ); //} //mSoundList.RemoveAll(); /// ¸»Ç³¼± Á¦°Å //SAFE_DELETE(mpChatBubble); /// À̸§ °´Ã¼ Á¦°Å //SAFE_DELETE(mpNameCard); if( mLinkInfo ) { sLinkInfo* info = 0; for( unsigned int i=0; iGetSize(); ++i ) { info = mLinkInfo->GetAt( i ); if( info ) { NiDelete info; } } mLinkInfo->RemoveAll(); } SAFE_NIDELETE( mLinkInfo ); SAFE_NIDELETE( mRandomIdle ); #ifdef MAP_EDITOR SAFE_NIDELETE( mRibbonGeom ); SAFE_DELETE( mShadowGeom ); #endif mPartsNameMap.RemoveAll(); SAFE_NIDELETE( mActorManager ); mModel = 0; } void cDynamicSceneNode::Process( unsigned long deltaTime, unsigned long accumTime ) { #ifdef MAP_EDITOR /// ±ËÀû if( mRibbonGeom ) mRibbonGeom->Process( deltaTime ); #endif /// ÀÓÀÇ·Î »À´ëÁ¤º¸¸¦ º¯°æÇÏ´Â °æ¿ì¿¡ »ç¿ëÇÑ´Ù. UpdateBipedRootTransforms( accumTime ); /// Alpha Fade In/Out ó¸® ProcessAlpha( deltaTime ); if( mAlpha < 0.000001f ) mCheckFrustum = false; else mCheckFrustum = true; unsigned long delta = accumTime - mLastTime; delta = (unsigned long)(delta * mScaleFactor); /// actormanager Àü¿ë ½Ã°£ °è»ê if( mLastTime == ULONG_MAX ) mScaleAccumTime = accumTime; else mScaleAccumTime += delta; float fScaleTime = mScaleAccumTime*0.001f; mLastTime = accumTime; /// °´Ã¼ÀÇ Update mActorManager->Update( fScaleTime ); GetNiNode()->Update( fScaleTime ); /// °æ°è±¸¸¦ ¼³Á¤ mBoundSphere.Set( GetCenter(), GetRadius() ); /// Àå¸é Æ®¸®¸¦ °»½Å if( mContainer ) mContainer->Update( this ); //if( mpChatBubble ) //{ // if( mHead == 0 ) // { // assert( 0 ); // return; // } // NiPoint3 headPos = mHead->GetWorldTranslate(); // headPos.z += mHeadDist; // mpChatBubble->Update( headPos, accumTime ); //} /// if( mNeedUpdateTransform ) { mNeedUpdateTransform = false; #ifdef MAP_EDITOR mNeedUpdateShadow = true; #endif } } //bool cDynamicSceneNode::OnVisible( cSceneCuller& culler ) //{ // bool ret = cSceneNode::OnVisible( culler ); // // if( ret ) // { // assert( mShadowGeom ); // mShadowGeom->Update( mNeedUpdateShadow, mAlpha ); // // mNeedUpdateShadow = false; // } // // return ret; //} bool cDynamicSceneNode::OnVisible( cSceneCuller& culler ) { #ifdef REGEN_TOOL if( mCulled ) return false; #endif #ifdef MAP_EDITOR /// ±×¸²ÀÚ if( mShadowGeom && mAlpha > 0.00001f ) mShadowGeom->Process( mNeedUpdateShadow, GetWorldTranslate(), mAlpha ); mNeedUpdateShadow = false; #endif return cSceneNode::OnVisible( culler ); } bool cDynamicSceneNode::Init( const cDynamicSceneNodeParam& param ) { //mpGameObject = param.mpObject; //assert( mpGameObject && "UnUsed Base Object" ); /// ¸®¼Ò½º °ü¸®ÀÚ·Î ºÎÅÍ ¸ðµ¨Á¤º¸ ȹµæ.. //mModel = RESOURCEMAN->GetModelByName( param.mPathName.Cstr() ); mModel = RESOURCEMAN->LoadKFM( param.mPathName.Cstr() ); if( mModel == 0 ) { assert(0 && "Model file not found"); return false; } /// ¸µÅ©¸¦ À§ÇÑ ¸Þ¸ð¸®¸¦ Àâ´Â´Ù. if( InitLinkInfo() == false ) return false; /// ±âº» ÆÄÆ®ÀÇ ³×ÀÌ¹Ö ÃʱâÈ­ if( InitPartsName() == false ) { return false; } /// ActorManager »ý¼º.. mActorManager = cActorManagerForPartition::Create( mModel ); if( mActorManager == 0 ) { assert( 0 ); return false; } /// °»½Å mActorManager->Update(0.0f); /// IDLE »óÅ ¾Ö´Ï¸ÞÀÌ¼Ç ¼ÂÆÃ.. (¿©·¯°¡Áö ÇüÅÂÀÇ IDLEÀÌ Á¸Àç ÇÏ´Â °æ¿ì) InitializeRandomIdle(); /// ¿£Áø ³ëµå¸¦ ¼³Á¤ mSceneNiNode = mActorManager->GetNifRoot(); if( GetNiObj() == 0 ) { assert( 0 && "null node" ); return false; } { /// º¯È¯ Çà·ÄÀ» ¼³Á¤ GetNiObj()->SetTranslate( param.mTranslate ); GetNiObj()->SetRotate( param.mRotate ); GetNiObj()->SetScale( param.mScale ); /// ÇÈÅ· ¹æ½ÄÀ» ¼³Á¤ mPick.SetQueryType( NiPick::QUERY_FIRST ); mPick.SetSortType( NiPick::SORT_OFF ); mPick.SetIntersectType( NiPick::INTERSECT_COLLISION_DATA ); mPick.SetCoordinateType( param.mPickCoordinate ); mPick.SetFrontOnly( param.mPickFrontOnly ); mPick.SetReturnTexture( param.mPickReturnTexture ); mPick.SetReturnNormal( param.mPickReturnNormal ); mPick.SetReturnSmoothNormal( false ); mPick.SetReturnColor( param.mPickReturnColor ); mPick.SetTarget( GetNiObj() ); // mPick.SetPickObjectPolicy(NiNew SimpleSkinPickObjectPolicy()); /// °æ°è ±¸¸¦ ¼³Á¤ GetNiNode()->Update( 0.0f ); /// °»½Å ¿©ºÎ¸¦ ¼³Á¤ mNeedUpdateTransform = true; } /// ¾ËÆÄ ¼Ó¼ºÀÌ ¾øÀ¸¸é »ý¼º NiAlphaProperty* alphaProp = (NiAlphaProperty*)GetNiObj()->GetProperty( NiProperty::ALPHA ); if( alphaProp == 0 ) { alphaProp = NiNew NiAlphaProperty; alphaProp->SetAlphaBlending( false ); alphaProp->SetAlphaTesting( false ); alphaProp->SetTestMode(NiAlphaProperty::TEST_GREATEREQUAL); GetNiObj()->AttachProperty( alphaProp ); } NiAmbientLight* amb = FindAmbientLight( GetNiObj() ); if( amb ) GetNiNode()->DetachChild( amb ); /// Á¤º¸ ÃßÃâ ClearCollectInfo(); RecursiveNodeInfo( GetNiObj() ); /// Á¶¸íÀ» ºÎÂø GetNiNode()->AttachEffect( SCENEMAN->GetAmbientLight( 1 ) ); GetNiNode()->AttachEffect( SCENEMAN->GetDirLight( 1 ) ); /// ¾È°³ ¼Ó¼ºÀ» ºÎÂø //GetNiNode()->AttachProperty( SCENEMAN->GetFogProperty() ); /// °»½Å bool selectiveUpdate = true; bool rigid = false; GetNiObj()->SetSelectiveUpdateFlags( selectiveUpdate, true, rigid ); GetNiObj()->UpdateProperties(); GetNiObj()->UpdateEffects(); GetNiObj()->Update( 0.0f ); GetNiObj()->UpdateNodeBound(); mBoundSphere.Set( GetCenter(), GetRadius() ); ///// Á¤º¸Ç¥½Ã¸¦ À§ÇÑ °´Ã¼ »ý¼º //if( param.mCreateNameCard ) //{ // mpNameCard = CreateNameCard( mpGameObject ); // assert(mpNameCard); //} #ifdef MAP_EDITOR /// ±×¸²ÀÚ ±âÇϸ¦ »ý¼º if( param.mUseShadow ) { assert( mShadowGeom == 0 ); mShadowGeom = new cShadowGeometry(); if( mShadowGeom->Init( RESOURCEMAN->GetShadowTexture(), 140.0f ) == false ) { assert( 0 ); return false; } } #endif return true; } void cDynamicSceneNode::SetTargetAnimation( unsigned int code ) { if( mTargetAnimation != code ) { if( mActorManager->SetTargetAnimation( code ) == false ) return; mTargetAnimation = code; } } bool cDynamicSceneNode::UpdateTargetAnimation( unsigned int code ) { if( mTargetAnimation != code ) { if( mActorManager->SetTargetAnimation( code ) == 0 ) return false; mTargetAnimation = code; return true;; } return (mActorManager->UpdateTargetAnimation( code ) != 0); } /* ------------------------------------------------------------------ * ÇÔ¼öÀ̸§ : ChangeParts( unsigned int index, NiNode* pObj ) * ¸ñ Àû : ÆÄÆ®¸¦ ±³Ã¼Çϴµ¥ »ç¿ë * ÁÖÀÇ»çÇ× : º»LOD°¡ ¿ÏÀüÈ÷ Å×½ºÆ®µÈ »óÅ´ ¾Æ´Ï´Ù. (Á»´õ ¼öÁ¤¿ä!!) * ½ºÅ²°ú º» Á¤º¸ °»½Å¿¡ ƯÈ÷ À¯ÀÇ ÇØ¾ßÇÑ´Ù. * ------------------------------------------------------------------ */ bool cDynamicSceneNode::ChangeParts( unsigned int partsIdx, NiNode* pNode ) { /// 1. ±âÁ¸ ÆÄÆ®¿¡ ´ëÇÑ Á¤º¸¸¦ ¼öÁýÇÑ´Ù. NiAVObject* pSrcNode = mActorManager->GetParts( partsIdx ); if( !pSrcNode ) { assert(0); return false; } NiMesh* pSrcMesh = NULL; if( NiIsKindOf(NiMesh, pSrcNode) ) { pSrcMesh = (NiMesh*)pSrcNode; } else { pSrcMesh = GetGeom(pSrcNode); } if( !pSrcMesh ) { assert(0); return false; } NiSkinningMeshModifier* pSrcSkinningModifier = NiGetModifier(NiSkinningMeshModifier, pSrcMesh); if( pSrcSkinningModifier == 0 ) { assert(0); return false; } /// 2. ±³Ã¼ µÇ¾îÁú ÆÄÆ®¿¡ ´ëÇÑ Á¤º¸ ¼öÁý const char* partsName = RESOURCEMAN->GetManagedPartName( partsIdx ); if( partsName == 0 || strlen(partsName) == 0 ) { assert(0); return false; } NiMesh* pDestMesh = GetGeom( pNode ); if( !pDestMesh ) { assert(0); return false; } NiSkinningMeshModifier* pDestSkinningModifier = NiGetModifier(NiSkinningMeshModifier, pDestMesh); if( pDestSkinningModifier == 0 ) { assert(0); return false; } NiAVObject** ppBones = pDestSkinningModifier->GetBones(); if( ppBones == 0 ) { assert(0); return false; } NiTransform* pSkinToBoneTransforms = pDestSkinningModifier->GetSkinToBoneTransforms(); if( pSkinToBoneTransforms == 0 ) { assert(0); return false; } NiBound* pBoneBounds = pDestSkinningModifier->GetBoneBounds(); if( pBoneBounds == 0 ) { assert(0); return false; } /// 3. »õ·Î¿î Á¤º¸¸¦ »ý¼º NiSkinningMeshModifier* pkModifier = NiNew NiSkinningMeshModifier( pDestSkinningModifier->GetBoneCount() ); pkModifier->SetSoftwareSkinned( pDestSkinningModifier->GetSoftwareSkinned() ); // Get the destinations for the converted skinning data NiAVObject** apkDestBones = pkModifier->GetBones(); NIASSERT(apkDestBones); NiTransform* akDestSkinToBoneTransforms = pkModifier->GetSkinToBoneTransforms(); NIASSERT(akDestSkinToBoneTransforms); pkModifier->EnableDynamicBounds(); NiBound* akDestBoneBounds = pkModifier->GetBoneBounds(); NIASSERT(akDestBoneBounds); // Set the root bone and its BoneToBindSpace transform pkModifier->SetRootBoneParent( pSrcSkinningModifier->GetRootBoneParent() ); pkModifier->SetRootBoneParentToSkinTransform( pSrcSkinningModifier->GetRootBoneParentToSkinTransform() ); // Set each bone and is bind to bone space transforms for (unsigned int i = 0; i < pDestSkinningModifier->GetBoneCount(); i++ ) { NiAVObject* pBone = ppBones[i]; if( pBone == 0 ) { assert(0); continue; } NiAVObject* pNewBone = GetNiNode()->GetObjectByName( pBone->GetName() ); if( pNewBone == 0 ) { assert(0); continue; } // Add bones, transforms, and bone bounds apkDestBones[i] = pNewBone; akDestSkinToBoneTransforms[i] = pSkinToBoneTransforms[i]; akDestBoneBounds[i] = pBoneBounds[i]; } /// CloneÇÑ Object¿¡ ÀÖ´ø Bone RootÁ¤º¸¸¦ »èÁ¦ÇÑ´Ù. if( pNode->DetachChild( pNode->GetObjectByName("foot_dummy") ) == 0 ) { assert(0); } pDestMesh->RemoveModifier( pDestSkinningModifier ); pDestMesh->AddModifier( pkModifier ); /// »õ·Î¿î °´Ã¼·Î ¹Ù²Û´Ù. mActorManager->ChangePartsObject( partsIdx, pNode ); return true; } bool cDynamicSceneNode::ChangePartsTexture( unsigned int partsIdx, NiTexture* pTex ) { /// 1. ±âÁ¸ ÆÄÆ®¿¡ ´ëÇÑ Á¤º¸¸¦ ¼öÁýÇÑ´Ù. NiAVObject* pNode = mActorManager->GetParts( partsIdx ); if( pNode && pTex ) { //NiAVObject* pGeom = GetGeom( pNode ); NiAVObject* pGeom = GetGeom( (NiNode*)pNode ); if( pGeom ) { NiTexturingProperty* pProperty = (NiTexturingProperty*)pGeom->GetProperty( NiProperty::TEXTURING ); if( pProperty ) { pProperty->SetBaseTexture( pTex ); pGeom->UpdateProperties(); return true; } } } return false; } /* ------------------------------------------------------------------ * ÇÔ¼öÀ̸§ : LinkObject( unsigned int index, NiNode* pObj ) * ¸ñ Àû : ¹«±â¸¦ ƯÁ¤´õ¹Ì¿¡ ¸µÅ© ½ÃŲ´Ù. * ÁÖÀÇ»çÇ× : ¸®ÅϵǴ À妽º¸¦ Ȱ¿ëÇØ¼­ Á¦°ÅµÇ¹Ç·Î ²À ¹Þ¾Æ¼­ º¸°üÇÒ°Í.. * ------------------------------------------------------------------ */ unsigned int cDynamicSceneNode::LinkObject( unsigned int dummyIdx, NiNode* pNode ) { /// Parts NameÁ¡°Ë.. À߸øµÈ À妽º üũ const char* partsName = 0; if( mPartsNameMap.GetAt( dummyIdx, partsName ) == false ) { assert(0); return UINT_MAX; } /// ¸µÅ© ´ë»ó ¿øº»°´Ã¼ ȹµæ.. // NiGeometry* pGeom = (NiGeometry*)GetGeom( pNode ); // assert(pGeom); // if( pGeom == 0 ) // { // assert(0); // return UINT_MAX; // } NiNode* pobj = NiDynamicCast(NiNode, CollectTestData( pNode )); if( pobj == 0 ) { assert(0); return UINT_MAX; } /// ¸µÅ©½Ãų À§Ä¡ °´Ã¼ ȹµæ.. NiNode* pDummy = (NiNode*)mActorManager->GetNifRoot()->GetObjectByName( partsName ); assert(pDummy); if( pDummy == 0 ) { assert(0); return UINT_MAX; } /// ¿øº»°´Ã¼ º¹»çº» »ý¼º.. NiCloningProcess cloning; cloning.m_eCopyType = NiObjectNET::COPY_EXACT; // NiGeometry* pNewObj = NiDynamicCast( NiGeometry, pGeom->Clone( cloning ) ); NiNode* pNewObj = NiDynamicCast( NiNode, pobj->Clone( cloning ) ); assert(pNewObj); if( pNewObj == 0 ) { assert(0); return UINT_MAX; } pNewObj->SetTranslate( 0.0f, 0.0f, 0.0f ); /// ½ÇÁ¦ ¸µÅ©.. pDummy->AttachChild( pNewObj ); /// °»½Å pNewObj->Update(0.0f); pNewObj->UpdateProperties(); pNewObj->UpdateEffects(); GetNiNode()->UpdateNodeBound(); /// ¸µÅ© Á¤º¸ ÀÔ·Â.. sLinkInfo* pkInfo = NiNew sLinkInfo; pkInfo->DummyIndex = dummyIdx; pkInfo->pObject = pNewObj; unsigned int linkIdx = mLinkInfo->Add( pkInfo ); /// ±âÇÏ Á¤º¸¸¦ °»½Å // RecollectGeoms(); return linkIdx; } /* ------------------------------------------------------------------ * ÇÔ¼öÀ̸§ : UnLinkObject( unsigned int index ) * ¸ñ Àû : ÇöÀç ¸µÅ©µÈ °´Ã¼¸¦ Á¦°ÅÇÑ´Ù. * ÁÖÀÇ»çÇ× : * ------------------------------------------------------------------ */ void cDynamicSceneNode::UnLinkObject( unsigned int linkIdx ) { if( linkIdx == UINT_MAX ) { return; } sLinkInfo* pInfo = mLinkInfo->GetAt( linkIdx ); if( pInfo == 0 ) { assert(0); return; } const char* partsName = 0; if( mPartsNameMap.GetAt( pInfo->DummyIndex, partsName ) == false ) { assert(0); return; } /// ¸µÅ©µÈ ´õ¹Ì¸¦ ã´Â´Ù. NiNode* pDummy = (NiNode*)mActorManager->GetNifRoot()->GetObjectByName( partsName ); if( pDummy == 0 ) { assert(0); return; } /// ´õ¹Ì // pDummy->GetParent()->DetachChild( pInfo->pObject ); pDummy->DetachChild( pInfo->pObject ); mLinkInfo->RemoveAt( linkIdx ); SAFE_NIDELETE(pInfo); pDummy->Update(0.0f, false); GetNiNode()->UpdateNodeBound(); /// ±âÇÏ Á¤º¸¸¦ °»½Å // RecollectGeoms(); } NiAVObject* cDynamicSceneNode::GetLinkObject( unsigned int linkId ) { if( linkId == UINT_MAX ) return 0; sLinkInfo* pInfo = mLinkInfo->GetAt( linkId ); if( pInfo ) { return pInfo->pObject; } return 0; } //cEffectSceneNode* cDynamicSceneNode::LinkEffect( unsigned int dummyIdx, const char* fileName, NiTransform* trans, bool bLoop, bool bFollow ) //{ // /// Parts NameÁ¡°Ë.. À߸øµÈ À妽º üũ // const char* partsName = 0; // if( mPartsNameMap.GetAt( dummyIdx, partsName ) == false ) // { // return 0; // } // // /// ¸µÅ©½Ãų À§Ä¡ °´Ã¼ ȹµæ.. // NiNode* pDummy = (NiNode*)mActorManager->GetNifRoot()->GetObjectByName( partsName ); // if( pDummy == 0 ) // { // return 0; // } // // cEffectSceneNodeParam param; // param.mpFollowSceneNode = this; // param.mpDummy = pDummy; // param.mPathName = fileName; // // if( trans != 0 ) // { // param.mTranslate = trans->m_Translate; // param.mRotate = trans->m_Rotate; // param.mScale = trans->m_fScale; // } // param.mFollowing = bFollow; // param.mLooping = bLoop; // // cEffectSceneNode* pnode = SCENEMAN->CreateEffect( param ); // if( pnode ) // mEffectList.AddTail(pnode); // // NiNode* pRoot = (NiNode*)(NiAVObject*)mNiObject; // pRoot->UpdateNodeBound(); // // return pnode; //} // //cEffectSceneNode* cDynamicSceneNode::LinkDamage( unsigned int dummyIdx, const char* fileName, NiTransform* trans, bool bLoop, bool /*bFollow*/ ) //{ // /// Parts NameÁ¡°Ë.. À߸øµÈ À妽º üũ // const char* partsName = 0; // if( mPartsNameMap.GetAt( dummyIdx, partsName ) == false ) // { // return 0; // } // // /// ¸µÅ©½Ãų À§Ä¡ °´Ã¼ ȹµæ.. // NiNode* pDummy = (NiNode*)mActorManager->GetNifRoot()->GetObjectByName( partsName ); // if( pDummy == 0 ) // { // return 0; // } // // cEffectSceneNodeParam param; // param.mpFollowSceneNode = this; // param.mpDummy = pDummy; // param.mPathName = fileName; // // if( trans != 0 ) // { // param.mTranslate = trans->m_Translate; // param.mRotate = trans->m_Rotate; // param.mScale = trans->m_fScale; // } // param.mFollowing = false;//bFollow; // param.mLooping = bLoop; // // cEffectSceneNode* pnode = SCENEMAN->CreateDamageEffect( param ); // if( pnode ) // mEffectList.AddTail(pnode); // // NiNode* pRoot = (NiNode*)(NiAVObject*)mNiObject; // pRoot->UpdateNodeBound(); // // return pnode; //} // ///// ÁÖÀÇ»çÇ× : //void cDynamicSceneNode::UnLinkEffect( cEffectSceneNode* pnode ) //{ // assert(pnode); // if( pnode == 0 ) // return; // // SCENEMAN->AddDeleteEffectNode( pnode ); // mEffectList.Remove( pnode ); //} // //bool cDynamicSceneNode::IsLinkedEffect( cEffectSceneNode* pnode ) //{ // return (!mEffectList.FindPos( pnode ))? false:true; //} // //cSoundSceneNode* cDynamicSceneNode::LinkSound( unsigned long soundIdx, bool bLoop ) //{ // /// ÂüÁ¶ÇÒ À§Ä¡ °´Ã¼ ȹµæ.. // NiNode* pDummy = (NiNode*)mActorManager->GetNifRoot()->GetObjectByName( "body_dummy"); // if( pDummy == 0 ) // { // return 0; // } // // sSoundInfo* pInfo = SOUNDSYS->GetSoundInfo( soundIdx ); // if( pInfo == 0 ) // return 0; // // cSoundSceneNodeParam param; // if( pInfo->mRadius <= 0.0f ) // { // param.mRadius = 100.0f; // } // else // { // param.mRadius = pInfo->mRadius; // } // param.mLoopCount = bLoop? 0:1; // param.mVolumeRatio = pInfo->mVolume; // // /// ±âº» ¼Ó¼º ÀÎÀÚµéÀ» ¼³Á¤ // param.mPathName = pInfo->mFileName; // param.mTranslate = pDummy->GetWorldTranslate(); // param.mManaged = true; // param.mpOwnerSceneNode = this; // // cSoundSceneNode* pnode = SCENEMAN->CreateEffectSound( param ); // if( pnode ) // mSoundList.AddTail(pnode); // // return pnode; //} // //void cDynamicSceneNode::UnLinkSound( cSoundSceneNode* pnode ) //{ // assert(pnode); // if( pnode == 0 ) // return; // // SCENEMAN->AddDeleteSoundNode( pnode ); // mSoundList.Remove( pnode ); //} // //bool cDynamicSceneNode::IsLinkedSound( cSoundSceneNode* pnode ) //{ // return (!mSoundList.FindPos( pnode ))? false:true; //} /// //void cDynamicSceneNode::CreateShadow() //{ //} /// //void cDynamicSceneNode::AddToVisibleArray( NiVisibleArray* psolidArray, NiVisibleArray* pskinedArray, NiVisibleArray* palphaArray ) const //{ // cSceneNode::AddToVisibleArray( psolidArray, pskinedArray, palphaArray ); // // /// °¡½Ã À̸§Ç¥·Î µî·Ï // //AddDepthPlaneObject(); // // /// ±×¸²ÀÚ¿¡ ´ëÇÑ °»½Å ¹× ·£´õ¸µÀ» À§ÇÑ °´Ã¼ Ãß°¡ //} // ///// //void cDynamicSceneNode::AddDepthPlaneObject() const //{ // /// ¸»Ç³¼± º¸À̱⠿©ºÎ // if( mpChatBubble && mpChatBubble->IsActive() ) // { // /// ¸»Ç³¼± µî·Ï // SCENEMAN->AddPlane( mpChatBubble ); // return; // } // // if( mHead == 0 ) // { //// assert( 0 ); // return; // } // // NiPoint3 headPos = mHead->GetWorldTranslate(); // headPos.z += mHeadDist; // // if( mpNameCard ) // { // mpNameCard->OnUpdate( CAMERAMAN->GetCurrentNi(), headPos ); // // SCENEMAN->AddDepthPlane( mpNameCard ); // } //} // ///// //void cDynamicSceneNode::ActiveChatBubble( LPTSTR msg, unsigned long color ) //{ // if( mpChatBubble ) // mpChatBubble->Active( msg, color ); //} // //void cDynamicSceneNode::UpdateNameCardTextValue() //{ // if( mpNameCard ) // mpNameCard->ChangeTextValue(); //} // //void cDynamicSceneNode::UpdateNameCardGaugeValue() //{ // if( mpNameCard ) // mpNameCard->ChangeGaugeValue(); //} void cDynamicSceneNode::AddToVisibleArray( NiVisibleArray* solidArray, NiVisibleArray* alphaArray, NiVisibleArray* alphaTestArray ) { cSceneNode::AddToVisibleArray( solidArray, alphaArray, alphaTestArray ); //#ifdef MAP_EDITOR // if( mRibbonGeom && mRibbonGeom->GetNumVerts() >= 4 ) // { // mRibbonGeom->SetCenter( GetCenter() ); // alphaArray->Add( *mRibbonGeom ); // } //#endif } void cDynamicSceneNode::FindLight( NiAVObject* obj ) { if( NiIsKindOf( NiAmbientLight, obj ) ) { mAmbientLight = (NiAmbientLight*)obj; SetAmbientLightAmbient( SCENEMAN->GetAmbientLight(1)->GetAmbientColor() ); SetAmbientLightDiffuse( SCENEMAN->GetAmbientLight(1)->GetDiffuseColor() ); SetAmbientLightDimmer( SCENEMAN->GetAmbientLight(1)->GetDimmer() ); } else if( NiIsKindOf( NiNode, obj ) ) { NiNode* node = (NiNode*)obj; for( unsigned int i = 0, iend = node->GetArrayCount(); i < iend; ++i ) { NiAVObject* child = node->GetAt( i ); if( child ) FindLight( child ); } } } void cDynamicSceneNode::RecollectGeoms() { // mRenderObjList.Clear(); // CollectGeoms( GetNiObj() ); } void cDynamicSceneNode::CollectPickData( NiAVObject* pobj ) { if( pobj->GetName() == "PickObj" ) { mPickDataList.PushBack( pobj ); return; } if( NiIsKindOf(NiNode, pobj) ) { NiNode* node = (NiNode*)pobj; for( unsigned int i = 0, end = node->GetArrayCount(); i < end; ++i ) { NiAVObject* child = node->GetAt(i); if( child ) CollectPickData( child ); } } } bool cDynamicSceneNode::Pick( const cRay& ray ) { if( mPickDataList.IsEmpty() ) { return cSceneNode::Pick( ray ); } if( mBoundSphere.IntersectRay( ray ) ) { NiAVObject* obj = 0; cPickDataList::cConstIterator i = mPickDataList.Begin(); cPickDataList::cConstIterator end = mPickDataList.End(); for( ; i != end; ++i ) { obj = (NiAVObject*)*i; mPick.SetTarget( obj ); if( mPick.PickObjects( ray.GetOrigin(), ray.GetDirection() ) ) { NiPick::Record* record = mPick.GetResults().GetAt(0); if( record ) { mPickPos = record->GetIntersection(); mPickDistance = record->GetDistance(); } return true; } } } return false; } /// ÁÖÀÇ : scalefactor °ªÀ¸·Î void cDynamicSceneNode::UpdateAniScaleFactor( float factor ) { if( factor <= 0.0f ) factor = 0.1f; if( factor > 2.0f ) factor = 2.0f; mScaleFactor = factor; } NiAVObject* cDynamicSceneNode::GetPartObject( unsigned int index ) const { const char* partsName = 0; if( mPartsNameMap.GetAt( index, partsName ) == false ) { return 0; } /// ¸µÅ©½Ãų À§Ä¡ °´Ã¼ ȹµæ.. return mActorManager->GetNifRoot()->GetObjectByName( partsName ); } NiAVObject* cDynamicSceneNode::CollectTestData( NiNode* pobj ) { if( pobj->GetChildCount() == 1 ) { if( NiIsKindOf( NiGeometry, pobj->GetAt(0) ) ) { pobj->GetAt(0)->SetTranslate( 0.0f, 0.0f, 0.0f ); return pobj; } NiAVObject* p = pobj->GetAt(0); if( NiIsKindOf(NiNode, p) ) { return CollectTestData( (NiNode*)p ); } } return pobj; } void cDynamicSceneNode::GotoLastFrame() { NiControllerSequence* p = mActorManager->GetActiveSequence(mActorManager->GetTargetAnimation(), true, true ); if( p ) { float time = 0.0f; time = p->GetKeyTimeAt( NiAnimationConstants::GetEndTextKey() ); if( time != NiControllerSequence::INVALID_TIME ) mActorManager->Update( -time ); } } // //float cDynamicSceneNode::GetRadius() const //{ // return mRadius; //} void cDynamicSceneNode::SetAmbientLightAmbient( const NiColor& color ) { if( mAmbientLight ) mAmbientLight->SetAmbientColor( color ); } void cDynamicSceneNode::SetAmbientLightDiffuse( const NiColor& color ) { if( mAmbientLight ) mAmbientLight->SetDiffuseColor( color ); } void cDynamicSceneNode::SetAmbientLightDimmer( float dimmer ) { if( mAmbientLight ) mAmbientLight->SetDimmer( dimmer ); } NiAmbientLight* cDynamicSceneNode::FindAmbientLight( NiAVObject* obj ) { if( NiIsKindOf( NiAmbientLight, obj ) ) { return (NiAmbientLight*)obj; } else if( NiIsKindOf( NiNode, obj ) ) { NiAVObject* child = 0; NiNode* node = (NiNode*)obj; for( unsigned int i = 0, iend = node->GetArrayCount(); i < iend; ++i ) { child = node->GetAt( i ); if( child ) { NiAmbientLight* amb = FindAmbientLight( child ); if( amb ) return amb; } } } return 0; }