Skip to main content
gamedev.net
🔒 Locked

3D Motion Problem

Started by lost_jedi Aug 3, 2005 at 5:37 PM 0 replies 400+ views
Original Post
lost_jedi
lost_jedi
Heya again :) I was wondering if somone could tell me what is causing my model to rotate incorrectly. Here is an AVI movie showing my problem www.NHDigitek.com/XFlightFraps.rar When i sat down with my graph paper to figure out how i would make it rotate all the vectors in 3 axis as a local system i figured out that i needed 3 vectors to represent each axis and the way it faces. I might have gone about this the completely wrong way. But on my model/object i have 4(important) vectors Position (x,y,z) XVector(X,Y,Z) yVector(X,Y,Z) zVector(X,Y,Z) To rotate about the Z axis i use the following code:

Public Sub RotateZ(Angle As Double) 
With Normalize3dVector(OperatorMINUS(OperatorMP(XVector, Cos(Angle * PIdiv180)), OperatorMP(YVect, Sin(Angle * PIdiv180)))) 
    XVector.x = .x  
    XVector.Y = .Y 
    XVector.Z = .Z 
End With 
'Update the yVect wtih cross product 
YVect.x = CrossvectorProduct(ZVector, XVector).x * -1 
YVect.Y = CrossvectorProduct(ZVector, XVector).Y * -1 
YVect.Z = CrossvectorProduct(ZVector, XVector).Z * -1 

SpatialRotation.Z = SpatialRotation.Z + Angle 
End Sub
And instead of the "SpatialRotation += angle" bit at the end i have also tried

If Angle < 0 Then 
    SpatialRotation.Z = SpatialRotation.Z - Icos(DotProduct(ZVector, XVector)) 
Else 
    SpatialRotation.Z = SpatialRotation.Z + Icos(DotProduct(ZVector, XVector)) 
End If
But still no sucess. Thanks in advance ~ John.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.