Version 2.0!
Features
Tutorials
Files
Glossary
Projects
Contact
Links
Message Board
Extras
LuckyCam
Old News
Sign Guestbook
View Guestbook
VB Horoscope
VB Photo Album
.
ATTENTION READERS! Lucky's VB Gaming Site is no longer active. For updated game programming information and tutorials, please visit The Game Programming Wiki!

Vector-Vertex Rotations

Have you ever wanted to make a 3D Model and then rotate it without having to use animations?

* Yeah, this tutorial is for that, but what do you need to do to rotate a model? First you need to learn about Vector Rotation:

Now I'll show you how to rotate matrices, and yes a vector is a 1x3 Matrix.... eeerrr, lets just go to useful stuff:

Vector Rotation is something very easy and short, you just need to have a Vector to rotate, an angle (in radians) and an AXIS that dosen't rotate (whose value stays the same).

'X is the New X the same for 'Y and 'Z

'X = X
'Y = Y * Cos(Rads) + Z * Sin(Rads)
'Z = Z * Cos(Rads) - Y * Sin(Rads)

Here is a VB function that does the same:

Public Sub RotateOverX(Vect as D3DVector, Rads as Single)
	Dim TempV as D3DVector
	TempV.X = Vect.X
	TempV.Y = Vect.Y * Cos(Rads) + Vect.Z * Sin(Rads)
	TempV.Z = Vect.Z * Cos(Rads) - Vect.Y * Sin(Rads)
	Vect = TempV
End Sub

Simple Huh?

You see, I used another vector to almacenate the old vector info. Don't think that you can do all with only 1 vector cuz when you are doing the rotation the values change in the process and we need the original values to determine old ones. You can also do this with a Vertex or Variables.

I Added a module to this tutorial that has all these functions. You may use it in your project or whatever you want.