yaw and roll turn the same way?
BlitzMax Forums/MiniB3D Module/yaw and roll turn the same way?
| ||
Check out this code where I have yaw commented out for testing.SuperStrict Import sidesign.minib3d Graphics3D 800, 600 Local Camera:TCamera = CreateCamera() PositionEntity Camera, 0, 0, - 10 Local light:TLight = CreateLight() Global Titletext:TMesh = LoadMesh("models/titletext.b3d") ScaleEntity Titletext, 0.8, 0.8, 0.8 PositionEntity Titletext, 0, 0, 0 Global pitch:Float, yaw:Float, roll:Float While Not KeyDown(KEY_ESCAPE) UpdateWorld() RotateEntity Titletext, 90, yaw, roll, True pitch:+1 'yaw:+1 roll:+1 If pitch > 360.0 Then pitch = 0.0 If yaw > 360.0 Then yaw = 0.0 If roll > 360.0 Then roll = 0.0 RenderWorld() BeginMax2D() DrawText "Pitch = " + pitch, 0, 0 EndMax2D() Flip WEnd When I add 1 to either yaw or roll the model I'm loading turns the same. It's as if the parameters do the same thing but should they? Please help 3d noob. :) |
| ||
Hmm, I'm no 3d expert but this *might* be due to Gimble Lock. http://www.anticz.com/eularqua.htm James |
| ||
RotateEntity is the same as three turns, in the order Yaw then Pitch then Roll. In each case the turn is around an axis as it is positioned after any earlier turns. The 90 degree pitch makes the Z-axis vertical, where the Y-axis used to be. So the final roll is around a vertical axis, just like an earlier yaw. And yes that's gimbal lock. |
| ||
Is this closer to what you were expecting? I attached your Titletext mesh to a pivot and set both of the RotateEntity() calls to be local. With this code my model spins around the Y axis (vertically on the screen) AND rotates around the Y axis of the model which is now horizontal since its parent is rotated 90 deg on the X axis.SuperStrict Import sidesign.minib3d Graphics3D 800, 600 Local Camera:TCamera = CreateCamera() PositionEntity Camera, 0, 0, - 10 Local light:TLight = CreateLight() 'Give the object another 3 degrees of rotation Global titlePivot:TEntity = CreatePivot() Global Titletext:TMesh = LoadMesh("models/titletext.b3d",titlePivot) ScaleEntity Titletext, 0.8, 0.8, 0.8 PositionEntity Titletext, 0, 0, 0 Global pitch:Float, yaw:Float, roll:Float While Not KeyDown(KEY_ESCAPE) UpdateWorld() RotateEntity titlePivot, 90, yaw, 0, False 'We want local rotations I believe RotateEntity Titletext,0,yaw,0, False 'pitch:+1 yaw:+1 roll:+1 'If pitch > 360.0 Then pitch = 0.0 If yaw > 360.0 Then yaw = 0.0 If roll > 360.0 Then roll = 0.0 RenderWorld() BeginMax2D() DrawText "Pitch = " + pitch, 0, 0 EndMax2D() Flip Wend Hope that helps. |