Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotating an already rotating object. Possible?

Joseph Worthington
The Suntan Mega-Man
Join date: 29 Jul 2006
Posts: 563
11-03-2007 18:09
Been beating myself over the head with a coconut for the past hour trying to figure out if the following is even possible. I've cobbled together a small boat comprised of 15 prims. I've added a llTargetOmega() function to the root prim, causing the entire thing to slowly spin about. So far so good. What I would like to do now is have the whole structure move in a slow, set circle around a center point. Unfortunately when I try to add a base prim for the boat to rotate around...the original root prim spins independently of the rest of the boat, more or less ripping it apart at the seams.

My question is.....is it at all possible, with or without adding a new prim to be the rotation center, to get my dingy moving in a slow lazy circle like I want? And if so....which functions and calls should I be experimenting with?
_____________________
Do what now?
Want more control over your Windlight Moon? Vote Here!!
Twisted Pharaoh
if ("hello") {"hey hey";}
Join date: 24 Mar 2007
Posts: 315
11-05-2007 02:23
You can? Yes. Simply? No.

Unfortunately you need to use one and only one rotating function that would be the sum of your 2 rotations. I am unsure if you can do it in one call but with a timer event it should be doable. Ask a geometry expert about that it is not my strong point.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-05-2007 23:34
yes you can rotate around a set offset, by using llSetPos in conjunction with your rotation...


the following will rotate a prim (or object) around a given offset
CODE

vector vVecOffset = <.0, .0, 1.0>; //-- the point we are rotating around in relation to our object
vector vgVecArc = <.0, .0, 60.0>; //-- how far around the circle to travel each move
rotation vgRotArc = llEuler2Rot( vgVecArc * DEG_TO_RAD );
//-- notice you have to move AND rotate, or else the new
//-- position becomes a diagonal line instead of a circle
llSetPrimitiveParams( [PRIM_POSITION, llGetPos() + (vVecOffset - vVecOffset * vRotArc) * llGetLocalRot(),
PRIM_ROTATION, vRotArc * llGetLocalRot] );

stripped directly from my user page at


and unlike many wiki examples of rotating around a point, that not only works (a rarity), but works at any angle (but only in root prims because child prim rotations are borked... I haven't added conversions for those yet)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Joseph Worthington
The Suntan Mega-Man
Join date: 29 Jul 2006
Posts: 563
11-07-2007 01:16
Thank you both very much. I was afraid I'd have to use the llSetRot function....with pretty much made my brain leak out through my ears when I looked at it. This, truthfully, doesn't look much simpler....but at least now I have a starting point to set me down the right path. Thank you both kindly.
_____________________
Do what now?
Want more control over your Windlight Moon? Vote Here!!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-07-2007 05:10
From: Joseph Worthington
Thank you both very much. I was afraid I'd have to use the llSetRot function....with pretty much made my brain leak out through my ears when I looked at it. This, truthfully, doesn't look much simpler....but at least now I have a starting point to set me down the right path. Thank you both kindly.

heh technically you ARE using it in my exmple.. it's just combined with llSetPos in the llSetPrimitiveParams call.

just make sure it goes in the root prim of the object you want to set into orbit around a point...

and to be honest, that's about the simplest that particular function can be, except for attaching a full alpha stretched dimpled sphere as the root and using llTargetOmega, which has it's own issues, or using a variation of the door script on the same, with no direction switching

EDIT: brief explanation of the above code example.

PRIM_POSITION:
get our pos + (
our offset (the point we'll rotate around) -
our offset rotated arc degrees (to move us back out from the offset point) *
our rotation (to make it relative to where we are facing) =
our new position

PRIM_ROTATION:
our arc(how much we're turning) *
our rotation(where were facing now) =
our new facing to so that we turn smoothly
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -