我有一个 3D FBX 模型,我想在 XNA 4.0 windows 游戏中绘制它。这是 FBX 查看器中的模型:
但是当我运行项目时,它显示如下
这是我的绘图方法:
private void DrawModel(Model model, Matrix worldMatrix, string name)
{
Matrix[] modelTransforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(modelTransforms);
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = Matrix.CreateWorld(position, new Vector3(0, 0, 1), Vector3.Up) * worldMatrix;
effect.View = viewMat;
effect.Projection = projectionMat;
}
mesh.Draw();
}
}
这是基本绘制方法:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
graphics.GraphicsDevice.BlendState = BlendState.Opaque;
graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
DrawModel(house, houseWorld, "house");
base.Draw(gameTime);
}
谢谢你的帮助