• 大小: 14.42MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-10
  • 语言: C/C++
  • 标签: 游戏  DirectX  C++  Direct3D  

资源简介

【C++】3D骨骼动画“剑舞”程序源码by浅墨

资源截图

代码片段和文件信息

//=============================================================================
// Desc: AllocateHierarchyClass.cpp
// 来自微软官方DirectX SDK Samples中的骨骼动画类
//=============================================================================

#include “AllocateHierarchyClass.h“

//--------------------------------------------------------------------------------------
// Name: AllocateName()
// Desc: 为骨骼或网格名称的字符串分配内存
//--------------------------------------------------------------------------------------
HRESULT AllocateName( LPCSTR Name LPSTR* pNewName )
{
UINT cbLength;

if( Name != NULL )
{
cbLength = ( UINT )strlen( Name ) + 1;
*pNewName = new CHAR[cbLength];
memcpy( *pNewName Name cbLength * sizeof( CHAR ) );
}
else
{
*pNewName = NULL;
}

return S_OK;
}

//--------------------------------------------------------------------------------------
// Name: GenerateSkinnedMesh
// Desc: 生成蒙皮网格模型。该函数判断当前网格容器是否包含有蒙皮信息,如果当前网格模型
//       中不包含蒙皮信息,则直接退出该函数。接下来确定所需要的矩阵调色板容量。最后调
//       用ID3DXSkinInfo::ConvertToIndexedBlendedMesh()函数生成索引蒙皮网格模型
//--------------------------------------------------------------------------------------
HRESULT GenerateSkinnedMesh( IDirect3DDevice9* pd3dDevice D3DXMESHCONTAINER_DERIVED* pMeshContainer )
{
D3DCAPS9 d3dCaps;
pd3dDevice->GetDeviceCaps( &d3dCaps );

if( pMeshContainer->pSkinInfo == NULL )
return S_OK;

SAFE_RELEASE( pMeshContainer->MeshData.pMesh );
SAFE_RELEASE( pMeshContainer->pBoneCombinationBuf );


if (FAILED(pMeshContainer->pSkinInfo->ConvertToBlendedMesh(
pMeshContainer->pOrigMesh 
D3DXMESH_MANAGED | D3DXMESHOPT_VERTEXCACHE
pMeshContainer->pAdjacency
NULL NULL NULL
&pMeshContainer->NumInfl
&pMeshContainer->NumAttributeGroups
&pMeshContainer->pBoneCombinationBuf
&pMeshContainer->MeshData.pMesh)))
return E_FAIL;
return S_OK;
}



//--------------------------------------------------------------------------------------
// Name: CAllocateHierarchy::Createframe()
// Desc: 创建框架 仅仅是分配内存和初始化还没有对其成员赋予合适的值
//--------------------------------------------------------------------------------------
HRESULT CAllocateHierarchy::Createframe( LPCSTR Name LPD3DXframe* ppNewframe )
{
HRESULT hr = S_OK;
D3DXframe_DERIVED *pframe;

*ppNewframe = NULL;

// 为框架指定名称
pframe = new D3DXframe_DERIVED;  // 创建框架结构对象
if (FAILED(AllocateName(Name (LPSTR*)&pframe->Name)))
{
delete pframe;
return hr;
}

// 初始化D3DXframe_DERIVED结构其它成员变量
D3DXMatrixIdentity(&pframe->TransformationMatrix);
D3DXMatrixIdentity(&pframe->CombinedTransformationMatrix);

pframe->pMeshContainer   = NULL;
pframe->pframeSibling    = NULL;
pframe->pframeFirstChild = NULL;

*ppNewframe = pframe;
pframe = NULL;

return hr;
}


//--------------------------------------------------------------------------------------
// Name: CAllocateHierarchy::CreateMeshContainer()
// Desc: 创建蒙皮网格容器,以加载蒙皮信息
//---------------------

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     393270  2013-04-20 00:56  D3Ddemo20 by浅墨\D3Ddemo20\353bd50.bmp

     文件     393270  2013-04-20 00:56  D3Ddemo20 by浅墨\D3Ddemo20\9496a70.bmp

     文件     786486  2013-04-20 00:56  D3Ddemo20 by浅墨\D3Ddemo20\9622210.bmp

     文件      16353  2013-04-21 18:15  D3Ddemo20 by浅墨\D3Ddemo20\AllocateHierarchyClass.cpp

     文件       3234  2013-04-21 21:12  D3Ddemo20 by浅墨\D3Ddemo20\AllocateHierarchyClass.h

     文件     196662  2013-04-20 00:56  D3Ddemo20 by浅墨\D3Ddemo20\bd378f0.bmp

     文件       9820  2013-04-20 01:10  D3Ddemo20 by浅墨\D3Ddemo20\CameraClass.cpp

     文件       2273  2013-03-30 22:40  D3Ddemo20 by浅墨\D3Ddemo20\CameraClass.h

     文件       4473  2013-04-21 19:52  D3Ddemo20 by浅墨\D3Ddemo20\D3Ddemo20.vcxproj

     文件       2046  2013-04-21 19:52  D3Ddemo20 by浅墨\D3Ddemo20\D3Ddemo20.vcxproj.filters

     文件        143  2013-04-21 19:33  D3Ddemo20 by浅墨\D3Ddemo20\D3Ddemo20.vcxproj.user

     文件        848  2013-04-06 08:51  D3Ddemo20 by浅墨\D3Ddemo20\D3DUtil.h

     文件       4595  2013-02-03 20:37  D3Ddemo20 by浅墨\D3Ddemo20\DirectInputClass.cpp

     文件       1287  2013-02-03 20:37  D3Ddemo20 by浅墨\D3Ddemo20\DirectInputClass.h

     文件      27371  2002-06-20 06:33  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\backaw2.jpg

     文件    9123374  2013-04-22 09:09  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\Eternal Love (Short Version).wav

     文件      35512  2002-06-20 06:34  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\frontaw2.jpg

     文件     120000  2013-03-17 20:28  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\heighmap.raw

     文件     171014  2004-03-02 22:23  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\icon.ico

     文件      26871  2002-06-20 06:34  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\leftaw2.jpg

     文件      33407  2002-06-20 06:34  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\rightaw2.jpg

     文件      36898  2013-03-30 23:04  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow1.jpg

     文件      45727  2013-03-30 23:07  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow2.jpg

     文件      51965  2013-03-30 22:55  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow3.jpg

     文件      38096  2013-03-30 23:00  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow4.jpg

     文件      46402  2013-03-30 23:02  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow5.jpg

     文件      36587  2013-03-30 23:13  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\snow6.jpg

     文件      14283  2002-06-20 06:34  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\topaw2.jpg

     文件     654220  2004-12-22 11:08  D3Ddemo20 by浅墨\D3Ddemo20\GameMedia\wood.jpg

     文件    5503680  2013-04-20 20:50  D3Ddemo20 by浅墨\D3Ddemo20\lxq.X

............此处省略37个文件信息

评论

共有 条评论