Scott MacMaster Posted June 20, 2003 Posted June 20, 2003 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 Quote
*Experts* Nerseus Posted June 27, 2003 *Experts* Posted June 27, 2003 I would try using positive 1 for your SetNormal calls. You really want your normals to be normalized unit vectors. If you're not sure what that means, don't 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.