【发布时间】:2012-01-06 18:57:00
【问题描述】:
我只是尝试在 xna 4.0 中使用 basicEffect 绘制一个简单的 3d 模型(许多模型 (.fbx) 测试),并且没有其他对象,如 2d spritebatchs 或 text 或... 但它没有正确显示,我搜索了它并做了一些解决方案,但没有人工作 喜欢设置
graphics.GraphicsDevice.BlendState = BlendState.Opaque;
graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
虽然我没有画其他东西!有趣的是,我已经可以毫无问题地使用 3d 模型了! 这是我的绘制代码和结果截图
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
graphics.GraphicsDevice.BlendState = BlendState.Opaque;
graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
foreach (ModelMesh mesh in m_Model.Meshes)
{
foreach (ModelMeshPart meshPart in mesh.MeshParts)
{
BasicEffect effect = (BasicEffect)meshPart.Effect;
effect.View = Matrix.CreateLookAt(new Vector3(0, 100, 1000), Vector3.Zero, Vector3.Up);
effect.World = bones[mesh.ParentBone.Index] * (Matrix.CreateWorld(Vector3.Zero, Vector3.Right, Vector3.Up));
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 0.0001f, 1000000f);
effect.EnableDefaultLighting();
}
mesh.Draw();
}
base.Draw(gameTime);
}
你的时间
【问题讨论】: