Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...