Jump to content

Hud for incremental rotation


StratusFears
 Share

You are about to reply to a thread that has been inactive for 2240 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have been trying to make this simple hud to allow for the rotation of attached objects on an avatar, and it was working fantastically on a object rezzed in world, but the moment i attached it to myslef the prim being affected rather then doing its incremental 5 degree rotation would just snap between two points, a lower point when i hit "down" and a higher point when i hit "up"

I dont know what to do anymore and am really hoping someone can help me here. I will show the current script, all of the rotation parts were made from examples off the wiki which has been somewhat unhelpful with this. Bare in mind when seeing this that i know how to make listen commands better then this, and that this is just for simplicity while developing the hud, it will be on hidden channels with better commands when its done.

rotation rot_xyzq;
rotation rot_xyzq2;
rotation Default;
integer listenHandle;
default
{
state_entry()
{
listenHandle = llListen(0, "", "", "");
vector xyz_angles = <0,5.0,0>; // This is to define a 1 degree change
vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
vector xyz_angles2 = <0,-5.0,0>; // This is to define a 1 degree change
vector angles_in_radians2 = xyz_angles2*DEG_TO_RAD; // Change to Radians
rot_xyzq2 = llEuler2Rot(angles_in_radians2); // Change to a Rotation
}

touch_start(integer s)
{
llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...
}
listen(integer channel, string name, key id, string message)
{
if(message == "CounterClock")
{
llSetRot(llGetRot()*rot_xyzq2); //Do the Rotation...
}
if(message == "Clock")
{
llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...
}
if(message == "Def")
{
Default = llGetRot();
}
if(message == "Reset")
{
llSetRot(Default);
}
if(message == "Unhide")
{
llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
}
if(message == "Hide")
{
llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
}
}
}

 

Any help is greatly appreciated! 

Link to comment
Share on other sites

The main problem is that llGetRot(), in the context of a worn object, refers to the global rotation of the avatar.  That's not what you want.  You want llGetLocal Rot, which is relative to the attachment point.  See http://wiki.secondlife.com/wiki/Rotation#Single_or_Root_Prims_vs_Linked_Prims_vs_Attachments .  The same is true for llSetRot.  You are also doing your rotation caculations in the wrong order, although in this case that may still yield a reasonable answer.  You should be writing

llSetLocalRot(rot_xyzq * llGetLocalRot());

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2240 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...