Scott MacMaster
Newcomer
- Joined
- Jun 19, 2003
- Messages
- 1
I'm trying to modify the code from tutorial 4 in the DirectX 9 SDK to have it display different shapes. However, I can't seem to get it right. I'm correctly working on a triangle. It kinda' displayed but there are wierd artifacts. For one attempt, I get a triangle displayed but there's also this big rectangle thing in the corner. For most other attempts, I get additional triangles going off in strange directions. Sometimes they are big, sometimes small.
Here are relevant lines of code from the program.
// define the vertices for the triangle
verts[0].SetPosition(new Vector3(-1, -1, 0));
verts[0].SetNormal(new Vector3(0, 0, -1));
verts[1].SetPosition(new Vector3(0, 1, 0));
verts[1].SetNormal(new Vector3(0, 0, -1));
verts[2].SetPosition(new Vector3(1, -1, 0));
verts[2].SetNormal(new Vector3(0, 0, -1));
// translate the world
device.Transform.World = Matrix.Translation(0, 0, -10);
// setup the camera
device.Transform.View = Matrix.LookAtLH( new Vector3( 0.0f, 0.0f, 0.0f ), new Vector3( 0.0f, 0.0f, -1.0f ), new Vector3( 0.0f, 1.0f, 0.0f ) );
// setup the projection
device.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI / 4.0f, 1.0f, 1.0f, 100.0f );
In addition, here is a screen shot of the results.
Can someone explain to me what is going on?
Thanks,
Scott MacMaster
Here are relevant lines of code from the program.
// define the vertices for the triangle
verts[0].SetPosition(new Vector3(-1, -1, 0));
verts[0].SetNormal(new Vector3(0, 0, -1));
verts[1].SetPosition(new Vector3(0, 1, 0));
verts[1].SetNormal(new Vector3(0, 0, -1));
verts[2].SetPosition(new Vector3(1, -1, 0));
verts[2].SetNormal(new Vector3(0, 0, -1));
// translate the world
device.Transform.World = Matrix.Translation(0, 0, -10);
// setup the camera
device.Transform.View = Matrix.LookAtLH( new Vector3( 0.0f, 0.0f, 0.0f ), new Vector3( 0.0f, 0.0f, -1.0f ), new Vector3( 0.0f, 1.0f, 0.0f ) );
// setup the projection
device.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI / 4.0f, 1.0f, 1.0f, 100.0f );
In addition, here is a screen shot of the results.
Can someone explain to me what is going on?
Thanks,
Scott MacMaster