加载.X模型的DirectX 9模型、加载、DirectX

2023-09-07 23:45:09 作者:遇见你

我试图让我的第一个3D演示了我的投资组合,但我有问题,加载多个.X文件,以便我也许可以做一个简单的游戏。

I'm trying to make my first 3D demo for my portfolio but I'm having problems loading in multiple .X files so that I might be able to make a simple game.

我已经通过MSDN教程和弗兰克·卢娜的书,展示了如何在一个网状加载工作。我甚至试过mod弗兰克斯演示code,但我发现他的code只能做什么,他打算。改装它仅仅是一个完整的头痛。

I've worked through the msdn tutorials and Frank Luna's book that show how to load in one mesh. I even tried to mod franks demo code but I've found his code only does what he intended to. Modding it is just a complete headache.

我想知道如果任何人知道和好帮手库或例如code网站,可以采取的麻烦出装载.X模型转化为一个游戏,让我移动至等

I'm wondering if anyone knows and good help libs or websites with example code, that can take the hassle out of loading .X models into a game and allow me to move them etc

推荐答案

在我学习的DirectX 9,的这个网站是一个很好的地方去寻找信息。

When I was learning DirectX 9, this site was a good place to look for information.

在简单地说,你必须调用 D3DXLoadMeshFromX的或它的衍生功能从文件(或内存)。

In a nutshell, you have to call D3DXLoadMeshFromX or one of its derivative functions to load the mesh object from a file (or memory).

您不能动的对象本身,你要推/流行基质积聚平移/旋转每个对象。例如对于旋转:

You cannot "move" the object per se, you have to push/pop matrices to accumulate a translation/rotation for each object. e.g for a rotation:

float fAngle = 2.f;
D3DXMATRIXA16 matWorld;
D3DXMatrixIdentity(&matWorld); // Identity Matrix
D3DXMatrixRotationY( &matWorld, fAngle );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );