Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Does anyone have any pointers, help on how to rotate in 3d?

 

Problem:

 

I have a square made of 2 primitives and can successfully display them with a texture of a walking man.

 

I want to be able to simply rotate the square clockwise but can't seem to suss it. The SDK help is of little or no use???

My website
Posted

you need to use Matrices,

 

d3dDevice.Transform.World = RotateY(angle)

d3dDevice.Transform.World = RotateX(angle)

d3dDevice.Transform.World = RotateZ(angle)

 

Those will rotate the object around the origin but they are absolute in that if angle doesn't change, neither will the rotation, so do something like:

Public Const Speed As Long = 2000 'Decrease SPEED to go faster

Dim angle As Single = PI / SPEED 

Private Sub DoMatrices()
   d3dDevice.Transform.World = Matrix.Identity
   d3dDevice.Transform.World = Matrix.RotateZ(angle)
   angle += PI / SPEED
End Sub

 

now just call that everytime before you draw :)

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...