本想用骨骼动画无奈.x格式太过于复杂而且游戏业里也不如何用
只是把它原理弄明白些了但是我弱小意志在DirectXSDK那个1000多行SkinedMesh例子面前顺利地崩溃了心想还是先从最基本关键帧动画开始做吧-_-!
确定文件格式:md2(正好连找都不用找了老师给了)
以下是我Copy:MD2文件格式介绍
MD2是Quake2中使用模型文件格式由于其比较简单容易实现所以应用很广是种经典动画模型格式该文件格式由2部分组成:部分是文件头包含了文件ID号、版本号和有关模型各种数据起始地址等;另部分是文件主体包含了有关模型各种数据如顶点数据、纹理数据、法向量数据等
MD2是基于关键帧动画关键帧插值数学公式为:
p(t)=p(0)+t(p1-p0)
其中:
t—当前时间0表示开始1表示结束;
p(t)—时间t时方程值;
p0—起始位置;
p1—结束位置
MD2共有16个关键帧:
start:0end:39name:stand
start:40end:45name:run
start:46end:53name:attack
start:54end:65name:pain
start:66end:71name:jump
start:72end:83name:flip
start:84end:94name:salute
start:95end:111name:taunt
start:112end:122name:wave
start:123end:134name:po
start:135end:153name:crstnd
start:154end:159name:crwalk
start:160end:168name:crattack
start:169end:172name:crpain
start:173end:177name:crdeath
start:178end:197name:death
说白了个模型有16个动作每个动作有很多帧组成每帧由很多 3角形组成个网络每个 3角形由 3个顶点组成每个顶点由x,y,z 3个坐标组成每个……(再说就欠揍了)
那么如何让它动呢?知道如何放电影不?就是帧帧地画就行了!
这是我改写类:
#pragmaonce
#
#
/**//***************************************************************************/
/**//**/
/**//*File:XMD2Model.h*/
/**//*Author:[email protected]*/
/**//*Date:10-11-2002*/
/**//**/
/**//***************************************************************************/
//Thisfileholdsourselfcontained.md2(quake2)forloadinginand
//displayingour.md2fileindirectX3D.
structstMd2Header
...{
magic;//Themagicnumberusedtoidentythefile.
version;//Thefileversionnumber(mustbe8). [Page]
skinWidth;//Thewidthinpixelsofourimage.
skinHeight;//Theheightinpixelsofourimage.
frameSize;//Thesizeinstheframesare.
numSkins;//Thenumberofskinsassociatedwiththemodel.
numVertices;//Thenumberofvertices.
numTexCoords;//Thenumberoftexturecoordinates.
numTriangles;//Thenumberoffaces(polygons).
numGlCommands;//Thenumberofglcommands.
numFrames;//Thenumberofanimatedframes.
offSkins;//Theoffhefilefortheskindata.
offTexCoords;//Theoffhefileforthetexturedata.
offTriangles;//Theoffhefileforthefacedata.
offFrames;//Theoffhefilefortheframesdata.
offGlCommands;//Theoffhefilefortheglcommandsdata.
offEnd;//Theendofthefileoff.
};
//Somestructurestoholdorreadindatain.
structstMd2Skins
...{
charskinName[64];
};
structstMd2TexCoords
...{
u,v;
};
structstMd2Triangles
...{
vertexIndex[3];
texIndex[3];
};
structstMd2Vertices
...{
floatvertex[3];
floatnormal[3];
};
structstMd2Frames
...{
charname[16];
stMd2Vertices*pFinalVerts;
};
//Thewovariablesaredeclaredindxdraw.cppthatswhytheyhavethe
//externkeywordinfrontofthem.
externLPDIRECT3DDEVICE9g_pd3dDevice;
structstKeyFrame
...{
start;
end;
charszName[16];
};
structstKey
...{
numKeys;
stKeyFrame*pKey;
};
//OurDirectX3Dstructuredefinition.
structmy_vertex
...{
D3DXVECTOR3m_vecPos;//位置
D3DCOLORm_dwDfuse;//颜色 [Page]
D3DXVECTOR2m_vecTex;//纹理坐标
};
最新评论