Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FBX模型在XNA 4.0中未正确显示_C#_C# 4.0_Xna_Xna 4.0_Game Engine - Fatal编程技术网

C# FBX模型在XNA 4.0中未正确显示

C# FBX模型在XNA 4.0中未正确显示,c#,c#-4.0,xna,xna-4.0,game-engine,C#,C# 4.0,Xna,Xna 4.0,Game Engine,最近我发布了同样的问题,我的FBX模型在XNA中没有正确显示。我得到了问题的答案,模型显示得稍微好一点,但仍然无法正确显示 它应该是这样的: 但它表现为: 我的绘图代码是: public void Draw(Matrix projection, Matrix view) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms);

最近我发布了同样的问题,我的FBX模型在XNA中没有正确显示。我得到了问题的答案,模型显示得稍微好一点,但仍然无法正确显示

它应该是这样的: 但它表现为:

我的绘图代码是:

public void Draw(Matrix projection, Matrix view)
{
   Matrix[] transforms = new Matrix[model.Bones.Count];
   model.CopyAbsoluteBoneTransformsTo(transforms);

   foreach (ModelMesh mesh in model.Meshes)
   {
      foreach (BasicEffect effect in mesh.Effects)
      {
         effect.EnableDefaultLighting();
         effect.View = view;
         effect.Projection = projection;
         effect.World = Matrix.CreateRotationX(-270) *
                        transforms[mesh.ParentBone.Index] *
                        Matrix.CreateTranslation(Position);
      }
   mesh.Draw();
   }
}
有人能帮忙吗!
谢谢。

根据您之前的问题,Xna渲染图像显示您正在渲染2d和3d项目,在2d和3d之间重置一些图形状态非常重要

具体而言,在渲染2d素材后,添加以下线条:

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
这些设置对于3d是必需的,但在调用SpriteBatch.Begin()时会发生更改,因此有必要在3d设置之前将其更改回原来的设置

以下是解释这一点的博客帖子: 这是我的解决方案:

protected override void Draw(GameTime gameTime)
{

   GraphicsDevice.Clear(Color.CornflowerBlue);

   #region ResetGraphic

   ResetGraphic();

   #endregion
   #region render 3D
   BeginRender3D();
   //Render 3D here
   #endregion
   #region render 2D

   //Render 2D here
   #endregion

}

public void ResetGraphic()
{              
   GraphicsDevice.BlendState = BlendState.AlphaBlend;
   GraphicsDevice.DepthStencilState = DepthStencilState.None;
   GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
   GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

}

public void BeginRender3D()
{
   GraphicsDevice.BlendState = BlendState.Opaque;
   GraphicsDevice.DepthStencilState = DepthStencilState.Default;
}

我没有谷歌文档帐户,我看不到你的链接。下次使用Imgur。你不需要谷歌账户。好吧,当我点击链接时,它会要求我登录。点击这里:嗯。。。我的第一个猜测是,三角形的法线被翻转,使它们呈现为内到外。但无法四处移动和查看,但很难说清楚。此外,根据您的艺术,您可能需要添加此GraphicsDevice.SamplerState[0]=SamplerState.LinearRap;谢谢,对不起,我花了这么长时间才回来