Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with script!

Tara Bournemouth
Registered User
Join date: 9 Oct 2006
Posts: 21
08-31-2007 00:27
I'm having a bit of a problem with a script I'm using. I'm not a scriptor so plz bare with me :)

I'm using a rez script and the problem i'm having is when i rez something it is totaly turned right around. I've been playing with the numbers inside to get the object upright like i want but nothing I do is even coming close to what I want. I was wondering if someone could plz help me is there somewhere I'm suppost to be getting these numbers from? What am I doing wrong?

This is the part I keep playing around with

llRezObject("Object1", llGetPos() + <0.0, 0.0, 0.0>, ZERO_VECTOR,<0.0,0.0,68.0,5.0>, 42);

If you could help me out with this and and help me understand this line a bit better it would be greatly appreciated :)

Also you might need to know this the objects i'm trying to rez are linked together there are about ten in all. I need the whole set positioned right. Does it have to do with the root prim itself?
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
08-31-2007 00:49
From: Tara Bournemouth
llRezObject("Object1", llGetPos() + <0.0, 0.0, 0.0>, ZERO_VECTOR,<0.0,0.0,68.0,5.0>, 42);


Ok, the syntax of llRezObject is as follows:

llRezObject(string inventory, vector pos, vector vel, rotation rot, integer param)

The first item is a string that is the inventory item name..

The second position in region co-ordinates... in your case, it's grabbing the position of the rezzing object, and adding an offset of <0,0,0> which makes no sense.. it will rez at the center of the rezzing object.. there should be some offset such as <1,0,0> or <0,1,0> or <0,0,1> to move it away from the rezzing object.

The 3rd is the velocity, if the object is non-physical, this parameter is ignored.

The fourth is the rotation, in quarternions, not euler co-ordinates. You said it was 'turned around' so I'm assuming rotating it 180 degrees on the z axis will 'fix' it for you, so do this:

vector rotate_it = <0,0,180>; // the eular representation of the rotation you want...
rotate_it *= DEG_TO_RAD // convert degrees to radians...
rotation quat = llEular2Rot(rotate_it); //convert from eular to a rotational quaternion
llRezObject("Object1", llGetPos() + <1.0, 0.0, 0.0>, ZERO_VECTOR,quat, 42);

now.. I set an offset on the X axis 1 meter from the center of the rezzing object.... you can change that if you need to, and, you can now change the vector in the 1st line from <0,0,180> to whatever it would take to spin your object around how u want, therefore, you can think in terms of degrees and eular representations (roll/pitch/yaw).

the last item is a value passed from the rezzing object to the rezzed object...


Hope that helps
RichardEric Collins
Registered User
Join date: 29 Aug 2007
Posts: 16
08-31-2007 00:50
Your not setting the rotation correctly. The rotation is a quaternion, they use these as its just a quad word over the net where as a matrix is four times as big. But quaternions are a little hard to get your head round if you are not familiar with coding in 3D space. I've been coding for 15 years, mainly in games but recently in commercial 3d apps (more money in it) but quaternions still make my head hurt. ;) They are also great for 3D animation as its simple vector maths to rotate from one to another over time compared to matrices where it just can't be done.

( I wish they had used the keyword quaternion instead of rotation, would have prevented some confusion )

Best you google more about them if you feel it will help, I'm not a maths guru.

But here are three helpers I use to set up a rotation. They take angles. To create a rotation around more than one axis just mul the results together, remembering the order is important (anther thing that makes my head hurt)

Look like you'll only interested in the z part so for your code do...

llRezObject("Object1", llGetPos(), ZERO_VECTOR,SetRotationZ(68.0), 42);

Not sure if passing llGetPos is correct, someone else may need to confirm that bit as I've not moved into rez'ing stuff yet.

rotation SetRotationX(float pAngle)
{
pAngle *= DEG_TO_RAD;
pAngle *= 0.5f;
return <llSin(pAngle),0,0,llCos(pAngle)>;
}

rotation SetRotationY(float pAngle)
{
pAngle *= DEG_TO_RAD;
pAngle *= 0.5f;
return <0,llSin(pAngle),0,llCos(pAngle)>;
}


rotation SetRotationZ(float pAngle)
{
pAngle *= DEG_TO_RAD;
pAngle *= 0.5f;
return <0,0,llSin(pAngle),llCos(pAngle)>;
}
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
08-31-2007 00:55
heh Richard.. looks like you're going about it the long way.. look up llEular2Rot and llRot2Eular in the wiki... :)
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
08-31-2007 01:26
If you still have trouble, try this:

1. Rez the object and rotate it the way you want it
2. Paste this script inside:

From: someone
default
{
state_entry()
{
llOwnerSay((string)llGetRot());
}
}


It'll give you the rotation so you can copy and use in your llRezObject call like this:

From: someone
llRezObject("Object1", llGetPos() + <0.0, 0.0, 0.0>, ZERO_VECTOR, <REPLACE, THIS, BIT, HERE>, 42);
_____________________