Rezzing objects from a face
|
Dominus Skye
Bug Magnet
Join date: 31 Oct 2004
Posts: 54
|
02-08-2005 14:28
Looking for a quick formula to rez an item out of inventory, so that it is 1 metre away from the face of an object, regardless of how that object is rotated.
llRezObject("object", llGetPos() + <1, 0, 0>,ZERO_VECTOR, ZERO_ROTATION, 0);
works fine until the object is rotated, so I need a way of determing the offset from face 1 for x and y values.
Any assistance would be appreciated -)
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
02-08-2005 14:59
The best (and only) way to do this short of iterations based on prim shapes (pain) would be to use: http://secondlife.com/badgeo/wakka.php?wakka=llGetBoundingBox
_____________________
---
|
Tread Whiplash
Crazy Crafter
Join date: 25 Dec 2004
Posts: 291
|
Object Rotations...
02-08-2005 17:39
From: Dominus Skye works fine until the object is rotated, so I need a way of determing the offset from face 1 for x and y values.
You can use "llGetRot()" on the prim in question, to get its orientation. If you want to know where to position something with that rotation taken into account, search the "Scripting Library" forum section for the threads on "Offset Rotation". Note that your described method is not face-specific, however. It is simply offset from the center of the Prim in question. As Dominus mentions, trying to position something based on the shape of the prim or a particular face on a prim is going to be mind-bogglingly tough to do "on the fly". It would be much better to figure it all out ahead-of-time, manually. Rez the objects and move them to their desired relative positions. Write down their positions and rotations, and calculate the combined offsets and rotations needed to place Object "B" aligned with Object "A" in the manner you want. Then store those values in your script, for use when rezzing Object "B". When you're ready to rez, multiply the llGetRot() value from "Object A" by the offsets you previously stored (assuming "Object A" started with a rotation of <0, 0, 0>. If it didn't, you will need to find the difference between its initial rotation & the new rotation). Hope this info helps... Take care, --Noel "HB" Wade (Tread Whiplash)
|
Dominus Skye
Bug Magnet
Join date: 31 Oct 2004
Posts: 54
|
02-08-2005 19:25
I appreciate the help -) However, I am thinking it is possible I am going around this in the wrong manner. Let me give an example...
Assume you were making a giant chicken, where on touch you wanted it to lay an egg. The egg is an object in the inventory of the chicken. Using llRezObject with a fixed x,y,z offset is not an option, since if the chicken is later rotated, it may be laying the egg out of its front, rather than, well ... you know where they come out of.
So, in order to ensure that the egg comes out the rear instead of the front, am I overcomplicating issues by trying to tie the alignment to the face of the object that the egg will rezz from? Is there a simpler way?
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
02-08-2005 19:38
Try: llRezObject("object", llGetPos() + (llGetRot() / <1, 0, 0>  ,ZERO_VECTOR, ZERO_ROTATION, 0);
_____________________
---
|
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
|
02-08-2005 21:23
To make the object appear at distance d along the x axis of the rezzor do this:
float d = 2 ;
llRezObject("Object", llGetPos() + d * llRot2Fwd( llGetRot() ), ZERO_VECTOR, ZERO_ROTATION, 0);
For the y axis use llRot2Left instead of llRot2Fwd.
For the z axis use llRot2Up instead of llRot2Fwd.
Jeffrey's code does not compile, rotations "divided by" vectors is not legal.
_____________________
-
So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.
I can be found on the web by searching for "SuezanneC Baskerville", or go to
http://www.google.com/profiles/suezanne
-
http://lindenlab.tribe.net/ created on 11/19/03.
Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard, Robin, and Ryan
-
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
02-09-2005 04:27
Uhh...
llRezObject("object", llGetPos() + <1, 0, 0> * (ZERO_ROTATION / llGetRot()),ZERO_VECTOR, ZERO_ROTATION, 0);
Try that.
Basically you just have to tack * (ZERO_ROTATION/llGetRot()) onto whatever location you want in order for it to calculate rotation. It's the same technique you use in llSitTarget teleportation when the teleporter is rotated.
_____________________
</sarcasm>
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
02-09-2005 06:31
From: SuezanneC Baskerville Jeffrey's code does not compile, rotations "divided by" vectors is not legal. I use the "divide by" rule plenty, thanks. Thing is, I accidentally wrote it in reverse. It's <1,0,0> / llGetRot(), not the other way around - which is why Mole's code also works. After all, I already got slammed for doing it the hard way. 
_____________________
---
|
Dominus Skye
Bug Magnet
Join date: 31 Oct 2004
Posts: 54
|
02-09-2005 12:33
Thanks to everyone for their responses -) I could feel in my gut there were a number of ways to do it, just damned if I could find one .... now I have several!  Thank you as always, Dominus
|