Ralph Honi Posted November 8, 2011 Share Posted November 8, 2011 I have a spot light consisting of 3 prims that I wish to rotate via a HUD. The Spot light will be worn as an attachment to the seated avatar in a vehicle. Via the HUD, the object rotates around the root prim just fine in testing on the ground ... however as soon as I attach to the avatar I get only one pulse in a particular direction until I change direction then it pulses that way but only once ... and a radical initial rotation upon first rotation command. I have done some reading trying to figure this out ... Do I need to convert to a local x,y,z ? I read on it but am not sure how to accomplish this. And if so ... is it at each rotation command event? Obviously the vehicle will be moving and turning.Hopefully I described this adequately ... I'm not the greatest scripter but here is my attempt. //Spot Rotations Scriptrotation rot_xyzq;Left(){ vector xyz_angles = <0.0, 0.0, 3.0>; // This is to define a 3 degree change vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...}Right(){ vector xyz_angles = <0.0, 0.0, -3.0>; // This is to define a 3 degree change vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation llSetRot(llGetRot()*rot_xyzq); //Do the Rotation... }default{ state_entry() { llListen(2525,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "left") Left(); if (message == "right") Right(); }} Link to comment Share on other sites More sharing options...
Kayaker Magic Posted November 9, 2011 Share Posted November 9, 2011 Rotations are notoriously confusing. And THEN you ad SL into the mix! SL has at least 4 different ways that rotations work: Rotating a root prim is relative to region co-ordinates. Rotating a child prim is relative to the root prim's local orientation Rotating a root prim attached to an avatar is relative to the attachment point and the avatars rotation. There is a bug in one of the LL library routines, they multiplied instead of dividing a rotation, so you have to divide twice to get around it. Animations rotate the avatar in the viewer without the server ever being able to know the region location of the prim. Rotating a child prim attached to a root prim attached to an avatar is ... I forget, but I got it working once. I built a big table of all the different effects rotation has in different situations. I'll look that up when I get home and get back to you then. (Very late tonight PDT). Link to comment Share on other sites More sharing options...
Ralph Honi Posted November 9, 2011 Author Share Posted November 9, 2011 I would appreciate it very much Kayaker Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 9, 2011 Share Posted November 9, 2011 The table at http://wiki.secondlife.com/wiki/Rotation is about as comprehensive as you're going to get. That whole article is helpful. See also http://wiki.secondlife.com/wiki/User:Void_Singer/Rotations Link to comment Share on other sites More sharing options...
Kayaker Magic Posted November 12, 2011 Share Posted November 12, 2011 When I found my table, it was not as complete as the one Rolig pointed out in the wikil I thought I had filled in more of the boxes. Here is a script I wrote that points an attached 'gun' at the nearest avatar. You can put it in a cylendar, attach the cylendar to your pelvis, and offset it (with the build dialog) so that it is to your side and above you. It will rotate with you as you walk around, of cource since it is attached. The script will make it turn to point the local z axis at the nearest avatar. Looking at the code now, I could have commened it better. Look up llGetRootPosition and llGetLocalPosition in that table Rolig referenced to find out what each of them returns in the root prim of an attached object. The -PI_BY_TWO is to get the local z axis of a cylendar to point foreward. llAxis2Rot is my favorite of all the llLibrary routines! default{ state_entry() { llSensorRepeat("","",AGENT,20.0,PI_BY_TWO,1.0); llSetText("",<0,0,0>,0); } no_sensor() { rotation rot=llEuler2Rot(<0,-PI_BY_TWO,0>); llSetRot(rot); } sensor(integer num) { vector dpos = (llDetectedPos(0)-llGetRootPosition())/llGetRootRotation(); dpos -= llGetLocalPos()-<0,0,0.50>; //convert the vector into a rotation and point that way vector fwd=llVecNorm(dpos); //vector pointing my new direction vector lft=llVecNorm(<0,0,1>%fwd); //left rotation rot=llEuler2Rot(<0,-PI_BY_TWO,0>)*llAxes2Rot(fwd,lft,fwd%lft); //rotate to face that way head up llSetRot(rot); }} Link to comment Share on other sites More sharing options...
Recommended Posts
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