Roll on ..

Blitz3D Forums/Blitz3D Programming/Roll on ..

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I think there is a snooker ball example in the code archives, which is really simple - have you seen that?

re. the rolling asteroids, you could for example parent the asteroid model to a pivot, then orient and move the pivot. You are then free to roll the asteroid in any way you want without affecting its direction of motion.

Alternatively, store the pitch, yaw and roll of the asteroid in 3 variables, then on each program loop orient the object to point in the direction of motion, move it forwards (positive in the local Z axis), then orient it according to the stored pitch, yaw and roll variables. Then just increment the variables to make it spin.

This is just quickly typed into the browser and not tested, but roughly speaking -


global xa#,ya#,za#  ;angles of asteroid spin
global yaw#         ;angle of asteroid motion

;main loop
repeat

   ;orient it along dir of travel and move it forwards
   RotateEntity asteroid,0,yaw#,0
   MoveEntity asteroid,0,0,1

   ;alter the spin variables by some amounts
   xa# = xa# + 0.5
   ya# = ya# + 0.25
   za# = za# - 0.15

   ;spin it visually
   RotateEntity asteroid,xa#,ya#,za#

   ;UpdateWorld and RenderWorld etc.. down here

until done