Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rez along prim Axis

Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
12-01-2008 11:30
Fisrt let me say that I am not a script writer or programmer so this type of stuff does not come easy to me. I am building a clock with a prim-based pendulum. I use Object Rez or rRezAt Root to make the 3-piece pendulum appear. One then touches the pendulum and it swings away happily. All well and good until the the clock is rez at a different rotation form the original build. Is there a way to have the object rez aligned with the axis (perpendicular to the face) no matter how he clock is positioned after if is rezzed?

Thanks a lot.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-01-2008 11:45
In the params to llRezObject & llRezAtRoot, there's a rotation param.

Try using llGetRot() for that param..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
12-01-2008 11:57
Here is one of the scripts being used:

//Rez an object on touch
string object = "Object";//Object in inventory
integer start_param = 10;
rotation rot;

default
{
state_entry()
{
rot = llEuler2Rot(< 0, 90, 90> * DEG_TO_RAD);
}
touch_start(integer a)
{
vector vec = llGetPos() + < 0.0, 0.0, 5.0>; // 5 meter above this
vector speed = llGetVel();
llRezAtRoot(object, vec, speed, rot, start_param);
}
}


i can (by hand) rotate the position of the pendulum by inserting the rotation in the
rot =llEuler2Rot portion

What i don't know how to do is to capture that info depending on how the clock is rezzed. The pendulum face and swing needed to aligned to the clock axis which could be almost any thing.

If script examples can be posted that would help me understand, assume i know nothing, LOL

Thanks
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-01-2008 12:00
Does it come out right it you use this instead?

lRezAtRoot(object, vec, speed, rot * llGetRot(), start_param);
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
12-03-2008 00:13
From: Wyatt Weatherwax
What i don't know how to do is to capture that info depending on how the clock is rezzed. The pendulum face and swing needed to aligned to the clock axis which could be almost any thing.

If script examples can be posted that would help me understand, assume i know nothing, LOL

Thanks
To rez along an axis, first convert the rotation to a vector:
llRot2Fwd(rot) will give you 1m along the x axis
llRot2Left(rot) will give you 1m along the y axis
llRot2Up(rot) will give you 1m along the z axis

You only need to choose the one direction you want to rez along, and multiply the resulting vector by the distance along that vector (or nothing for 1m). Multiply by a negative value to go the other way (back, right, down).

So to rez 2m along Y, you get something like:

string object = "<name_of_thing>";
rotation rot = llGetRot();
vector offset = llRot2Left(rot) * 2.0;
llRezAtRoot(object, llGetPos() + offset, ZERO_VECTOR, rot, -1);
Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
12-03-2008 04:08
Thanks for the suggestions, I will give them a try and report back. There is still hope I can get these presents done in time. :))
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
12-03-2008 04:22
From: Meade Paravane
Does it come out right it you use this instead?

lRezAtRoot(object, vec, speed, rot * llGetRot(), start_param);

Almost, you need to rotate the relative position too:
llRezAtRoot( object, llGetPos() + < 0.0, 0.0, 5.0 > * llGetRot(), speed, rot * llGetRot(), start_param );
_____________________
From Studio Dora
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
12-03-2008 08:47
this would be useful for an application i have but i would need the object to res 2 meters along the x axis and 1 along the Y, how do you combine them?
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
12-03-2008 09:00
This is all great info and a solution is forming. If anyone wants an additonal challenge, there is another type of "pendulun" in the form a 4 balls that rotate horizontally for several revolutions, slow to a stop and the rotate with equal for back (clockwise to counter clockwise) and looped. I an currently using a swing script but is is NOT smooth and the speeds are all equal (no slowing down).

Suggestions and/pr script examples would be appreciated.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-03-2008 09:02
From: Maihem Randt
this would be useful for an application i have but i would need the object to res 2 meters along the x axis and 1 along the Y, how do you combine them?

I think it's just:

vector destination = llGetPos() + (<2.0, 1.0, 0.0> * llGetRot());
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-03-2008 09:04
From: Wyatt Weatherwax
This is all great info and a solution is forming. If anyone wants an additonal challenge, there is another type of "pendulun" in the form a 4 balls that rotate horizontally for several revolutions, slow to a stop and the rotate with equal for back (clockwise to counter clockwise) and looped. I an currently using a swing script but is is NOT smooth and the speeds are all equal (no slowing down).

Suggestions and/pr script examples would be appreciated.

Sounds like a good case for http://wiki.secondlife.com/wiki/LlRotLookAt or llLookAt.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Wyatt Weatherwax
Registered User
Join date: 23 Oct 2007
Posts: 59
12-03-2008 09:12
Meade - I looked at that but can't makes heads or tails of it without an example to follow. I'm good a tweaking scripts but not writing them. However, everyone can have a clock when I'm done. :)
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
12-03-2008 09:19
From: Meade Paravane
I think it's just:

vector destination = llGetPos() * (<2.0, 1.0, 0.0> * llGetRot());


I was trying to add that into this script but i keep getting errors:(

default
{

touch_start(integer total_number) {

rotation rot = llGetRot();
vector offset = llRot2Left(rot) * 2.0;
llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT,0), llGetPos() + offset, ZERO_VECTOR, rot, -1);

}

}

can anyone help?
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-03-2008 09:29
From: Maihem Randt
can anyone help?

Oops! Typoed.. Should be:

vector destination = llGetPos() + (<2.0, 1.0, 0.0> * llGetRot());
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
12-03-2008 09:31
when trying to add in
vector destination = llGetPos() * (<2.0, 1.0, 0.0> * llGetRot());
i was getting syntax errors, probably because i cant figure out where to stick it, and I am not sure what part of the original script should be deleted out if any
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-03-2008 11:07
From: Maihem Randt
when trying to add in
vector destination = llGetPos() * (<2.0, 1.0, 0.0> * llGetRot());
i was getting syntax errors, probably because i cant figure out where to stick it, and I am not sure what part of the original script should be deleted out if any

I typo'ed - it should be llGetPos() +..., not llGetPos() *...

Something like this might work:
default
{
touch_start(integer total_number)
{
rotation rot = llGetRot();
vector offset = <2.0, 1.0, 0.0>;
llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT,0) , llGetPos() + (offset * rot), ZERO_VECTOR, rot, -1);
}
}
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
12-03-2008 22:05
that worked perfectly thank you very much :)
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n