XNA 3D coordinates seem off

Posted by Peteyslatts on Game Development See other posts from Game Development or by Peteyslatts
Published on 2012-12-04T17:26:46Z Indexed on 2012/12/04 23:22 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

I'm going through a book, and the example it gave me seems like is should work, but when I try and implement it, it falls short.

My Camera class takes three vectors in to generate View and Projection matrices. I'm giving it a position vector of (0,0,5), a target vector of Vector.Zero and a top vector (which way is up) of Vector.Up.

My Three vertices are placed at (0,1,0), (-1,-1,0), (1,-1,0).

It seems like it should work because the vertices are centered around the origin, and thats where I'm telling the camera to look but when I run the game, the only way to get the camera to see the vertices is to set its position to (0,0,-5) and even then the triangle is skewed. Not sure what's wrong here.

Any suggestions would be helpful.

Just to make sure I've given you guys everything (I don't think these are important as the problem seems to be related to the coordinates, not the ability of the game to draw them): I'm using a VertexBuffer and a BasicEffect.

My render code is as follows:

effect.World = Matrix.Identity;
effect.View = camera.view;
effect.Projection = camera.projection;
effect.VertexColorEnabled = true;

foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
    pass.Apply();

    GraphicsDevice.DrawUserPrimitives<VertexPositionColor>
         (PrimitiveType.TriangleStrip, verts, 0, 1);
}

© Game Development or respective owner

Related posts about XNA

Related posts about 3d