Change font size
It is currently Wed Aug 21, 2019 12:11 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Vehicle Physics Question VEHICLE_ANGULAR_MOTOR_DIRECTION
PostPosted: Wed Jul 03, 2013 1:42 pm 

Joined: Tue Jul 02, 2013 11:56 am
Posts: 3
Below is a test script I have been using in order to test the various parameter used in the angular motor (ODE).

Much to my surprise, I find that in the grid I am using the angular thrust is being applied based on the world coordinates.

This means that when I face east, the vehicle (a single 5m x 5m x 1m prim) will bank as I expect.
If I face west, then left will bank right, right will bank left, back will tip forward, forward will tip back. Basically backwards.

Facing north and south are even more fun. left will cause a tip, up will cause a bank, etc.

Was I correct in expecting the angular motor to be based on the prim's local coordinate system?

My only previous vehicle experience is with SL. So perhaps my expectations are incorrect.

Also I was curious if this odd behavior was occurring in other grids. The one I am using is Kitely.

{L_CODE}:
vector avPos = <0.0,0.0,1.5>; // position of avatar in plane, relative to parent
vector avRotDeg = <0,0,0>;

integer sitting = FALSE;
key pioletID = NULL_KEY;

float angularX = 5;
float angularZ = 20;

setVehicleParams() {

    llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, ZERO_VECTOR );
    llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <3.0, 3.0, 3.0> );   // slider
    llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 3);
    llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, ZERO_VECTOR);
    return;
}

exitProtocol() {
    llReleaseControls();
    llUnSit(pioletID);
    pioletID = NULL_KEY;
    sitting = FALSE;
    llSetTimerEvent(0);
    llSetStatus(STATUS_PHYSICS, FALSE);
    llResetScript();
}

default
{

    on_rez(integer num)
    {
        llResetScript();
    }

    state_entry()
    {
        rotation avRot = llEuler2Rot(avRotDeg * DEG_TO_RAD);
        llSitTarget(avPos, avRot);
        llSetSitText("Fly");
        llSetCameraEyeOffset(<-7, 0, 4>); // Position of camera, relative to parent.
        llSetCameraAtOffset(<0, 0, 1.9>);   // Point to look at, relative to parent.
        llSetVehicleType(VEHICLE_TYPE_AIRPLANE);

    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) {
            llResetScript();
        } else  if(change & CHANGED_LINK) {
            pioletID = llAvatarOnSitTarget();
            if((pioletID == NULL_KEY) && (sitting)) {
                exitProtocol();
                llOwnerSay("Was sitting, now stand.");
                exitProtocol();

            } else if((pioletID == NULL_KEY)) {
                llReleaseControls();
                llOwnerSay("Null sitter. Was not sitting.");
                exitProtocol();

            } else {
                llOwnerSay("Piolet now sitting.");
                sitting = TRUE;
                setVehicleParams();
                llRequestPermissions(pioletID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION | PERMISSION_CONTROL_CAMERA);
                // llSetTimerEvent(timerFreq);

            }

        }
    }

    //CHECK PERMISSIONS AND TAKE CONTROLS
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TAKE_CONTROLS) {
            llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
            llSetStatus(STATUS_PHYSICS, TRUE);
        }
        if (perm & PERMISSION_CONTROL_CAMERA) {
            llSetCameraEyeOffset(<-10, 0, 2.5>); // Position of camera, relative to parent.
            llSetCameraAtOffset(<0, 0, 1.0>);   // Point to look at, relative to parent.
        }
    }


     //FLIGHT CONTROLS
    control(key id, integer level, integer edge)
    {

        //llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_OFFSET, ZERO_VECTOR);
        integer start = level & edge;
        integer end = ~level & edge;
        integer held = level & ~edge;


        if (held) {
            return;
        }

        vector angular_motor;
       
        if (start & CONTROL_FWD) {
            angular_motor.y = 14.0;
        } else if (end & CONTROL_FWD) {
            angular_motor.y = 0;
        } else if (start & CONTROL_BACK) {
            angular_motor.y = -14.0;
        } else if (end & CONTROL_BACK) {
            angular_motor.y = 0;
        } else {
            angular_motor.y = 0;
        }
       
        // PITCH CONTROL ----------------
        if ( start & CONTROL_ROT_RIGHT ) {
            angular_motor.x = angularX;
        } else if ( end & CONTROL_ROT_RIGHT ) {
            angular_motor.x = 0;
        } else if ( start & CONTROL_ROT_LEFT ) {
            angular_motor.x = -1*angularX;
        } else if ( end & CONTROL_ROT_LEFT ) {
            angular_motor.x = 0;
        } else {
        }
        llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <angular_motor.x, angular_motor.y, 0.0> );
    }
   
    touch_start(integer tn){
        if ( llDetectedKey(0) == llAvatarOnSitTarget() ) {
            exitProtocol();
        }
    }
   

}


Top
 Profile  
 
 Post subject: Re: Vehicle Physics Question VEHICLE_ANGULAR_MOTOR_DIRECTION
PostPosted: Thu Jul 04, 2013 5:04 pm 

Joined: Tue Jul 02, 2013 11:56 am
Posts: 3
Found an open issue related to this topic.

[url]http://opensimulator.org/mantis/view.php?id=6039
[/url]

Turns out this is a known issue.

Wish it had a higher priority.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net