llRezObject Placement
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-02-2008 07:02
HIyas Everyone, I've been using the following function to rez objects: RezObject() { llRezObject(("Object"  ,(llGetPos()+<0.000,0.000,0.000>  ,<0,0,0>,llEuler2Rot(<0, 0, 0>*DEG_TO_RAD)*llGetRot(),0); } This has allowed me to rez an object above or below the center (x = 0.00, y = 0.00) of the root prim. Also keeping the same rotation of the root prim. Now I would like to rez the object at an x and y position that will follow the root prims rotation. So, instead of being placed at a plus/minus xy global position, I would like the function to calculate a new x and y position as the root prim rotates. I hope this makes sense. I've tried llGetLocalPos and llGetLocalRot but haven't had any success. All help will be greatly appreciated. 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-02-2008 08:06
Something like (note: not yet compiled; may need a minor syntax fix or two): rezObjectLocal(string object, vector localPos, vector localVel, rotation localRot, integer startParam) { rotation currRot = llGetRot(); llRezObject(object, llGetPos()+localPos*currRot, localVel*currRot, localRot*currRot, startParam); }
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
10-02-2008 08:56
llRezAtRoot is much easier to use than llRezObject when it comes to placing the root at a certain position. The two caries the same parameters and only differs in where they place the rezzed object. 
_____________________
From Studio Dora
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-02-2008 09:47
I'll try an analogy of what I am trying to do: Say I have a clock with a big circular face. I set clock flat on the ground. I step onto the center of the face where the hands meet and orient myself so I am facing the 12 o'clock position. So to my right would be the 3 o'clock position, and to my left is the 9 o'clock position. Okies, so now I rez an object from the clock's inventory at the 3 o'clock position 5 meters away from me (I'm still at the center of the clock). The object I rezzed has a constant height of 1 meter. The object also has the same xyz rotation of the clock. Now if I rotate the clock on it's z axis clockwise 90 degrees but I still stay facing the same direction I was facing, I would like the object to rez right behind me and have the same xyz rotation as the clock. It would still rez at the 3 o'clock position relative to the clock but now rezzes at the 6 o'clock position relative to me. The function I stated in my first post always rezzes the object in the same place no matter the rotation of the clock on it's z axis. I'm trying to get the rezzed object to follow the rotation of the clock 5 meters out. 
|
|
Jim Perhaps
Registered User
Join date: 10 Dec 2005
Posts: 65
|
This works for me
10-02-2008 10:04
I find this code very simple and works well for me. I am not sure how many meters you can position your rezzed object(s) away from the center of the prim that you rez your object(s) from. I only use it to position 10 meters out from center.
Changes you must make:
ObjectName = the name of the object you want to rez that is stored inside the prim you put this code in.
.... + <X,Y,Z> * .....
X = the measurement in meters on the X axis from the center of the prim that this code and your object is placed in. Y = the measurement in meters on the Y axis from the center of the prim that this code and your object is placed in. Z =the measurement in meters on the X axis from the center of the prim that this code and your object is placed in.
llRezAtRoot("ObectName",llGetPos() + <X,Y,Z> * llGetRot(), ZERO_VECTOR, llEuler2Rot(<0,0,0> * DEG_TO_RAD) * llGetRot(), 0);
I put the item I want in a prim and then I rez it out and position it with the above code.
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-02-2008 12:04
So far, everything I've looked at returns global values. I'm thinking maybe that the position vector needs to have its own variables and have those change when the object rezzer rotates: float X; float Y; float Z; RezObject() { llRezObject(("Object"  ,(llGetPos()+<0.000,0.000,0.000>  ,<X,Y,Z>,llEuler2Rot(<0, 0, 0>*DEG_TO_RAD)*llGetRot(),0); } but Z will be constant for me so I can assign it a value float Z = 1.0: Now, how to translate rotation of the object rezzer into xy coordinates for the object that it's going to rez? I did see some interesting functions about vectors and angles. I do not remember any geometry... lol
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-02-2008 12:38
See post #2. Passing a localPos of <1.0, 2.0, 3.0> would mean 1m along the prim's local x-axis, 2m along the prim's local y-axis, and 3m along the prim's local z-axis.
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-02-2008 12:44
From: Hewee Zetkin See post #2. Passing a localPos of <1.0, 2.0, 3.0> would mean 1m along the prim's local x-axis, 2m along the prim's local y-axis, and 3m along the prim's local z-axis. Everything shoots offworld when I try this. Maybe I don't understand your syntax.
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
10-02-2008 12:46
It sounds like you just want to rotate the position offset. If you're rezzing at llGetPos() + <5.0, 0.0, 0.0>, but want the offset to rotate along with the rezzer, try llGetPos() + (<5.0, 0.0, 0.0> * llGetRot())
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
10-02-2008 12:51
From: Day Oh It sounds like you just want to rotate the position offset. If you're rezzing at llGetPos() + <5.0, 0.0, 0.0>, but want the offset to rotate along with the rezzer, try llGetPos() + (<5.0, 0.0, 0.0> * llGetRot()) Thanx Day Oh... this worked perfectly! 
|
|
Rudolf Cleanslate
Registered User
Join date: 1 Dec 2006
Posts: 13
|
12-08-2008 03:54
The above works for me too...
I now want the rezzed object to preserve its relative rotation to the rezzer. Multiplying the rezzer's rotation by the rotation offset does not work. Anybody an idea whats wrong with the code below ? ...............................................................................
vector dps = <-0.40, 0.0, 0.0>; // relative position offset vector drs = <90,90,0>; // relative rotation offset
default { touch_start(integer total_number) { vector rpc = llGetPos() + (dps * llGetRot()); rotation rot = (llGetRot() * llEuler2Rot(drs * DEG_TO_RAD)); vector rotdeg = llRot2Euler(rot) * RAD_TO_DEG; llWhisper(0,(string)rotdeg); llRezAtRoot("object1",rpc,<0,0,0>,rot,0); } }
edit: I am rezzing an object, not a single prim.. I just discovered that if I use llRezObject, the child object is rezzed with a correct rotation. New problem is now that the object is no longer rezzed at the precise position offset. It seems that I have to add half the object dimensions to the position offset
|
|
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
|
12-08-2008 14:56
Try switching this: llGetRot() * llEuler2Rot(drs * DEG_TO_RAD)
To this: llEuler2Rot(drs * DEG_TO_RAD) * llGetRot()
I can't try it, but the first would give you global rotation while the second one is local rotation, which I think is what you want.
|