|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
04-28-2006 20:47
I want a prim to set its positon and rotation based on the position and rotation of another prim and need to figure out the math to do that. Using the rotation and postion of the first prim the second prim should set its roations and postions to always move to the same relative postion no matter how the first is placed. In other words it would act as if it were linked to the first.
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
04-28-2006 21:53
Hi Mod
Are you using llSetPos and llSetRos in your first prim?
If so, just shout their arguments to the second prim on some negative channel?
The second prim would need to offset the position. Not sure about the rot, but would that not be identical?
Limitations: 2nd object to be within 100 M from 1st. The string you shout has max length= 255.
Ed
|
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
04-29-2006 00:44
First, you want to figure out where you want the second object to be, relative to the first object, when it's NOT rotated (ie. at ZERO_ROTATION), and store this position as an offset vector. For example, if you always want the second object to be 2m away from the first, located along the first object's +y axis, it's offset would be < 0, 1, 0 >. Then, obviously, the real-world (region-coordinate) position that the second object must move to is just the first object's position plus this offset.
If the first object is rotated, this becomes only slightly more complicated. Since the first object is rotated, its axes are rotated as well. The offset you created to determine where the second object needs to be relative to the first should then be rotated by the same amount. So, you end up with the real-world position the second object needs to be in as:
Destination position = First object's position + ( offset * first object's rotation )
In terms of the second object's rotation, you'll want to store it's original rotation relative to the unrotated first object. Then, at any time, you can have it rotate itself correctly relative to the first object simply by multiplying the second object's original rotation by the first object's current rotation. An even simpler case is where the first and second objects are always aligned the same way (ie. both of them start out unrotated relative to the world axes), in which case the second object's rotation is always the same as the first's.
I hope that made sense. Here I am posting at 4am again... oO;
_____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Missing something
04-29-2006 02:55
I am probably misunderstanding what you have suggested but what I did did not make it work. Let me present a example: Initially, prim 1 is located <2,2,0> and zero rotation and prim 2 is located <2,3,0> and zero rotation. So the offset for prim 2 is <0,1,0>.Then prim 1 stays at the same position but is rotated 90 degrees. Prim 2 should move to 3,2,0 and rotate 90 degrees (if I am thinking correctly). Its new position is prim 1's postion + <1,0,0>. Ok, from what you suggested prim 2's new postion would be changed correcty by llSetPos(<2,2,0> + (<0,1,0> * prim 1's new rotation), but that does not work. So I must be misreading what you are saying.
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Got it
04-29-2006 03:06
Lament, it took me a few minutes to turn your suggestion into the correct script commands, but finally got it and it works, thank you.
Mod
|