开发者

Graphical Glitch Xna GraphicsTutorial - Debug

开发者 https://www.devze.com 2023-03-03 10:40 出处:网络
My terrain gets weird colors like this: http://tinypic.com/view.php?pic=307w421&s=7 Does anyone have any idea what is going wrong here?

My terrain gets weird colors like this:

http://tinypic.com/view.php?pic=307w421&s=7

Does anyone have any idea what is going wrong here? In what area of my code (conceptually) should I look to debug this?

Update:

Its from a tutorial from my school based on: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Starting_a_project.php

We made use of the BasicEffect shader and made various parts of the engine such as: a camera, a 3d vertices terrain derived from a heigthmap, basic lighting, basic soft normals and an buffers for optimalization.

VertexPositionColorNormal Struct:

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, VertexElementFo开发者_运维知识库rmat.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


Try removing the , at the end of this line:

new VertexElement(sizeof(float)*3+4,VertexElementFormat.Vector3, VertexElementUsage.Normal,0),

I also noticed that you've added a constructor to your code but there isn't one on Riemer's site.

Also, it might be easier for you to post your code somewhere as a zip file so we can take a look that way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号