我的地形变得像这样奇怪的颜色:
http://tinypic.com/view.php?pic=307w421&s=7
有谁知道这里出了什么问题?我应该在代码的哪个区域(从概念上)进行调试?
更新:
它来自我学校的教程,基于:http ://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Starting_a_project.php
我们使用了 BasicEffect 着色器并制作了引擎的各个部分,例如:相机、从高度图派生的 3d 顶点地形、基本照明、基本软法线和用于优化的缓冲区。
VertexPositionColorNormal 结构:
public struct VertexPositionColorNormal : IVertexType
{
#region Field
public Vector3 Position, Normal;
public Color Color;
#endregion
#region Constructor
public VertexPositionColorNormal(Vector3 position, Color color, Vector3 normal)
{
Position = position;
Color = color;
Normal = normal;
}
#endregion
#region properties
public static VertexElement[] VertexElements =
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(sizeof(float)*3+4,VertexElementFormat.Vector3, VertexElementUsage.Normal,0),
};
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(VertexElements);
VertexDeclaration IVertexType.VertexDeclaration
{
get { return VertexDeclaration; }
}
#endregion