|
Windy Lurra
Registered User
Join date: 8 Sep 2006
Posts: 39
|
11-18-2006 20:52
Hello.
I'm working on a script that I can invoke on a 'control' object that's part of a house. This object would send its <x,y,z> position to the other individual objects that make up the house (the house is too big to link as one unit). The object receiving the position message will take that vector value, apply a subtractive vector operation, based on the known value of how far away its master prim is from the control unit.
It works beautifully, until I realized that it will break as soon as the house is rotated. So basically, I need to include in the message not only the control unit's position, but orientation. Does anyone have a formula that can be demonstrated in LSL that can apply the rotational transformation to the vector delta, so that the object can move to the correct location if it the house has been rotated?
Thanks!
|
|
carol Wombat
Registered User
Join date: 29 Jan 2006
Posts: 16
|
11-19-2006 05:49
Check out the record and positioning code in builder buddy. Post 25 summarises best the code that compensates the base rotation. /54/2b/96792/1.html
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
11-19-2006 05:52
If you set your root prim up with zero-rotation initially then delta*llGetRot() (for the base)should give you the right place. You will quite possibly also have to rotate the object to match as well... setting it's rotation to it's current rotation * base's rotation should do.
In snippet form:
base says (string)llGetPos()+"|"+(string)llGetRot();
target listens, parses by |, takes the vector for root pos and the rot for root rot as rPos and rRot
Final pos and rot are (llGetPos()-rPos)*rRot and llGetRot()*rRot.
At least, I hope so!
|
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
11-19-2006 13:12
This is probably a shameless plug, but check out my product rez-faux. There's not much sense in reinventing the wheel: it lets you package up your entire house and sell it, and your customers can rez and position it as a whole, even if it's made of multiple link sets.
That said, if what you really want is to learn the math and do it yourself, builder's buddy or multimove might be good places to look for hints.
|
|
Thanto Usitnov
Lord Byron wannabe
Join date: 4 Aug 2006
Posts: 68
|
11-19-2006 19:22
It seems to me that people are really overcomplicating this...
The prim broadcasting position should also broadcast rotation. Each part of the house receiving that should set its rotation accordingly. The position should be set like so, assuming you want to rotate on the xy plane only (IE: just turning it side to side, not rolling it): bPos = broadcasted position bRot = broadcasted rotation myPos = each linkset's position relative to the broadcaster at zero rotation
desired position = bPos + myPos.x * llRot2Fwd(bRot) + myPos.y*llRot2Left(bRot) + <0.0,0.0,myPos.z>
I may have x and y switched, and llRot2Left may need to be multiplied by negative 1. Anyway, llRot2Fwd returns a unit vector pointing forward, given a rotation (IE: strips a rotation of its S value, and turns it into a unit vector). This will be your new x axis. Move along this according to the desired x position of your linkset. llRot2Left returns a unit vector pointing left, given a rotation. This will be your new y axis. Move along this according to the desired y position. Then, move up according the desired height.
This should work, but I don't have access at the moment to check. And again, x and y might be switched, and llRot2Left may need to be multiplied by negative 1. Otherwise, that should be right.
|