在我的 XNA 游戏中,我使用 Viewport.Project 来获取太阳 3D 坐标的 2d 屏幕坐标(主要是因为它看起来不错)。我得到了这个工作,但是,当我朝太阳的相反方向看时,我看到了其中的两个(从技术上讲,一个)。我不知道这里发生了什么..
有谁知道发生了什么?我怎样才能防止这种情况发生?
为了帮助可视化这一点,这是我正在谈论的图像: 超链接图像,没有 10+ 代表
这是代码:
Rectangle clientBounds = Window.ClientBounds;
Texture2D sun = Content.Load<Texture2D>(@"Image\Skybox_Sun");
Vector3 coords = new Vector3(1000, 0, 1000);
Vector3 coords1 = graphics.GraphicsDevice.Viewport.Project(coords, camera.Projection, camera.View, Matrix.Identity);
suncoords = coords1;
spriteBatch.Begin();
spriteBatch.Draw(sun, new Vector2(coords1.X, coords1.Y), null, Color.White, 0, new Vector2(cursor.Width / 2, cursor.Height / 2), q, SpriteEffects.None, 0);
spriteBatch.End();