rotation

hog

Well-known member
Joined
Mar 17, 2003
Messages
984
Location
UK
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 cant seem to suss it. The SDK help is of little or no use???
 
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 doesnt change, neither will the rotation, so do something like:
Code:
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 :)
 
Back
Top