Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Camera decoupling

Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-22-2004 09:39
Has anyone got it to work?

I don't have my code to copy/paste here, but basically I set the flag, and the mouselook steer flag, mouselook steer works, but the camera (in mouselook) still moves with the rotation.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
06-22-2004 11:53
Here is what I used for mouselook steering of my ultralight in preview:

// mouselook banking
llRemoveVehicleFlags(VEHICLE_FLAG_MOUSELOOK_STEER|VEHICLE_FLAG_CAMERA_DECOUPLED);
llSetVehicleFlags(VEHICLE_FLAG_MOUSELOOK_BANK);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <10, 10, 0>;);


If you set VEHICLE_FLAG_CAMERA_DECOUPLED instead of removing it like I have done above, then the steering should work as it did on the blue plasma bike from preview.
_____________________
Apotheus Silverman
Shop SL on the web - SLExchange.com

Visit Abbotts Aerodrome for gobs of flying fun.
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-22-2004 12:06
Right, I want the camera decoupled, and hence I am setting the flag, but the camera remains coupled.

Has anyone successfully decoupled? Is there some secret magic to it?

[Edit: this is a VEHICLE_TYPE_BALLOON, and mouslook steering works, it's just that the camera turns too].

[Edit2: Is the preview-bike available in world anywhere? I looked around the vehicle sims but couldn't find it. Or does anyone have the script they can post?]
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
06-28-2004 13:00
Wednesday, sounds like a bug, but I need more information on how you are tickling it. Either post your non-working script here in the forums, or drop a readable copy on my SL profile and I'll try to figure out what is going on.
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
06-28-2004 15:12
Here's the blue plasma bike from the preview...


--------

// example mouselook hoverbike
//
// Uses "mouselook" to steer, which is new for SL 1.4.

integer gUseMouseLookSteer = TRUE;

float gMaxTurnSpeed = 12;
float gMaxWheelieSpeed = 5;
float gMaxFwdSpeed = 30;
float gMaxBackSpeed = -10;
float gAngularRamp = 0.17;
float gLinearRamp = 0.2;

// These are true globals whose values are "accumulated" over
// multiple control() callbacks.
float gBank = 0.0;
vector gLinearMotor = <0, 0, 0>;
vector gAngularMotor = <0, 0, 0>;

default
{
state_entry()
{
// init stuff that never changes
llSetSitText("Ride";);
llCollisionSound("", 0.0);
llSitTarget(<0.01, 0.05, 0.01>, ZERO_ROTATION);
llSetCameraEyeOffset(<-6.0, 0.0, 1.0>;);
llSetCameraAtOffset(<3.0, 0.0, 1.0>;);

// create the vehicle
llSetVehicleFlags(-1);
llSetVehicleType(VEHICLE_TYPE_CAR);
llRemoveVehicleFlags(VEHICLE_FLAG_LIMIT_MOTOR_UP);

llRemoveVehicleFlags(VEHICLE_FLAG_LIMIT_ROLL_ONLY);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.7);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.8);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.8);

llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.8);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.4);

if (gUseMouseLookSteer)
{
// non-bank mouselook
llRemoveVehicleFlags(VEHICLE_FLAG_MOUSELOOK_BANK);
llSetVehicleFlags(VEHICLE_FLAG_MOUSELOOK_STEER | VEHICLE_FLAG_CAMERA_DECOUPLED);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.5);
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 15, 10>;);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 100); // irrelevent for mouselook
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <100, 10, 5>;);
}
else
{
// mouselook banking
llRemoveVehicleFlags(VEHICLE_FLAG_MOUSELOOK_STEER);
llSetVehicleFlags(VEHICLE_FLAG_MOUSELOOK_BANK | VEHICLE_FLAG_CAMERA_DECOUPLED);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.5);
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <10, 10, 0>;);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 100); // irrelevent for mouselook
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <100, 10, 5>;);

llSetVehicleFloatParam(VEHICLE_BANKING_EFFICIENCY, 2.5);
llSetVehicleFloatParam(VEHICLE_BANKING_MIX, 0.7);
llSetVehicleFloatParam(VEHICLE_BANKING_TIMESCALE, 0.01);

}

llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10, 10, 10>;);

llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.1);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 1.5);

llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 4);
llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 0.5);
llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.5);
llSetVehicleFlags(VEHICLE_FLAG_HOVER_UP_ONLY);
}

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
if (agent != llGetOwner())
{
// owner has mounted
llSay(0, "You aren't the owner";);
llUnSit(agent);
llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
}
else
{
// not the owner ==> boot off
llSetStatus(STATUS_PHYSICS, TRUE);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);

// reset the global accumulators
gAngularMotor = <0, 0, 0>;
gLinearMotor = <0, 0, 0>;
gBank = 0.0;
}
}
else
{
// dismount
llSetStatus(STATUS_PHYSICS, FALSE);
llReleaseControls();
llStopAnimation("motorcycle_sit";);
}
}

}

run_time_permissions(integer perm)
{
if (perm)
{
llStartAnimation("motorcycle_sit";);
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT
| CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP, TRUE, FALSE);
}
}

control(key id, integer level, integer edge)
{
// The idea here is to ramp up the motors when the keys are held down for a long
// time and to let the motors decay after they are let go. This allows fine-
// tuning of the motion of the vehicle by throttling the key controls.
//
// Note that this probably doesn't work well when the client FPS and/or the server
// FPS is lagging. So for best results you'll want to turn off as much visual
// effects as you can tolerate, and drive in the more empty areas.

// linear
integer key_control = FALSE;
if(level & CONTROL_FWD)
{
gLinearMotor.x = gLinearMotor.x + gLinearRamp * (gMaxFwdSpeed - gLinearMotor.x);
key_control = TRUE;
}
if(level & CONTROL_BACK)
{
gLinearMotor.x = gLinearMotor.x + gLinearRamp * (gMaxBackSpeed - gLinearMotor.x);
key_control = TRUE;
}
if (key_control)
{
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
key_control = FALSE;
}
else
{
if (gLinearMotor.x > 15 || gLinearMotor.x < -5)
{
// Automatically reduce the motor if keys are let up when moving fast.
gLinearMotor.x *= 0.8;
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
}
else
{
// reduce the linear motor accumulator for the next control() event
gLinearMotor.x *= 0.8;
}
}
}
}
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
06-29-2004 17:12
Wednesday, the problem with your vehicle is that you set the _ANGULAR_MOTOR to <PI/2, 0, 0>, which zeros any "pitch" (y-component) and "yaw" (z-component).

Under the _MOUSELOOK_ flags the "meaning" of the angular motor changes to represent the "limits of the angular motor's components" rather than the "direction of the angular motor". The direction is determined by your mouselook, the magnitude is scaled by the the _ANGULAR_MOTOR parameter.

Since you zeroed out the "pitch" and "yaw" components, all you had left was "roll". Under _MOUSELOOK_STEER "roll" has no meaning since you can't rotate about your "forward axis".

Under _MOUSELOOK_BANK, "roll" does have meaning, but "yaw" does not. However, since you didn't get results under MOUSELOOK_BANK, I suspect that you did not enable the banking parameters. That is, if your _BANKING_EFFICIENCY is zero, you'll never get any "roll" effect. Also, if your _BANKING_TIMESCALE is very large it is possible for banking to be so weak as to be unoticable. Finally, be sure to set the _BANKING_MIX near 0.0 (instead of near 1.0) so that you are able to bank even when you are not moving very fast.

I hope that helps.
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
07-02-2004 19:52
Yeah, Wednesday you're right. I took another look at your vehicle and there IS a bug in the decoupled mouselook. I verified what you said in your instant message yesterday: for some reason the decoupled flag is not getting set or used, but a region crossing event will reset it.

Sorry, you can safely ignore what I posted above. That was not the cause of your problem. The second time around I looked more carefully and you had the banking all set up correctly with the right angular motor setting.

Thanks for the copy of your vehicle. I'll use it to find the bug.
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
07-03-2004 13:01
I win!

Just kidding, thanks for the response Andrew.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Johnny Prototype
Junior Member
Join date: 10 Aug 2004
Posts: 9
08-17-2004 16:53
So does that mean that mouselook steering is fubar atm ?
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
08-18-2004 09:53
It just means the camera does not de-couple until the vehicle crosses a sim line. After that it works fine. If you pull it back in to your inventory and pull it out again, it continues to be ok.

If you re-compile the script, create a copy or give a copy to someone else, it become re-fubared.
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!