Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multi item moving

PaperJack Easterwood
Registered User
Join date: 7 Oct 2008
Posts: 3
06-06-2009 12:12
Hello!

I am building a quite big ship, and I'd need some clarification.

I am using a nonphys vehicle as a main prim. This vehicle relays information about it's position and rotation. I know the offset of all the other objects; how can I make them warpos to the respective location and assume the right rotation ?
What if the objects aren't at rotation 0 0 0 ?

thanks!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 16:15
1) Align you base prim object at zero_rotation. (just to get the following data)

2) get all other object offsets and rotations as pairs partPos and partRot (they can be stored locally to that object)

3) when the move /rotation command is updated to the other parts, apply them with this formula..

newPartPos = newBasePos + partPos * newBaseRot;
newPartRot = partRot * newBaseRot

for warpPos (or better jumpPos) to trigger near simultaneous you may have to do a little work around...

base object sends pos updates via link message to child prim which region says the new position data (or the whole calculation). all parts (including the base) trigger their move from the regionsay..... (because prims can't hear their own says.)

other things to consider:
it's probably more effective to calculate the warp/jump pos call once, and parse it out to all of the sub parts, then to have each one do it separately (although this can be alot of data to send for a warpPos call, unless you compress the data as something like vector direction and multiple repeated, but then you've lost most of the benefit of single calculation). timely rotation matching is hard, because the outlying parts are updating position and rotation, and sometimes require jump/warpPos style calulations, which slows their update speed. building in delays to execution might be advisable, or having the farthest outlying part doing the actual move call (the base just initiates calculation). just as long as you're aware that certain rotations affect certain parts more, you should be safe.
_____________________
|
| . "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...
| -
PaperJack Easterwood
Registered User
Join date: 7 Oct 2008
Posts: 3
06-24-2009 08:05
Can you make me an example, because I didn't quite get what you said.
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
A semi-related follow-up
06-24-2009 11:12
Void,

You answered a similar question for me about how to move a motorcycle's handlebar assembly to make it appear the bike is turning to the left. To apply your response to this question to my situation are you saying that I need to...

1) Have each prim of the handlebar assembly report back to the root prim it's local position, offset and rotation and store those pairings

2) Manually move the fork assembly and have the same prims report their new location, offset and rotation and store those pairings

3) And then use something like llSetLocalPos and llSetLocalRot to move the fork back and forth between the two position depending on whether I want the wheel straight or turned?

Calculations for local vs global rotations, offsets, and positions confuse me to no end so any code snip-its you might offer to further illustrate how this might work would be greatly appreciated!

Thanks!
Ford
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-25-2009 01:17
this script gets the current local position and rotation of the part it's in on touch. run it once for each position, then delete it. (only neds to be dropped in the parts that will change position)
CODE

default{
touch_start( integer vInt ){
llOwnerSay( (string)llGetLinkNumber() + ":" + (string)llGetLocalPos() + "," + (string)llGetLocalRot() );
}
}


drop this script in each part that you got information from, the order is pos,rot parked, then pos,rot ridden, obviously to replace the #'s
CODE

list gLstPosRot = [#,#,#,#];

uShift( integer vBooSit ){
llSetPrimitiveParams( [PRIM_POSITION, llList2Rot( gLstPosRot , (vBooSit * 2) ), PRIM_ROTATION, llList2Rot( gLstPosRot , (1 + vBooSit * 2) )] );
}

default{
state_entry(){
/*//-- really only a just in case the object goes back to inventory while ridden --//*/
uShift( 0 );
}

link_message( integer vInt, integer vIntSit, string vStrCmd, key vKey ){
if ("v7-D Shift Product Position" == vStrCmd){
uShift( vIntSit );
}
}
}


this is the script that controls it all when it's done... when the rider sits it'll shift the alignment to the front, when the rider gets up it'll shift the positions to parked. it doesn't matter what prim this is in.
CODE

default{
changed( integer vBitChg ){
if (CHANGED_LINK & vBitChg){
integer vBooSit = (integer)((string)llAvatarOnSitTarget());
llMessageLinked( LINK_SET, vBooSit, "v7-D Shift Product Position", "" );
}
}
}


I was nice and did the control script with a boolean so you could reuse it to set the tilt of the whole bike.

if the parts only rotate around their respective axis then you can change the second script to only set rotations and you won't need position information

ETA:
I haven't checked these script for compile, so if they have errors you'll need to do that part yourself
_____________________
|
| . "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...
| -
Rutherford Beresford
Registered User
Join date: 2 Sep 2007
Posts: 45
Thank you!
07-01-2009 10:28
Thank you so much for your help!