示例#1
0
void CD3D11Skeleton::BuildAnimation()
{
	DWORD firstKeyIndex = 0;
	DWORD nextKeyIndex  = 0;

	if (m_fTime < m_pCurrentAnimTrack->GetKey(m_lastKey)->GetTime())
		m_lastKey = 0;

	for (unsigned int i = m_lastKey; i < m_pCurrentAnimTrack->GetKeyCount() ; i+=m_pBones.size())
	{
		if (m_fTime < m_pCurrentAnimTrack->GetKey(i)->GetTime())
		{
			firstKeyIndex = i;
			m_lastKey = i;


			//Check if its the Last Key.
			if( i + BoneCount()  >= m_pCurrentAnimTrack->GetKeyCount()  )
			{
				nextKeyIndex = i;
			}
			else
			{
				nextKeyIndex  = i + BoneCount();
			}

			break;
		}
	}

	float time = 0.0f;
	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		Mat a = m_pCurrentAnimTrack->GetKey( firstKeyIndex + i )->GetMatrix();
		Mat b = m_pCurrentAnimTrack->GetKey( nextKeyIndex + i )->GetMatrix();

		float T1 = m_pCurrentAnimTrack->GetKey( firstKeyIndex + i )->GetTime();
		float T2 = m_pCurrentAnimTrack->GetKey( nextKeyIndex + i )->GetTime();

		//Last key
		if ( firstKeyIndex == nextKeyIndex || T1 == T2 )
		{
			m_BoneGlobals[i] = a;
			continue;
		}

		float s = (m_fTime - T1) / (T2 - T1);

		m_BoneGlobals[i] = a;

		GetBone(i)->SetWorldMatrix(a);

		//safeQueEvent(IEventDataPtr(shared_ptr<EvtData_SetActorTransform>(DEBUG_CLIENTBLOCK EvtData_SetActorTransform(GetBone(i)->GetID(),GetBone(i)->GetWorldMatrix()))));

// 		t->Start();		
// 		g_pApp->m_pGame->VGetGamePhysics()->VKinematicMove(GetBone(i)->GetWorldMatrix(),GetBone(i)->GetID());
// 		t->Stop();
// 		time += t->get();
	} 
}
示例#2
0
bool CD3D11Skeleton::Restore()
{
	m_CurrentTime = 0.0f;

	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		if(!GetBone(i)->Restore())
			return false;
	}

	for (map<string,shared_ptr<AnimationsTrack>>::iterator it = m_AnimTrackMap.begin(); it !=m_AnimTrackMap.end() ; it++)
	{
		if(!it->second->Restore())
			return false;
	}

	if (m_AnimTrackMap.empty())
		return false;


	SetCurrentAnimationsTrack(  m_AnimTrackMap.begin()->first );

	m_BoneGlobals.resize(BoneCount());

	if(!m_pevMatrixPalette->restore())
		return false;

	return true;
}
示例#3
0
void CD3D11Skeleton::SetCurrentAnimationsTrack( string name )
{
	m_pCurrentAnimTrack = m_AnimTrackMap[name];

	for (unsigned int i = 0; i < BoneCount() ; i++)
		GetBone(i)->SetCurrentAnimationsTrack(name);
}
示例#4
0
void CD3D11Skeleton::SetProjectionsMatrix( Mat projection )
{
	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		//GetBone(i)->SetProjectionsMatrix(projection);
	}
}
示例#5
0
CD3D11Bone* CD3D11Skeleton::FindBone( string name )
{
	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		if (GetBone(i)->GetName() == name )
			return GetBone(i);
	}

	return NULL;
}
示例#6
0
bool CD3D11Skeleton::Update( DWORD const elapsedMs )
{
// 	m_fTime += (float)elapsedMs/1000;
// 
// 	if (m_fTime > m_pCurrentAnimTrack->GetEndTime() )
// 	{
// 		//Set Next Track && Time = Start Time
// 		SetNextAnimationsTrack();
// 		m_lastKey = 0;
// 		m_fTime = m_pCurrentAnimTrack->GetStartTime();
// 	}

// 	THREADSTRUCT ts; 
// 
// 	/* Fill in the data structure */
// 	ts.iParam   = 69;
// 	ts.szParam  = _T("Hello, threaded world!");
// 
// 	m_thread = CreateThread(NULL,				/* Security attributes (NULL = default) */
// 		0,					/* Stack size (0 = default) */
// 		ThreadProc,		/* Address of thread callback */
// 		(LPVOID)&ts,		/* Argument casted to void pointer */
// 		0,					/* Creation flags (0 = not suspended) */
// 		NULL);				/* Pointer to thread ID value */
// 
// 	if (m_thread == NULL)
// 		printf("Failed to create thread! [%d]\n", GetLastError());
// 
// 
// 	t->Stop();



	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		m_BoneGlobals[i] = (*GetBone(i)->GetGlobal());
	} 





// 
// 	t->Start();
// 	BuildAnimation();
// 	t->Stop();
	
	return true;
}
示例#7
0
bool CEditableObject::VerifyBoneParts()
{
	U8Vec b_use(BoneCount(),0);
    for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++)
        for (int i=0; i<int(bp_it->bones.size()); i++){
        	int idx = FindBoneByNameIdx(bp_it->bones[i].c_str());
            if (idx==-1){
            	bp_it->bones.erase(bp_it->bones.begin()+i);
            	i--;
            }else{
	        	b_use[idx]++;
            }
        }

    for (U8It u_it=b_use.begin(); u_it!=b_use.end(); u_it++)
    	if (*u_it!=1) return false;
    return true;
}
示例#8
0
bool CD3D11Skeleton::SetupBoneHierarchy()
{
	for (unsigned int i = 0; i < BoneCount() ; i++)
	{
		if (GetBone(i)->GetParentName() == "Root")
		{
			GetBone(i)->SetParent(NULL);
			continue;
		}

		CD3D11Bone* parentBone= FindBone(GetBone(i)->GetParentName());

		if (!parentBone )
			return false;

		GetBone(i)->SetParent(parentBone);
	}

	return true;
}