Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help – Basic Rotation Example – Learning

Dragon Muir
Registered User
Join date: 25 Jun 2005
Posts: 60
01-23-2009 16:19
Below is two simple scripts, but 3D rotation and geometry is not something I have any real experience with. I had some in high school, but cannot recall any of it.

Let’s say I want a object to be set at a current rotation but when I turn a second prim and click it, it will turn the same rotation but not change the beginning rotation it begins at.
The two basic scripts below is an attempt try to understand rotation, but I am unsure where to start. If someone could give the formula needed to make this work I can play with the script and learn from it.

The part that needs to be changed is “NewRot = (vector)message;”. I need to get the objects llGetRot and somehow apply the rotation to it.

Script that listens to turn according to the second prim
CODE


vector NewRot;

default
{
state_entry()
{
llListen(222,"","","");
}


listen(integer channel, string name, key id, string message)
{


NewRot = (vector)message;
llSetRot(llEuler2Rot(NewRot));

}

}




Script that tells second prim it's roation.
CODE


default
{
state_entry()
{

}
touch_start(integer total_number)
{
llSay(222, (string)llGetRot());
}

}




PS: I think I am using
CODE
 
wrong. It has been a long time since I posted. There is a way to make scripts appear in script form I think?
Klug Kuhn
Registered User
Join date: 7 Sep 2007
Posts: 126
01-23-2009 16:56
mm, i think you could just tell the listening prim the rotation directly, doesn't really need to get the vector and do the conversion. e.g.

NewRot = (rotation)message;
llSetRot(NewRot);

I haven't done an inworld test, but should be ok.

Also if the listening prim is not a root prim, you may need to consider using llSetLocalRot().

Using
CODE
 and 
should align the script part nicely. :)
Dragon Muir
Registered User
Join date: 25 Jun 2005
Posts: 60
01-23-2009 18:17
Not quite what I mean. What I want to do is move the listening object however I like. It saves it current rotation and then applies the rotation of the second object to it. So I move the second object, save its current rotation, turn the first object and click it, and then the second object will rotate as much as the first object in its current rotation.
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
01-23-2009 19:24
You may want to try llRotBetween. It should allow you to calculate the rotation difference of the first object and the second object, then just add it to the second object to rotate it accordingly.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
Dear Dragon...
01-24-2009 08:57
Don't worry about High School. They didn't really cover this stuff.

There are lots of resouces about rotations in these Forums and in the various SL wikis. My only advice is to search them (Google works) and read them and do your best. Feel free to ask questions here, too.

Eventually you will be answering questions instead of asking them 8-)

lee

(Or just giving pedantic advice, like I do 8-)
_____________________
So many monkeys, so little Shakespeare.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-24-2009 20:21
if you're matching rotations, just reporting the current rotation amount to the other object and applying it should work fine (though it's a little trickier if they're linked and one is the root) if you're matching just rotation amounts (meaning the amount of change) it's usually easier to calculate the change amount for the first, apply it and then send the change amount to the other to be applied.

these pages will probably help



PS PHP tags are right, if you aren't seeing them put your code in blocks check the link in my signature for a way to enable their viewing (along with all the other bbcode tags) in Firefox
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -