Advertisement Jump to content
Sign in to follow this  

3D Motion Problem

This topic is 4919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 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)) 
    SpatialRotation.Z = SpatialRotation.Z + Icos(DotProduct(ZVector, XVector)) 
End If
But still no sucess. Thanks in advance ~ John.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!