为了账号安全,请及时绑定邮箱和手机立即绑定

MonoGame:渲染 3d 模型和 spritebatch 的问题

MonoGame:渲染 3d 模型和 spritebatch 的问题

C#
萧十郎 2023-05-14 16:51:29
我想在屏幕上绘制一些调试信息,但这会导致渲染模型出现问题。我在互联网上找到了一些解决方案,但它不起作用。也许我太笨了,但我不知道出了什么问题。这是绘制方法:    protected override void Draw(GameTime gameTime)    {        GraphicsDevice.Clear(Color.DarkCyan);        spriteBatch.Begin();        player.Draw(dt);        spriteBatch.DrawString(gamefont, "render Time :" + gameTime.ElapsedGameTime.TotalSeconds, new Vector2(0, 85), Color.White);        spriteBatch.End();        effect.View = player.view;        effect.Projection = player.projection;        effect.Texture = dirtTexture;        GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;        GraphicsDevice.BlendState = BlendState.Opaque;        GraphicsDevice.DepthStencilState = DepthStencilState.Default;        foreach (EffectPass p in effect.CurrentTechnique.Passes)        {            p.Apply();            effect.World = player.world;            GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, buffer.VertexCount / 3);        }        base.Draw(gameTime);    }这是它的样子
查看完整描述

1 回答

?
小唯快跑啊

TA贡献1863条经验 获得超2个赞

三角形法线(正面)被向后绘制。这是由顶点缓冲区中顶点的顺序定义的。

幸运的是,我们可以在GraphicsDevice. 只需添加以下行:

GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

如果给出相同的结果,请使用:

GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;


查看完整回答
反对 回复 2023-05-14
  • 1 回答
  • 0 关注
  • 126 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信