コード例 #1
0
HRESULT SkinnedMesh::SetupBoneMatrixPointersOnMesh( LPD3DXMESHCONTAINER pMeshContainerBase )
{
	UINT iBone, cBones;
	D3DXFRAME_DERIVED* pFrame;

	D3DXMESHCONTAINER_DERIVED* pMeshContainer = (D3DXMESHCONTAINER_DERIVED*)pMeshContainerBase;

	// 스킨메시가 있으면
	if ( pMeshContainer->pSkinInfo != NULL )
	{
		// 본 개수를 가져와서
		cBones = pMeshContainer->pSkinInfo->GetNumBones();

		// 본 매트릭스를 저장할 공간을 할당하고
		pMeshContainer->ppBoneMatrixPtrs = new D3DXMATRIX*[cBones];
		if ( pMeshContainer->ppBoneMatrixPtrs == NULL )
			return E_OUTOFMEMORY;

		// 매트릭스를 설정한다
		for ( iBone = 0; iBone < cBones; iBone++ )
		{
			// 해당 본의 이름을 찾아서 그걸 키로 담당 프레임을 찾나?
			pFrame = (D3DXFRAME_DERIVED*)D3DXFrameFind( m_pFrameRoot,
				pMeshContainer->pSkinInfo->GetBoneName( iBone ) );
			if ( pFrame == NULL )
				return E_FAIL;

			// 찾은 프레임에 저장된 행렬을 본에 지정한다
			pMeshContainer->ppBoneMatrixPtrs[iBone] = &pFrame->CombinedTransformationMatrix;
		}
	}

	return S_OK;
}
コード例 #2
0
HRESULT CDexModelXAni::SetupBoneMatrixPointersOnMesh(LPD3DXMESHCONTAINER pMeshContainerBase)
{
	UINT iBone, cBones;
	stDexFrameEx *pFrame;

	stDexMeshContainerEx *pMeshContainer = (stDexMeshContainerEx*)pMeshContainerBase;

	// if there is a skinmesh, then setup the bone matrices
	if (pMeshContainer->pSkinInfo != NULL)
	{
		cBones = pMeshContainer->pSkinInfo->GetNumBones();

		pMeshContainer->ppBoneMatrixPtrs = new D3DXMATRIX*[cBones];
		if (pMeshContainer->ppBoneMatrixPtrs == NULL)
			return E_OUTOFMEMORY;

		for (iBone = 0; iBone < cBones; iBone++)
		{
			pFrame = (stDexFrameEx*)D3DXFrameFind( m_pFrameRoot, pMeshContainer->pSkinInfo->GetBoneName(iBone) );
			if (pFrame == NULL)
				return E_FAIL;
			D3DXMATRIX temp = pFrame->CombinedTransformationMatrix;
			pMeshContainer->ppBoneMatrixPtrs[iBone] = &pFrame->CombinedTransformationMatrix;
		}
	}
	return S_OK;
}
コード例 #3
0
HRESULT	CAnimationModel::SetupBoneMatrixPointersOnMesh(LPD3DXMESHCONTAINER pSuperMeshContainer)
{
	HRESULT	hr	= S_OK;
	CMeshContainer	*pMeshContainer	= (CMeshContainer*) pSuperMeshContainer;

	if( NULL != pMeshContainer->pSkinInfo )
	{
		DWORD	numBones	= pMeshContainer->pSkinInfo->GetNumBones();
		pMeshContainer->m_ppBoneMatrixPtrs	= NULL;
		pMeshContainer->m_ppBoneMatrixPtrs	= new LPD3DXMATRIX[ numBones ];

		if( NULL == pMeshContainer->m_ppBoneMatrixPtrs )
			return E_OUTOFMEMORY;

		for( DWORD i=0; i<numBones;	++i )
		{
			LPCSTR		pBoneName	= pMeshContainer->pSkinInfo->GetBoneName( i );
			LPD3DXFRAME	pFrame		= D3DXFrameFind( m_pFrameRoot, pBoneName );

			if( NULL == pFrame )
			{
				return	E_FAIL;				
			}
			pMeshContainer->m_ppBoneMatrixPtrs[i] = &( (CFrame*)pFrame )->m_CombinedTransformationMatrix;
		}
	}

	return	hr;
}
コード例 #4
0
	/**
	 * @brief skinned mesh
	 * 
	 * Called to setup the pointers for a given bone to its transformation matrix
	 *
	 */
	HRESULT AnimationManager::setupBoneMatrixPointersOnMesh(LPD3DXMESHCONTAINER pMeshContainerBase)
	{
		acut::AnimationMeshContainer* pMeshContainer = static_cast<acut::AnimationMeshContainer*>(pMeshContainerBase);

		// もしスキンメッシュなら、ボーン行列をセットアップする
	    if (NULL != pMeshContainer->pSkinInfo) {
	        DWORD numberOfBones = pMeshContainer->pSkinInfo->GetNumBones();

			// ボーン行列のポインタへの配列を作成
			pMeshContainer->m_boneMatrixPointers.reserve(numberOfBones);
	        for (DWORD iBone = 0; iBone < numberOfBones; ++iBone) {
				acut::AnimationFrame* pFrame = static_cast<acut::AnimationFrame*>(D3DXFrameFind(
					m_pRootFrame,
	                pMeshContainer->pSkinInfo->GetBoneName(iBone)
				));
				if (pFrame == NULL) {
	                return E_FAIL;
				}

	            pMeshContainer->m_boneMatrixPointers.push_back(&pFrame->CombinedTransformationMatrix);
	        }
	    }

	    return S_OK;
	}
コード例 #5
0
/**
 * \brief we need to go through the hierarchy and set the combined matrices
 * calls itself recursively as it tareverses the hierarchy
 * \param device - the Direct3D device object
 * \param pFrame - current frame
 * \param pParentMatrix - the parent frame matrix
 * \author Keith Ditchburn \date 18 July 2005
*/
void CXFileEntity::SetupBoneMatrices(D3DXFRAME_EXTENDED *pFrame, LPD3DXMATRIX pParentMatrix)
{
	// Cast to our extended structure first
	D3DXMESHCONTAINER_EXTENDED* pMesh = (D3DXMESHCONTAINER_EXTENDED*)pFrame->pMeshContainer;

	// If this frame has a mesh
	if(pMesh)
	{
		// We need to remember which is the first mesh in the hierarchy for later when we 
		// update (FrameMove)
		if(!m_firstMesh)
			m_firstMesh = pMesh;
		
		// if there is skin info, then setup the bone matrices
		if(pMesh->pSkinInfo && pMesh->MeshData.pMesh)
		{
			// Create a copy of the mesh to skin into later
			D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE];
			if (FAILED(pMesh->MeshData.pMesh->GetDeclaration(Declaration)))
				return;

			pMesh->MeshData.pMesh->CloneMesh(D3DXMESH_MANAGED, 
				Declaration, m_d3dDevice, 
				&pMesh->exSkinMesh);

			// Max bones is calculated for later use (to know how big to make the bone matrices array)
			m_maxBones=max(m_maxBones,(int)pMesh->pSkinInfo->GetNumBones());

			// For each bone work out its matrix
			for (unsigned int i = 0; i < pMesh->pSkinInfo->GetNumBones(); i++)
			{   
				// Find the frame containing the bone
				D3DXFRAME_EXTENDED* pTempFrame = (D3DXFRAME_EXTENDED*)D3DXFrameFind(m_frameRoot, 
						pMesh->pSkinInfo->GetBoneName(i));

				// set the bone part - point it at the transformation matrix
				pMesh->exFrameCombinedMatrixPointer[i] = &pTempFrame->exCombinedTransformationMatrix;
			}

		}
	}

	// Pass on to sibblings
	if(pFrame->pFrameSibling)
		SetupBoneMatrices((D3DXFRAME_EXTENDED*)pFrame->pFrameSibling, pParentMatrix);

	// Pass on to children
	if(pFrame->pFrameFirstChild)
		SetupBoneMatrices((D3DXFRAME_EXTENDED*)pFrame->pFrameFirstChild, &pFrame->exCombinedTransformationMatrix);
}
コード例 #6
0
/**
 * Goes through the hierarchy and set the combined matrices calls recursively
 * @param pFrame			The current frame.
 * @param pParentMatrix			The parent frame matrix.
 */
void IND_3dMeshManager::setupBoneMatrices(D3DXFRAME_EXTENDED *pFrame, LPD3DXMATRIX pParentMatrix, IND_3dMesh *pNew3dMesh) {
	// Cast to our extended structure first
	D3DXMESHCONTAINER_EXTENDED *pMesh = (D3DXMESHCONTAINER_EXTENDED *) pFrame->pMeshContainer;

	// If this frame has a mesh
	if (pMesh) {
		// We need to remember which is the first mesh in the hierarchy for later when we
		// update (FrameMove)
		if (!pNew3dMesh->_3dMesh._firstMesh)
			pNew3dMesh->_3dMesh._firstMesh = pMesh;

		// if there is skin info, then setup the bone matrices
		if (pMesh->pSkinInfo && pMesh->MeshData.pMesh) {
			// Create a copy of the mesh to skin into later
			D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE];
			if (FAILED(pMesh->MeshData.pMesh->GetDeclaration(Declaration)))
				return;
			//TODO: SOLVE DEPENDANCE IN DIRECT3D ONLY BY MOVING CODE SOMEWHERE ELSE?
			//pMesh->MeshData.pMesh->CloneMesh(D3DXMESH_MANAGED,
			//  Declaration, _render->GetDevice(),
			//  &pMesh->exSkinMesh);

			// Max bones is calculated for later use (to know how big to make the bone matrices array)
			pNew3dMesh->_3dMesh._maxBones = max(pNew3dMesh->_3dMesh._maxBones, (int)pMesh->pSkinInfo->GetNumBones());

			// For each bone work out its matrix
			for (unsigned int i = 0; i < pMesh->pSkinInfo->GetNumBones(); i++) {
				// Find the frame containing the bone
				D3DXFRAME_EXTENDED *pTempFrame = (D3DXFRAME_EXTENDED *)D3DXFrameFind(pNew3dMesh->_3dMesh._frameRoot,
				                                 pMesh->pSkinInfo->GetBoneName(i));

				// set the bone part - point it at the transformation matrix
				pMesh->_exFrameCombinedMatrixPointer[i] = &pTempFrame->_exCombinedTransformationMatrix;
			}

		}
	}

	// Pass on to sibblings
	if (pFrame->pFrameSibling)
		setupBoneMatrices((D3DXFRAME_EXTENDED *)pFrame->pFrameSibling, pParentMatrix, pNew3dMesh);

	// Pass on to children
	if (pFrame->pFrameFirstChild)
		setupBoneMatrices((D3DXFRAME_EXTENDED *)pFrame->pFrameFirstChild, &pFrame->_exCombinedTransformationMatrix, pNew3dMesh);
}
コード例 #7
0
ファイル: skinnedMesh.cpp プロジェクト: 7zhang/studies
void SkinnedMesh::SetupBoneMatrixPointers(Bone *bone) {
    if (bone->pMeshContainer != NULL) {
        BoneMesh *boneMesh = (BoneMesh*)bone->pMeshContainer;

        if (boneMesh->pSkinInfo != NULL) {
            int NumBones = boneMesh->pSkinInfo->GetNumBones();
            boneMesh->boneMatrixPtrs = new D3DXMATRIX*[NumBones];

            for (int i=0; i < NumBones; i++) {
                Bone *b = (Bone*)D3DXFrameFind(m_pRootBone, boneMesh->pSkinInfo->GetBoneName(i));
                if (b != NULL)boneMesh->boneMatrixPtrs[i] = &b->CombinedTransformationMatrix;
                else boneMesh->boneMatrixPtrs[i] = NULL;
            }
        }
    }

    if (bone->pFrameSibling != NULL)SetupBoneMatrixPointers((Bone*)bone->pFrameSibling);
    if (bone->pFrameFirstChild != NULL)SetupBoneMatrixPointers((Bone*)bone->pFrameFirstChild);
}
コード例 #8
0
ファイル: SkinnedMesh.cpp プロジェクト: erickterri/3dlearn
void SkinnedMesh::buildToRootXFormPtrArray()
{
    // Get a pointer to each frame's to-root transformation (store in an
    // array) such that the ith element corresponds with the ith bone
    // offset matrix.  In this way, we can access a frame's to-root
    // transformation with a simple array look up, instead of traversing the
    // tree.

    for(UINT i = 0; i < mNumBones; ++i)
    {
        // Find the frame that corresponds with the ith bone offset matrix.
        const char* boneName = mSkinInfo->GetBoneName(i);
        D3DXFRAME* frame = D3DXFrameFind(mRoot, boneName);
        if( frame )
        {
            FrameEx* frameEx = static_cast<FrameEx*>( frame );
            mToRootXFormPtrs[i] = &frameEx->toRoot;
        }
    }
}
コード例 #9
0
void CXModel::SetupMatrices(stD3DFrameEx *inFrame,
                            LPD3DXMATRIX parentMatirx)
{
   if(!m_device) return;

   stD3DContainerEx *containerEx = (stD3DContainerEx*)inFrame->pMeshContainer;

   if(containerEx)
      {
         if(!m_currentContainer)
            m_currentContainer = containerEx;

         if(containerEx->pSkinInfo && containerEx->MeshData.pMesh)
            {
               D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE];

               if(FAILED(containerEx->MeshData.pMesh->GetDeclaration(Declaration)))
                  return;

               containerEx->MeshData.pMesh->CloneMesh(D3DXMESH_MANAGED,
                  Declaration, m_device, &containerEx->originalMesh);

               m_maxBones = max(m_maxBones, containerEx->pSkinInfo->GetNumBones());

               for(unsigned int i = 0; i < containerEx->pSkinInfo->GetNumBones(); i++)
                  {   
                     stD3DFrameEx *temp = (stD3DFrameEx*)D3DXFrameFind(m_root,
                        containerEx->pSkinInfo->GetBoneName(i));

                     containerEx->boneMatrices[i] = &temp->finalMatrix;
                  }

            }
      }

   if(inFrame->pFrameSibling)
      SetupMatrices((stD3DFrameEx*)inFrame->pFrameSibling, parentMatirx);

   if(inFrame->pFrameFirstChild)
      SetupMatrices((stD3DFrameEx*)inFrame->pFrameFirstChild, &inFrame->finalMatrix);
}
コード例 #10
0
void XSkinnedMesh::SetupBoneMatrixPtr( const BoneFrame* bone )
{
	if (bone->pMeshContainer)
	{
		BoneMesh* boneMesh = static_cast<BoneMesh*>(bone->pMeshContainer);

		if (boneMesh->pSkinInfo)
		{
			int numBones = boneMesh->pSkinInfo->GetNumBones();

			boneMesh->_boneMatrixPtrs = new D3DXMATRIX*[numBones];

			// 각 본마다 행렬 적용
			for (int i = 0; i < numBones; i++)
			{
				auto newBone = static_cast<Bone*>(D3DXFrameFind( _rootBone, boneMesh->pSkinInfo->GetBoneName( i ) ));

				if (newBone)
				{
					boneMesh->_boneMatrixPtrs[i] = &newBone->_combinedTransMatrix;
				}

				else
				{
					boneMesh->_boneMatrixPtrs[i] = nullptr;
				}
			}
		}
	}

	if (bone->pFrameSibling)
	{
		SetupBoneMatrixPtr( bone->pFrameSibling );
	}

	if (bone->pFrameFirstChild)
	{
		SetupBoneMatrixPtr( bone->pFrameFirstChild );
	}
}
コード例 #11
0
void cSkinnedMesh::SetupBoneMatrixPtrs( ST_BONE* pBone )
{
	// 각 프레임의 메시 컨테이너에 있는 pSkinInfo를 이용하여 영향받는 모든 
	// 프레임의 매트릭스를 ppBoneMatrixPtrs에 연결한다.
	// pSkinInfo->GetNumBones() 으로 영향받는 본의 개수를 찾음.
	// pSkinInfo->GetBoneName(i) 로 i번 프레임의 이름을 찾음
	// D3DXFrameFind(루트 프레임, 프레임 이름) 로 프레임을 찾음.
	// 찾아서 월드매트릭스를 걸어줘라.

	if(pBone->pMeshContainer)
	{
		ST_BONE_MESH* pBoneMesh = (ST_BONE_MESH*)pBone->pMeshContainer;
		if(pBoneMesh->pSkinInfo)
		{
			LPD3DXSKININFO pSkinInfo = pBoneMesh->pSkinInfo;
			
			DWORD dwNumBones = pSkinInfo->GetNumBones();
			for (DWORD i = 0; i < dwNumBones; ++i)
			{
				LPCSTR szBoneName = pSkinInfo->GetBoneName(i);
				ST_BONE* pBone = (ST_BONE*)D3DXFrameFind(m_pRoot, szBoneName);
				pBoneMesh->ppBoneMatrixPtrs[i] = &(pBone->matWorld);
			}
		}
	}

	//재귀적으로 모든 프레임에 대해서 실행.
	if(pBone->pFrameFirstChild)
	{
		SetupBoneMatrixPtrs((ST_BONE*)pBone->pFrameFirstChild);
	}

	if(pBone->pFrameSibling)
	{
		SetupBoneMatrixPtrs((ST_BONE*)pBone->pFrameSibling);
	}
}
コード例 #12
0
ファイル: XEnitity.cpp プロジェクト: ongamex/old_stuff
void XEnitity::SetupBoneMatrices(CUSTOM_FRAME *pFrame)
{
	CUSTOM_MESHCONTAINER* pMeshContainer = (CUSTOM_MESHCONTAINER*) pFrame->pMeshContainer; 

	while(pMeshContainer && pMeshContainer->pSkinInfo){

		D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE];
		if( FAILED( pMeshContainer->MeshData.pMesh->GetDeclaration(Declaration) ) )
			return;
		//clone the mesh
		pMeshContainer->MeshData.pMesh->CloneMesh(D3DXMESH_MANAGED, Declaration, m_d3ddev, &pMeshContainer->pExSkinMesh);

		//calc the max bones
		DWORD NumBones = pMeshContainer->pSkinInfo->GetNumBones();
		m_MaxBones = max(m_MaxBones, (unsigned int)NumBones);

		for(unsigned int i = 0; i < NumBones; ++i){
			CUSTOM_FRAME* pTmpFrame = (CUSTOM_FRAME*) D3DXFrameFind(m_pTopFrame, pMeshContainer->pSkinInfo->GetBoneName(i));

			pMeshContainer->pExFrameCombinedMatrixPointer[i] = &pTmpFrame->exCombTransformationMatrix;
		}
		
		//loop for all meshes
		pMeshContainer = (CUSTOM_MESHCONTAINER*)pMeshContainer->pNextMeshContainer;
	}//end while

	//pass to siblings
	if(pFrame->pFrameSibling)
		SetupBoneMatrices((CUSTOM_FRAME*)pFrame->pFrameSibling);

	//pass to children
	if(pFrame->pFrameFirstChild)
		SetupBoneMatrices((CUSTOM_FRAME*)pFrame->pFrameFirstChild);

	return;
}
コード例 #13
0
//メッシュコンテナ内のボーンを設定
HRESULT MeshManager::SetupBoneFromMeshContainer(LPD3DXFRAME pFrameRoot,LPD3DXMESHCONTAINER pMeshCont)
{
	DxMeshContainer *pMeshContainer = (DxMeshContainer*)pMeshCont;

	//スキンメッシュのときはボーン行列をセット
	if(pMeshContainer->pSkinInfo)
	{
		DWORD NumBones = pMeshContainer->pSkinInfo->GetNumBones();

		pMeshContainer->ppBoneMatrixPtrs = new D3DXMATRIX*[NumBones];
		if( !pMeshContainer->ppBoneMatrixPtrs ) return false;

		LPCSTR str;

		for( DWORD i = 0; i < NumBones; i++ )
		{
			str = pMeshContainer->pSkinInfo->GetBoneName(i);
			DxFrame *pFrame = (DxFrame*)D3DXFrameFind(pFrameRoot, str );
			if( !pFrame) return false;
			pMeshContainer->ppBoneMatrixPtrs[i] = &pFrame->CombinedTransformationMatrix;
		}
	}
	return S_OK;
}
コード例 #14
0
ファイル: Mesh.cpp プロジェクト: helcl42/Game-DX
//-----------------------------------------------------------------------------
// Prepares the given frame.
//-----------------------------------------------------------------------------
void Mesh::PrepareFrame( Frame *frame )
{
	m_frames->Add( frame );

	// Check if this frame is actually a reference point.
	if( strncmp( "rp_", frame->Name, 3 ) == 0 )
		m_refPoints->Add( frame );

	// Set the initial final transformation.
	frame->finalTransformationMatrix = frame->TransformationMatrix;

	// Prepare the frame's mesh container, if it has one.
	if( frame->pMeshContainer != NULL )
	{
		MeshContainer *meshContainer = (MeshContainer*)frame->pMeshContainer;

		// Check if this mesh is a skinned mesh.
		if( meshContainer->pSkinInfo != NULL )
		{
			// Create the array of bone matrix pointers.
			meshContainer->boneMatrixPointers = new D3DXMATRIX*[meshContainer->pSkinInfo->GetNumBones()];

			// Set up the pointers to the mesh's bone transformation matrices.
			for( unsigned long b = 0; b < meshContainer->pSkinInfo->GetNumBones(); b++ )
			{
				Frame *bone = (Frame*)D3DXFrameFind( m_firstFrame, meshContainer->pSkinInfo->GetBoneName( b ) );
				if( bone == NULL )
					continue;

				meshContainer->boneMatrixPointers[b] = &bone->finalTransformationMatrix;
			}

			// Keep track of the maximum bones out of all the mesh containers.
			if( m_totalBoneMatrices < meshContainer->pSkinInfo->GetNumBones() )
				m_totalBoneMatrices = meshContainer->pSkinInfo->GetNumBones();
		}

		// Check if the mesh has any materials.
		if( meshContainer->NumMaterials > 0 )
		{
			// Load all the materials in via the material manager.
			for( unsigned long m = 0; m < meshContainer->NumMaterials; m++ )
			{
				// Ensure the material has a texture.
				if( meshContainer->materialNames[m] != NULL )
				{
					// Get the name of the material's script and load it.
					char *name = new char[strlen( meshContainer->materialNames[m] ) + 5];
					sprintf( name, "%s.txt", meshContainer->materialNames[m] );
					meshContainer->materials[m] = Engine::GetInstance()->GetMaterialManager()->Add( name, GetPath() );
					SAFE_DELETE_ARRAY( name );
				}
			}
		}
	}

	// Prepare the frame's siblings.
	if( frame->pFrameSibling != NULL )
		PrepareFrame( (Frame*)frame->pFrameSibling );

	// Prepare the frame's children.
	if( frame->pFrameFirstChild != NULL )
		PrepareFrame( (Frame*)frame->pFrameFirstChild );
}
コード例 #15
0
ファイル: ragdoll.cpp プロジェクト: 7zhang/studies
void RagDoll::InitRagdoll() {
    Release();

    InitBones((Bone*)m_pRootBone);

    Bone* Head_End = (Bone*)D3DXFrameFind(m_pRootBone, "Head_End");
    Bone* Head = (Bone*)D3DXFrameFind(m_pRootBone, "Head");
    Bone* Neck = (Bone*)D3DXFrameFind(m_pRootBone, "Neck");
    Bone* Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis");
    Bone* Spine = (Bone*)D3DXFrameFind(m_pRootBone, "Spine");
    Bone* R_Shoulder = (Bone*)D3DXFrameFind(m_pRootBone, "Shoulder_Right");
    Bone* L_Shoulder = (Bone*)D3DXFrameFind(m_pRootBone, "Shoulder_Left");
    Bone* U_R_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Upper_Arm_Right");
    Bone* U_L_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Upper_Arm_Left");
    Bone* L_R_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Lower_Arm_Right");
    Bone* L_L_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Lower_Arm_Left");
    Bone* R_Hand = (Bone*)D3DXFrameFind(m_pRootBone, "Hand_Right");
    Bone* L_Hand = (Bone*)D3DXFrameFind(m_pRootBone, "Hand_Left");

    Bone* R_Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis_Right");
    Bone* L_Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis_Left");
    Bone* R_Thigh = (Bone*)D3DXFrameFind(m_pRootBone, "Thigh_Right");
    Bone* L_Thigh = (Bone*)D3DXFrameFind(m_pRootBone, "Thigh_Left");
    Bone* R_Calf = (Bone*)D3DXFrameFind(m_pRootBone, "Calf_Right");
    Bone* L_Calf = (Bone*)D3DXFrameFind(m_pRootBone, "Calf_Left");
    Bone* R_Foot = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Right");
    Bone* L_Foot = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Left");
    Bone* R_Foot_End = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Right_End");
    Bone* L_Foot_End = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Left_End");

    D3DXQUATERNION q, q2;
    D3DXQuaternionIdentity(&q);
    D3DXQuaternionRotationAxis(&q2, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), D3DX_PI * -0.5f);

    //Head
    OBB* o01 = CreateBoneBox(Head, Head_End, D3DXVECTOR3(0.3f, 0.2f, 0.2f), q);

    //Right Arm
    OBB* o03 = CreateBoneBox(U_R_Arm, L_R_Arm, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q);
    OBB* o04 = CreateBoneBox(L_R_Arm, R_Hand, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q);

    //Left Arm
    OBB* o06 = CreateBoneBox(U_L_Arm, L_L_Arm, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q);
    OBB* o07 = CreateBoneBox(L_L_Arm, L_Hand, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q);

    //Spine
    OBB* o08 = CreateBoneBox(Spine, Neck, D3DXVECTOR3(0.5f, 0.35f, 0.15f), q);

    //Right Leg
    OBB* o09 = CreateBoneBox(R_Thigh, R_Calf, D3DXVECTOR3(0.4f, 0.15f, 0.15f), q);
    OBB* o10 = CreateBoneBox(R_Calf, R_Foot, D3DXVECTOR3(0.4f, 0.14f, 0.14f), q);
    OBB* o11 = CreateBoneBox(R_Foot, R_Foot_End, D3DXVECTOR3(0.15f, 0.06f, 0.12f), q2);

    //Left Leg
    OBB* o12 = CreateBoneBox(L_Thigh, L_Calf, D3DXVECTOR3(0.4f, 0.15f, 0.15f), q);
    OBB* o13 = CreateBoneBox(L_Calf, L_Foot, D3DXVECTOR3(0.4f, 0.14f, 0.14f), q);
    OBB* o14 = CreateBoneBox(L_Foot, L_Foot_End, D3DXVECTOR3(0.15f, 0.06f, 0.12f), q2);

    //Constraints
    CreateTwistCone(Neck, o01, o08, D3DX_PI * 0.15f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));

    CreateTwistCone(L_Pelvis, o08, o12, D3DX_PI * 0.5f, D3DXVECTOR3(0.3f, D3DX_PI * 0.5f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));
    CreateHinge(L_Calf, o12, o13, 0.0f, -2.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));
    CreateHinge(L_Foot, o13, o14, 1.5f, 1.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));

    CreateTwistCone(R_Pelvis, o08, o09, D3DX_PI * 0.5f, D3DXVECTOR3(0.3f, D3DX_PI * 0.5f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));
    CreateHinge(R_Calf, o09, o10, 0.0f, -2.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));
    CreateHinge(R_Foot, o10, o11, 1.5f, 1.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));

    CreateTwistCone(U_L_Arm, o08, o06, D3DX_PI * 0.6f, D3DXVECTOR3(0.0f, D3DX_PI * 0.75f, D3DX_PI * 0.0f), D3DXVECTOR3(0.0f, 0.0f, 0.0f));
    CreateHinge(L_L_Arm, o06, o07, 2.0f, 0.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f));

    CreateTwistCone(U_R_Arm, o08, o03, D3DX_PI * 0.6f, D3DXVECTOR3(0.0f, D3DX_PI * 0.75f, D3DX_PI * 0.0f), D3DXVECTOR3(D3DX_PI, 0.0f, 0.0f));
    CreateHinge(L_R_Arm, o03, o04, 2.0f, 0.0f, D3DXVECTOR3(0.0f, 0.0f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, -D3DX_PI * 0.5f));

    //Assign Pelvis bone to Spine OBB
    Pelvis->m_pObb = o08;
    D3DXVECTOR3 PelvisPos(Pelvis->CombinedTransformationMatrix(3, 0),
                          Pelvis->CombinedTransformationMatrix(3, 1),
                          Pelvis->CombinedTransformationMatrix(3, 2));

    Pelvis->m_pivot = o08->SetPivot(PelvisPos);
}
コード例 #16
0
ファイル: skinnedMesh.cpp プロジェクト: Alriightyman/RTS
BONE* SKINNEDMESH::FindBone(char name[])
{
	return (BONE*) D3DXFrameFind(m_pRootBone, name);
}