Trouble Figuring Out Direct3d

Scott MacMaster

New member
Joined
Jun 19, 2003
Messages
1
Im trying to modify the code from tutorial 4 in the DirectX 9 SDK to have it display different shapes. However, I cant seem to get it right. Im correctly working on a triangle. It kinda displayed but there are wierd artifacts. For one attempt, I get a triangle displayed but theres 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
 
I would try using positive 1 for your SetNormal calls. You really want your normals to be normalized unit vectors. If youre not sure what that means, dont worry :) Just replace the "-1" parts of SetNormal(...) to "1".

If all else fails, zip up your project (minus any binaries - the bin folder) and let us take a look.

-Nerseus
 
Back
Top