Jump to content

TouchDetect Rotation help needed


Tristus Patton
 Share

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

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

Recommended Posts

Hello,

I was trying to figure out how to when you click in an area on a HUD to rotate a prim. What I mean is, the HUD with have the range you can rotate, and depending on where you click in that range, it will rotate on the Y axis to that rotation.

The range is as high as 45.000, and as low as 315.000, for a child prim.and I only want that one prim to rotate.

I know it will take a long time, but I was thinking I could script every degree of rotation into the HUD to do this. But I was hoping for something simple, and Im unsure of where to start. If I did have to script every poition I think I'd need to be able to find out how to tell if someone clicked within a triangle, but I dont know how to do that either.


Thanks for any help you can give.

Link to comment
Share on other sites

//Make yourself a HUD from a cube prim X=0.1, Y=0.1, Z=0.3, Taper Y = 1.0//Drop this script into it.rotation gRot;default{    state_entry()    {        llSetLocalRot(ZERO_ROTATION);    }        touch(integer num)    {        vector where = llDetectedTouchST(0);        if (where.y > 0.5)  //User touched top end of HUD        {            gRot = llEuler2Rot(<1.0*DEG_TO_RAD,0.0,0.0>)*llGetLocalRot();        }        else    //User touched bottom end of HUD        {            gRot = llEuler2Rot(<-1.0*DEG_TO_RAD,0.0,0.0>)*llGetLocalRot();        }                    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROT_LOCAL, gRot]); //Spin the HUD    }        touch_end(integer num)  //User let go of the HUD    {        vector EndRot = llRot2Euler(gRot);        float Angle = RAD_TO_DEG * EndRot.x;        if( Angle < 0.0)        {            Angle += 360.0;        }        llSay(0,(string)Angle);   //Report end rotation around X in degrees    }}

Kind of a fun little challenge.  :smileywink:

ETA:   BTW, if you really want to move one degree per mouse click, just change the touch event into a touch_start event.  And if it bothers you that the reported angle is something like 15.999998, convert it to an integer before reporting it.

  • Like 1
Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...