3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: help with iObjectSpin  (Read 1169 times)

« on: September 23, 2009, 05:43:18 PM »
hello!  :)

I'm trying to simulate a pause for a car game (in here: http://www.3drad.com/forum/index.php?topic=2641.0) and I think somehow I have almost everything solved but the rotation of the car.

If the car is spining (from drifting or a jump/accident) once resumed the spining is interrumpted.

I think, dont know, but think I could be able to solve that detail using iObjectSpin to get that spining values and reproduce it with the force object.

problem is I dont understand how iObjectSpin works, to be exactly I dont understand the return data and how I could apply to the force object (if!) to acomplish my objective.

searched for it in the forum but dosnt seem to be very popular...

anyone understand this function and could provide an example of usage?
also, you think I can use it with the force object to do what I want?

Quote
iObjectSpin(OBJ_X,Vector3)
   Return the specified object spin.
   OBJ_X = object handle
   Vector3 = spin vector.
             The vector direction is the axis of rotation (absolute).
             The length of the vector is the rotation speed (spin), in degrees per second.

another idea?
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #1 on: September 24, 2009, 02:09:09 PM »
ok! I figured it out myself...

-----------------------
EDIT: what I wanted and how is done.

first I get the spin values for the object:

iObjectSpin(OBJ_OBJECT,object_spin);

that giveme, as the instructions clearly say and my dead brain couldnt understand... the axis of rotation where the object is spining and the rotation speed.

so, I want to reproduce it using a force, and need to position and setup that force correctly; first, I need a quartenion:

iQuaternionLookAt(quaternion_spin,object_spin,Vector3(0,1,0));

and the location of the spining object:

iObjectLocation(OBJ_OBJECT,object_location);

now lets position the force:

iObjectPositionReset(OBJ_FORCE,quaternion_spin,object_location);

set the intensity: (*)

OUT_FORCE=iVectorLengthSq(carspin);

and start it!

iObjectStart(OBJ_FORCE);

look mum, is spining!

------------------------
(*)
this is a little detail:
instructions say this value that iobjectspin give me is rotation speed (spin), in degrees per second so the fact that I use iVectorLengthSq to set the force intensity is a very pulled out of my arse thing... I just used that because, at naked eye, the reproduced spining looks almost acurate compared with the original one... logic tell me this, if possible, would requiere another formula. but at that point I didnt care anymore because the main subject was solved.
« Last Edit: September 24, 2009, 06:09:28 PM by loop »
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
Pages: [1]