有什么毛病我的XNA魔​​方? [英] What's wrong with my XNA cube?

查看:148
本文介绍了有什么毛病我的XNA魔​​方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面这个样本试图建立在上面。我纳入了code到我的解决方案,这是一个Windows窗体应用程序(有点棘手W /新华社)。

I'm following this sample trying to build on it. I incorporated the code into my solution, which is a windows form app (a little tricky w/ XNA).

当我终于得到了一个立方体绘制它结束了内而外...或者在外面......还是?看到自己。

When I finally got a cube to draw it ended up inside out... or outside in... or? See for yourself.

该应用程序现在是几千行,所以我不能在这里贴。我需要知道从哪里开始寻找。

The app is now several thousand lines so I can't paste it here. I'll need to know where to start looking.

任何想法有什么不对吗?

Any idea what's wrong here?

看起来双方都越来越抽出顺序...但是,这不应该的问题。图形引擎应该确定什么是可见的,什么是不可见的,但它似乎是得到它错了。

It looks like the sides are getting drawn out of order... but that shouldn't matter. The graphics engine should determine what's visible and what's not visible but it seems to be getting it wrong.

在此先感谢。

推荐答案

有一个名为XNA Framework类的GraphicsDevice 里面包含了所有的属性基本呈现参数。

There is an XNA Framework class called GraphicsDevice which contains all of the properties for the basic rendering parameters.

内的GraphicsDevice有需要被具有以下属性构造一个部件结构DepthStencilState:

Inside GraphicsDevice there is a member struct DepthStencilState which needs to be configured with the following attributes:

  • DepthBufferEnable = TRUE
  • DepthBufferFunction = LessThanEqual
  • DepthBufferWriteEnable = TRUE

最简单的方法是简单地将其设置为静态定义的默认值。

The easiest way is to simply set it to the statically defined Default.

GraphicsDevice.DepthStencilState = DepthStencilState.Default;

如果您仍然有问题,确保到的RenderTarget您所呈现的是支持的深度纹理。例如:

If you are still having problems, make sure the RenderTarget to which you are rendering is a texture that supports depth. Example:

finalFrameRT = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);

如果您不希望看到的后置两侧的边后卫,你需要根据你的顶点索引的顺序设置 RasterizerState 来CullClockwise或CullCounterClockwise。

If you do not wish to see the backs of rear-facing sides, you need to set RasterizerState to CullClockwise or CullCounterClockwise according to the order of your vertex indices.

这篇关于有什么毛病我的XNA魔​​方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆