我只是嘗試繪製一個簡單的3D模型(許多模型(.fbx)測試)與basicEffect在xna 4.0,並沒有其他對象像2d spritebatchs或文本或... 但它沒有正確顯示,我搜索它,並做了一些解決方案,但沒有一個工作 ,比如集合xna 3d模型破壞
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);
}
TY您的時間
ty m8,yeah nearPlaneDistance太小了,發現剛發佈問題後,將0.0001f修改爲0.1f fixxed這個問題 – mX64