Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation Math, arrrrggghhh! Help?

Nimbus Rau
Salmon pie? Where?
Join date: 15 Apr 2007
Posts: 292
11-27-2007 15:17
I'm making a gadget that rezzes a newt each time it is touched. So far it's working ok, with one notable exception - the location of the rezzed newt. It's fine if I have the emitter oriented in one specific direction, but if it's facing in any other direction, the newt is rezzed in the wrong place.

Now, I'm thinking that the answer will likely involve llRot2Fwd in some way. But I'm rather math-challenged, and for the life of me I can't figure out exactly how to set it up so that the newt is rezzed in the same position *relative to the emitter*, regardless of emitter placement.

Here's the current version of the rezzer script I've written:

default
{
state_entry()
{

}


touch_start(integer total_number)
{
vector eulbubble = <0,0,90>;
eulbubble *= DEG_TO_RAD;
rotation rotbubble = llEuler2Rot(eulbubble);

vector eulnewt = <-90,270,0>;
eulnewt *= DEG_TO_RAD;
rotation rotnewt = llEuler2Rot(eulnewt);

llMessageLinked(LINK_SET, 0, "zotness", NULL_KEY);
llSleep(0.5);
llTriggerSound("Zot!", 1);
llRezObject("zot bubble", llGetPos() + <0, 1, 0>, ZERO_VECTOR, rotbubble, 42);

llSleep (1.5);
llRezObject("Newt", llGetPos() + <0, 1, 0>, ZERO_VECTOR, rotnewt, 42);


}


}

How can I rewrite it so that the newt (and the "zot bubble" effect) are always rezzed in the same position and orientation relative to the emitter box?
_____________________
- Metamorphoses - Quad Cat Avatars & More
http://slurl.com/secondlife/Firespire/46/203/21/
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-27-2007 15:31
i belive you need a llSetRot() somewhere in the script
Nimbus Rau
Salmon pie? Where?
Join date: 15 Apr 2007
Posts: 292
11-27-2007 15:46
From: Mrc Homewood
i belive you need a llSetRot() somewhere in the script


Could you be more specific?

Note that the llRezObject function includes a parameter for the rotation of the object that is rezzed; would the llSetRot() be in addition to that? What, exactly, should it apply to?
_____________________
- Metamorphoses - Quad Cat Avatars & More
http://slurl.com/secondlife/Firespire/46/203/21/
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
11-27-2007 16:54
llRezObject("Newt", llGetPos() + (<0, 1, 0>*llGetRot()), ZERO_VECTOR, rotnewt * llGetRot(), 42);

Untested, but I think this will do what you want.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Nimbus Rau
Salmon pie? Where?
Join date: 15 Apr 2007
Posts: 292
11-27-2007 17:31
From: Seifert Surface
llRezObject("Newt", llGetPos() + (<0, 1, 0>*llGetRot()), ZERO_VECTOR, rotnewt * llGetRot(), 42);

Untested, but I think this will do what you want.


Brilliant! Thanks so much. :-)

As written, the newts arrive in rather odd positions vis-a-vis the emitter; but those odd positions do seem to be constant with respect to the emitter placement. So a bit of parameter-tweaking has got it working perfectly.

I've been wrestling with that one for the last week or two, and was about ready to pitch my newt emitter into the sea. Now it works *properly* Hooray!

/me does Happydance of Appreciation
_____________________
- Metamorphoses - Quad Cat Avatars & More
http://slurl.com/secondlife/Firespire/46/203/21/