2 registered members (AndrewAMD, Akow),
1,371
guests, and 10
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
one object rotating around another wih vec_rotateaxis
#332931
07/13/10 01:18
07/13/10 01:18
|
Joined: Jan 2002
Posts: 300 Usa
Rich
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 300
Usa
|
Hi, I am having trouble getting this to work properly, so I assume I am doing it wrong. I have two objects, one one which I need to rotates around the axis of another. I thought the function vec_rotateaxis did this, but it doesn't seem to be working as I expected. It seems to rotate it around the level's axis, but I am sure I am doing it incorrectly. Any suggestions would be appreciated, thanks! Object B needs to rotate around Object A's (roll) Axis.
A8 com / A7 free
|
|
|
Re: one object rotating around another wih vec_rotateaxis
[Re: Rich]
#332934
07/13/10 02:30
07/13/10 02:30
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, this code rotates 'you' around 'me'.
vec_diff ( vtemp, you.x, my.x );
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );
PD: rotation around Y axis is tilt
|
|
|
EDITED*Re: one object rotating around another wih vec_rotateaxis
[Re: txesmi]
#332977
07/13/10 11:42
07/13/10 11:42
|
Joined: Jan 2002
Posts: 300 Usa
Rich
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 300
Usa
|
Hi, this code rotates 'you' around 'me'.
vec_diff ( vtemp, you.x, my.x );
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );
PD: rotation around Y axis is tilt Thanks I will test those out soon! Much appreciated! And about the tilt thing, oops! I made a mistake, was in a hurry . EDIT****** It seems to be working :), but the object also slowly spirals inward towards the axis. I'll keep playing with it.
Last edited by Rich; 07/13/10 12:17.
A8 com / A7 free
|
|
|
Re: one object rotating around another wih vec_rotateaxis
[Re: Rich]
#332987
07/13/10 13:29
07/13/10 13:29
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
you'll need to normalize
vec_diff ( vtemp, you.x, my.x );
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_normalize ( vtemp, Radius );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );
or use a variable as angle holder
nAngle += AngSpeed * time_step;
nAngle %= 360;
vec_for_angle ( vtemp, vector ( 0, nAngle, 0 ) );
vec_normalize ( vtemp, Radius );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );
Salud!
|
|
|
Re: EDITED*Re: one object rotating around another wih vec_rotateaxis
[Re: txesmi]
#332990
07/13/10 13:48
07/13/10 13:48
|
Joined: Jan 2002
Posts: 300 Usa
Rich
OP
Senior Member
|
OP
Senior Member
Joined: Jan 2002
Posts: 300
Usa
|
Works perfect! Thanks again !!
A8 com / A7 free
|
|
|
|