Jump to content

Rotation in the world


Daniells Brandi
 Share

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

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

Recommended Posts

if by front we mean E to mean facing East inworld, we rotate on the Y axis

the simplest way to get started with rotations is to work in degrees using llEuler2Rot() to do the conversion

http://wiki.secondlife.com/wiki/LlEuler2Rot

going left to right in the Up View drawing then:

cube1: llSetRot(llEuler2Rot(<0.0, 315.0, 0.0> * DEG_TO_RAD));
cube2: llSetRot(llEuler2Rot(<0.0, 90.0, 0.0> * DEG_TO_RAD));
cube3: llSetRot(llEuler2Rot(<0.0, 270.0, 0.0> * DEG_TO_RAD));

Edited by Mollymews
edit forgot the * DEG_TO_RAD
Link to comment
Share on other sites

yes, but I would like for example to rotate 10 degrees up, but without changing the direction of the prim.

 

        ///////////////////////////////////////////////////////////////////////// 
        vector vOffset2 = <1,0,0> * llGetRot();
        vector noY = <llVecMag(<vOffset2.x, vOffset2.y, 0.0>), 0.0, vOffset2.z>;
        integer pitch = llRound(llAtan2(noY.z, noY.x) * RAD_TO_DEG);   
        /////////////////////////////////////////////////////////////////////////

 

would be the reverse process of this code.
  This code gives me the pitch, but I want the object to have a pitch set by me

Edited by Daniells Brandi
Link to comment
Share on other sites

to rotate an object by some degree around its current orientation then some code to explain:

default
{
    touch_start(integer total_number)
    {
        vector rotate_by = <0.0, 10.0, 0.0>;
        
        rotation our_current_rotation = llGetRot();
        
        rotation rotate_to = llEuler2Rot(rotate_by * DEG_TO_RAD) * our_current_rotation; 
        
        llSetRot(rotate_to); 
        
        // to go in the other direction then set the vector to minus
        // example: rotate_by = <0.0, -10.0, 0.0>;
    }
}

 

Link to comment
Share on other sites

 mollymeus,  your code is perfect, I did the test and saw that it does not work on physical objects.

  It would have some code like this for physical object.
  I need a seaplane to level (align) at  height determined by user.

 

I was working with  'VEHICLE_ANGULAR_MOTOR_DIRECTION'  but the plane keeps going up or down even when the value set to 0,

 it makes the plane oscillate all the time, I  need more precision I'm out of ideas.

Link to comment
Share on other sites

ah! vehicles are a whole other thing

as you probably realised the motors decay, and when left the plane will fall out of the sky. Apply power to the motors incorrectly then the plane will oscillate like you are seeing

generally what we want to do is:  Given the current pitch of the plane, and  given some target pitch, then apply power to the motor that is some multiple of the difference

power = ( target_pitch - current_pitch )  * ((float)something * (the mass and center of mass of the plane))

the question being what is (float)something ?

usually we try different values for  (float)something' until we get it about right

 

 

 

 

Link to comment
Share on other sites

Or you do the ugly cheat ...... you make the vehicle non-physical for an instant, rotate it a bit, and make it physical again. If you're lucky, that instant is hardly perceptible.  Probably more acceptable if you are scripting a drone than if you are making something to ride in.

Link to comment
Share on other sites

Daniells, if you haven't already then a good place to start to learn about all this, is with Andrew Linden's flight script with mods by Cubey Terra. Link here:

https://www.outworldz.com/cgi/freescripts.plx?ID=35

in the control event, it shows what the (float)something can be when the pilot presses a keyboard control and how this is translated to power the motors

most people who get into piloted flying vehicles start by playing with this script. As it shows all the basic principles of SL flight in a complete working example

once we get our heads around this then we can go on to make our own types of planes which can exhibit different behaviours depending on type of plane. A fighter jet for example different from a passenger airliner, different again from a bush hopper, in terms of power/strength applied to the motors

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1599 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...