在 DirectX 9 中加载 .X 模型 [英] Loading a .X model in DirectX 9

查看:34
本文介绍了在 DirectX 9 中加载 .X 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的投资组合制作我的第一个 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 教程和 Frank Luna 的书,这些书展示了如何在一个网格中加载.我什至尝试修改 franks 演示代码,但我发现他的代码只能做他打算做的事情.修改它只是一个完全令人头疼的问题.

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.

我想知道是否有人知道并提供很好的帮助库或带有示例代码的网站,这可以消除将 .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 );

这篇关于在 DirectX 9 中加载 .X 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆