[Opensim-users] OpenSim Crashes when running a small Vehicle Script
Thomas Seuring
Thomas at seuring.com
Mon Sep 21 22:31:23 UTC 2009
I've wrote a small, very easy Script to drive a Vehicle. But everytime I get
and like to drive, OpenSim crashes.
Any ideas?
Thanks
Tom
BELOW: Crash and Code:
The crash is:
Region (root) # Stacktrace:
at (wrapper managed-to-native) Ode.NET.d.JointSetLMotorAxis
(intptr,int,int,single,single,single) <0x00004>
at (wrapper managed-to-native) Ode.NET.d.JointSetLMotorAxis
(intptr,int,int,single,single,single) <0xffffffff>
at
OpenSim.Region.Physics.OdePlugin.ODEVehicleSettings.SetLinearMotorProperties
() <0x001e6>
at OpenSim.Region.Physics.OdePlugin.ODEVehicleSettings.LinearMotor
(single) <0x004aa>
at OpenSim.Region.Physics.OdePlugin.ODEVehicleSettings.Step (single)
<0x0009b>
at OpenSim.Region.Physics.OdePlugin.OdePrim.Move (single) <0x00b20>
at OpenSim.Region.Physics.OdePlugin.OdeScene.Simulate (single) <0x0155f>
at OpenSim.Region.Framework.Scenes.SceneGraph.UpdatePhysics (double)
<0x0003c>
at OpenSim.Region.Framework.Scenes.Scene.Update () <0x004d5>
at OpenSim.Region.Framework.Scenes.Scene.Heartbeat (object) <0x00018>
at (wrapper runtime-invoke) object.runtime_invoke_void__this___object
(object,intptr,intptr,intptr) <0xffffffff>
Abort trap
The Script is:
// set the vehicle parameters
setupVehicle()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetVehicleType(VEHICLE_TYPE_CAR);
// The vehicle will get up to full speed in 1 second
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
// The motor will become ineffective after 3 seconds.
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 3.0);
// Turn off angular and linear deflection
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.0);
// Set low linear friction, equal in all directions
llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 5000.0);
// Set very high angular friction, this vehicle does not
// like to turn
llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 0.1);
}
// stop this object from being a vehicle
noVehicle()
{
// Turn off physics and vehicle params
llSetVehicleType(VEHICLE_TYPE_NONE);
llSetStatus(STATUS_PHYSICS, FALSE);
}
// give this prim a wedge shape and set it to about avatar size
setupObject()
{
llSetPrimitiveParams([
PRIM_TYPE,
PRIM_TYPE_BOX,
PRIM_HOLE_DEFAULT,
<0.75, 1.0, 0.0>,
0.0,
<0.0, 0.0, 0.0>,
<1.0, 1.0, 0.0>,
<0.0, 0.0, 0.0>,
PRIM_SIZE,
<4.0, 1.5, 0.5>
]);
}
// default state, not a vehicle
default
{
state_entry()
{
noVehicle();
setupObject();
// Set the location avatars will sit
llSitTarget(<-1.0, 0.0, 0.5>, ZERO_ROTATION);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
// someone is sitting on the object; request permission
// to take controls
llRequestPermissions(
llAvatarOnSitTarget(),
PERMISSION_TAKE_CONTROLS);
}
}
}
run_time_permissions(integer perm)
{
// the run time permissions have changed; if script can
// take controls, do that and go to the vehicle state
if (perm & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(
CONTROL_FWD | CONTROL_BACK |
CONTROL_LEFT | CONTROL_RIGHT |
CONTROL_ROT_LEFT |CONTROL_ROT_RIGHT,
TRUE, FALSE);
state vehicle;
}
}
}
state vehicle
{
state_entry()
{
setupVehicle();
}
changed(integer change)
{
// If the avatar sitting on this object gets up, stop
// being a vehicle
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == NULL_KEY)
{
// no one is sitting on the object; stop
// being a vehicle
llReleaseControls();
state default;
}
}
}
control(key from, integer level, integer edge)
{
integer pressed = (level & edge);
vector velocity = ZERO_VECTOR;
float speed = 15.0;
if (pressed & CONTROL_FWD)
{
velocity = <1.0, 0.0, 0.0>;
}
else if (pressed & CONTROL_BACK)
{
velocity = <-1.0, 0.0, 0.0>;
}
else if (pressed & CONTROL_LEFT ||
pressed & CONTROL_ROT_LEFT)
{
velocity = <0.0, 1.0, 0.0>;
}
else if (pressed & CONTROL_RIGHT ||
pressed & CONTROL_ROT_RIGHT)
{
velocity = <0.0, -1.0, 0.0>;
}
if (velocity != ZERO_VECTOR)
{
velocity = velocity * speed;
llSetVehicleVectorParam(
VEHICLE_LINEAR_MOTOR_DIRECTION,
velocity);
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20090922/9b2c0099/attachment.html>
More information about the Opensim-users
mailing list