本文整理汇总了C#中Aurora.Physics.AuroraOpenDynamicsEngine.AuroraODEPhysicsScene类的典型用法代码示例。如果您正苦于以下问题:C# AuroraODEPhysicsScene类的具体用法?C# AuroraODEPhysicsScene怎么用?C# AuroraODEPhysicsScene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuroraODEPhysicsScene类属于Aurora.Physics.AuroraOpenDynamicsEngine命名空间,在下文中一共展示了AuroraODEPhysicsScene类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetScene
public PhysicsScene GetScene(String sceneIdentifier)
{
if (_mScene == null)
{
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
// http://opensimulator.org/mantis/view.php?id=2750).
d.InitODE();
_mScene = new AuroraODEPhysicsScene(ode, sceneIdentifier);
}
return _mScene;
}
开发者ID:NickyPerian,项目名称:Aurora,代码行数:12,代码来源:AODEPlugin.cs
示例2: GetScene
public PhysicsScene GetScene(String sceneIdentifier)
{
if (_mScene == null)
{
if (!m_initialized) //Only initialize ode once!
{
// Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to
// http://opensimulator.org/mantis/view.php?id=2750).
d.SetODEFile();
d.InitODE();
m_initialized = true;
}
_mScene = new AuroraODEPhysicsScene(sceneIdentifier);
}
return _mScene;
}
开发者ID:Gnu32,项目名称:Silverfin,代码行数:17,代码来源:AODEPlugin.cs
示例3: DoAChange
public bool DoAChange(AuroraODEPhysicsScene.changes what, object arg)
{
if (m_frozen && what != AuroraODEPhysicsScene.changes.Add && what != AuroraODEPhysicsScene.changes.Remove)
return false;
if (prim_geom == IntPtr.Zero && what != AuroraODEPhysicsScene.changes.Add &&
what != AuroraODEPhysicsScene.changes.Remove)
{
m_frozen = true;
return false;
}
// nasty switch
switch (what)
{
case AuroraODEPhysicsScene.changes.Add:
changeadd();
break;
case AuroraODEPhysicsScene.changes.Remove:
if (_parent != null)
{
AuroraODEPrim parent = (AuroraODEPrim)_parent;
parent.ChildRemove(this);
}
else
ChildRemove(this);
RemoveGeom();
m_targetSpace = IntPtr.Zero;
return true;
case AuroraODEPhysicsScene.changes.Link:
AuroraODEPrim tmp = (AuroraODEPrim)arg;
changelink(tmp);
break;
case AuroraODEPhysicsScene.changes.DeLink:
changelink(null);
break;
case AuroraODEPhysicsScene.changes.Position:
changePosition((Vector3)arg);
break;
case AuroraODEPhysicsScene.changes.Orientation:
changeOrientation((Quaternion)arg);
break;
case AuroraODEPhysicsScene.changes.PosOffset:
donullchange();
break;
case AuroraODEPhysicsScene.changes.OriOffset:
donullchange();
break;
case AuroraODEPhysicsScene.changes.Velocity:
changevelocity(arg);
break;
case AuroraODEPhysicsScene.changes.Acceleration:
changeacceleration(arg);
break;
case AuroraODEPhysicsScene.changes.AngVelocity:
changeangvelocity(arg);
break;
case AuroraODEPhysicsScene.changes.Force:
changeforce(arg);
break;
case AuroraODEPhysicsScene.changes.Torque:
changeSetTorque(arg);
break;
case AuroraODEPhysicsScene.changes.AddForce:
changeAddForce(arg);
break;
case AuroraODEPhysicsScene.changes.AddAngForce:
changeAddAngularForce(arg);
break;
case AuroraODEPhysicsScene.changes.AngLock:
changeAngularLock(arg);
break;
case AuroraODEPhysicsScene.changes.Size:
changesize(arg);
break;
case AuroraODEPhysicsScene.changes.Shape:
changeshape(arg);
break;
case AuroraODEPhysicsScene.changes.CollidesWater:
changefloatonwater(arg);
break;
case AuroraODEPhysicsScene.changes.VolumeDtc:
//.........这里部分代码省略.........
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:101,代码来源:AODEPrim.cs
示例4: AuroraODEPrim
public AuroraODEPrim(String primName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, float Density)
{
m_vehicle = new AuroraODEDynamics();
//gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
ode = dode;
if (!pos.IsFinite())
{
pos = new Vector3((parent_scene.Region.RegionSizeX * 0.5f), (parent_scene.Region.RegionSizeY * 0.5f),
parent_scene.GetTerrainHeightAtXY((parent_scene.Region.RegionSizeX * 0.5f), (parent_scene.Region.RegionSizeY * 0.5f)));
m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
}
_position = pos;
fakepos = false;
PID_D = parent_scene.bodyPIDD;
PID_G = parent_scene.bodyPIDG;
// correct for changed timestep
PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50
PID_G /= (parent_scene.ODE_STEPSIZE * 50f);
m_density = Density / 100;
// m_tensor = parent_scene.bodyMotorJointMaxforceTensor;
body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
prim_geom = IntPtr.Zero;
prev_geom = IntPtr.Zero;
if (!size.IsFinite())
{
size = new Vector3(0.5f, 0.5f, 0.5f);
m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
}
if (size.X <= 0) size.X = 0.01f;
if (size.Y <= 0) size.Y = 0.01f;
if (size.Z <= 0) size.Z = 0.01f;
_size = size;
if (!QuaternionIsFinite(rotation))
{
rotation = Quaternion.Identity;
m_log.Warn("[PHYSICS]: Got nonFinite Object create Rotation");
}
_orientation = rotation;
fakeori = false;
_mesh = mesh;
_pbs = pbs;
_parent_scene = parent_scene;
m_targetSpace = (IntPtr)0;
if (pos.Z < 0)
m_isphysical = false;
else
{
m_isphysical = pisPhysical;
// If we're physical, we need to be in the master space for now.
// linksets *should* be in a space together.. but are not currently
if (m_isphysical)
m_targetSpace = _parent_scene.space;
}
m_primName = primName;
m_forceacc = Vector3.Zero;
m_angularforceacc = Vector3.Zero;
m_UpdateTimecntr = 0;
m_UpdateFPScntr = 2.5f * parent_scene.StepTime; // this parameter needs retunning and possible came from ini file
if (m_UpdateTimecntr > .1f) // try to keep it under 100ms
m_UpdateTimecntr = .1f;
AddChange(changes.Add, null);
}
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:79,代码来源:AODEPrim.cs
示例5: AuroraODERayCastRequestManager
public AuroraODERayCastRequestManager(AuroraODEPhysicsScene pScene)
{
m_scene = pScene;
nearCallback = near;
}
开发者ID:BillyWarrhol,项目名称:Aurora-Sim,代码行数:5,代码来源:AODERayCastRequestManager.cs
示例6: AuroraODEPrim
public AuroraODEPrim(string name, byte physicsType, PrimitiveBaseShape shape, Vector3 position, Vector3 size, Quaternion rotation,
int material, float friction, float restitution, float gravityMultiplier, float density, AuroraODEPhysicsScene parent_scene)
{
m_vehicle = new AuroraODEDynamics();
// correct for changed timestep
PID_D /= (parent_scene.ODE_STEPSIZE*50f); // original ode fps of 50
PID_G /= (parent_scene.ODE_STEPSIZE*50f);
body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
prim_geom = IntPtr.Zero;
_name = name;
PhysicsShapeType = physicsType;
_size = size;
_position = position;
fakepos = 0;
_orientation = rotation;
fakeori = 0;
_pbs = shape;
_parent_scene = parent_scene;
m_targetSpace = IntPtr.Zero;
/*
m_isphysical = pisPhysical;
if (m_isphysical)
m_targetSpace = _parent_scene.space;
*/
m_isphysical = false;
m_forceacc = Vector3.Zero;
m_angularforceacc = Vector3.Zero;
hasOOBoffsetFromMesh = false;
_triMeshData = IntPtr.Zero;
SetMaterial(material, friction, restitution, gravityMultiplier, density);
CalcPrimBodyData();
_parent_scene.AddSimulationChange(() => changeadd());
}
开发者ID:keverw,项目名称:Aurora-Sim,代码行数:44,代码来源:AODEPrim.cs
示例7: AuroraODECharacter
public AuroraODECharacter(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation, Vector3 size)
{
m_uuid = UUID.Random();
m_taintRotation = rotation;
// _orientation = rotation;
// _lastorientation = rotation;
if (pos.IsFinite())
{
if (pos.Z > 9999999f || pos.Z <-90f)
{
// pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
pos.Z = parent_scene.GetTerrainHeightAtXY(parent_scene.Region.RegionSizeX * 0.5f, parent_scene.Region.RegionSizeY * 0.5f) + 5.0f;
}
_position = pos;
m_taintPosition.X = pos.X;
m_taintPosition.Y = pos.Y;
m_taintPosition.Z = pos.Z;
}
else
{
_position.X = (float)parent_scene.Region.RegionSizeX * 0.5f;
_position.Y = (float)parent_scene.Region.RegionSizeY * 0.5f;
_position.Z = parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + 10f;
m_taintPosition.X = _position.X;
m_taintPosition.Y = _position.Y;
m_taintPosition.Z = _position.Z;
m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
}
_parent_scene = parent_scene;
CAPSULE_RADIUS = parent_scene.avCapRadius;
// m_StandUpRotation =
// new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
// 0.5f);
CAPSULE_LENGTH = (size.Z * 1.1f) - CAPSULE_RADIUS * 2.0f;
if ((m_collisionFlags & CollisionCategories.Land) == 0)
AvatarHalfsize = CAPSULE_LENGTH * 0.5f + CAPSULE_RADIUS;
else
AvatarHalfsize = CAPSULE_LENGTH * 0.5f + CAPSULE_RADIUS - 0.3f;
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
m_isPhysical = false; // current status: no ODE information exists
m_tainted_isPhysical = true; // new tainted status: need to create ODE information
_parent_scene.AddPhysicsActorTaint(this);
m_UpdateTimecntr = 0;
m_UpdateFPScntr = 2.5f * parent_scene.StepTime; // this parameter needs retunning and possible came from ini file
if (m_UpdateTimecntr > .1f) // try to keep it under 100ms
m_UpdateTimecntr = .1f;
m_name = avName;
}
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:61,代码来源:AODECharacter.cs
示例8: AuroraODECharacter
public AuroraODECharacter(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation,
Vector3 size)
{
m_uuid = UUID.Random();
_parent_scene = parent_scene;
m_taintRotation = rotation;
if (pos.IsFinite())
{
if (pos.Z > 9999999f || pos.Z < -90f)
{
pos.Z =
_parent_scene.GetTerrainHeightAtXY(_parent_scene.Region.RegionSizeX * 0.5f,
_parent_scene.Region.RegionSizeY * 0.5f) + 5.0f;
}
_position = pos;
}
else
{
_position.X = _parent_scene.Region.RegionSizeX * 0.5f;
_position.Y = _parent_scene.Region.RegionSizeY * 0.5f;
_position.Z = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + 10f;
MainConsole.Instance.Warn("[PHYSICS]: Got NaN Position on Character Create");
}
CAPSULE_RADIUS = _parent_scene.avCapRadius;
CAPSULE_LENGTH = (size.Z*1.1f) - CAPSULE_RADIUS*2.0f;
AvatarHalfsize = CAPSULE_LENGTH*0.5f + CAPSULE_RADIUS;
m_isPhysical = false; // current status: no ODE information exists
_parent_scene.AddSimulationChange(() => RebuildAvatar());
m_name = avName;
}
开发者ID:JAllard,项目名称:Aurora-Sim,代码行数:36,代码来源:AODECharacter.cs
示例9: MoveLinear
// end Step
private void MoveLinear(float pTimestep, AuroraODEPhysicsScene _pParentScene, AuroraODEPrim parent)
{
d.Vector3 dvel_now = d.BodyGetLinearVel(Body);
if (m_linearMotorDirection.LengthSquared() < 0.0001f)
{
m_linearMotorDirection = Vector3.Zero;
m_newVelocity = Vector3.Zero;
}
else
{
Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/m_linearMotorTimescale;
m_lastLinearVelocityVector += (addAmount);
m_linearMotorDirection *= (1.0f - 1.0f/m_linearMotorDecayTimescale);
// convert requested object velocity to world-referenced vector
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
m_newVelocity = m_lastLinearVelocityVector;
m_newVelocity *= rotq; // apply obj rotation to velocity vector
}
if (m_newVelocity.Z == 0 && (Type != Vehicle.TYPE_AIRPLANE && Type != Vehicle.TYPE_BALLOON))
m_newVelocity.Z += dvel_now.Z; // Preserve the accumulated falling velocity
d.Vector3 dpos = d.BodyGetPosition(Body);
Vector3 pos = new Vector3(dpos.X, dpos.Y, dpos.Z);
if (!(m_lastPositionVector.X == 0 &&
m_lastPositionVector.Y == 0 &&
m_lastPositionVector.Z == 0))
{
///Only do this if we have a last position
m_lastposChange.X = pos.X - m_lastPositionVector.X;
m_lastposChange.Y = pos.Y - m_lastPositionVector.Y;
m_lastposChange.Z = pos.Z - m_lastPositionVector.Z;
}
#region Blocking Change
double Zchange = Math.Abs(m_lastposChange.Z);
if (m_BlockingEndPoint != Vector3.Zero)
{
bool needUpdateBody = false;
if (pos.X >= (m_BlockingEndPoint.X - 1))
{
pos.X -= m_lastposChange.X + 1;
needUpdateBody = true;
}
if (pos.Y >= (m_BlockingEndPoint.Y - 1))
{
pos.Y -= m_lastposChange.Y + 1;
needUpdateBody = true;
}
if (pos.Z >= (m_BlockingEndPoint.Z - 1))
{
pos.Z -= m_lastposChange.Z + 1;
needUpdateBody = true;
}
if (pos.X <= 0)
{
pos.X += m_lastposChange.X + 1;
needUpdateBody = true;
}
if (pos.Y <= 0)
{
pos.Y += m_lastposChange.Y + 1;
needUpdateBody = true;
}
if (needUpdateBody)
d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
}
#endregion
#region Terrain checks
float terrainHeight = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y);
if (pos.Z < terrainHeight - 5)
{
pos.Z = terrainHeight + 2;
m_lastPositionVector = pos;
//Make sure that we don't have an explosion the next frame with the posChange
d.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
}
else if (pos.Z < terrainHeight)
{
m_newVelocity.Z += 1;
}
#endregion
#region Hover
// Check if hovering
if ((m_flags &
//.........这里部分代码省略.........
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:101,代码来源:AODEDynamics.cs
示例10: Step
internal void Step(IntPtr pBody, float pTimestep, AuroraODEPhysicsScene pParentScene, AuroraODEPrim parent)
{
m_body = pBody;
if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
if (Mass == 0)
GetMass(pBody);
if (Mass == 0)
return; //No noMass vehicles...
if (!d.BodyIsEnabled(Body))
d.BodyEnable(Body);
frcount++; // used to limit debug comment output
if (frcount > 100)
frcount = 0;
// scale time so parameters work as before
// until we scale then acording to ode step time
MoveLinear(pTimestep, pParentScene, parent);
MoveAngular(pTimestep, pParentScene, parent);
LimitRotation(pTimestep);
}
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:23,代码来源:AODEDynamics.cs
示例11: Enable
//end SetDefaultsForType
internal void Enable(IntPtr pBody, AuroraODEPrim parent, AuroraODEPhysicsScene pParentScene)
{
if (m_enabled)
return;
m_enabled = true;
m_lastLinearVelocityVector = parent.Velocity;
m_lastPositionVector = parent.Position;
m_lastAngularVelocity = parent.RotationalVelocity;
parent.ThrottleUpdates = false;
m_body = pBody;
if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
GetMass(pBody);
}
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:16,代码来源:AODEDynamics.cs
示例12: AuroraODECharacter
public AuroraODECharacter(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation,
Vector3 size)
{
m_uuid = UUID.Random();
_parent_scene = parent_scene;
m_taintRotation = rotation;
if (pos.IsFinite())
{
if (pos.Z > 9999999f || pos.Z < -90f)
{
pos.Z =
_parent_scene.GetTerrainHeightAtXY(_parent_scene.Region.RegionSizeX*0.5f,
_parent_scene.Region.RegionSizeY*0.5f) + 5.0f;
}
_position = pos;
}
else
{
_position.X = _parent_scene.Region.RegionSizeX*0.5f;
_position.Y = _parent_scene.Region.RegionSizeY*0.5f;
_position.Z = _parent_scene.GetTerrainHeightAtXY(_position.X, _position.Y) + 10f;
MainConsole.Instance.Warn("[PHYSICS]: Got NaN Position on Character Create");
}
m_isPhysical = false; // current status: no ODE information exists
Size = size;
m_name = avName;
}
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:32,代码来源:AODECharacter.cs
示例13: Step
internal void Step(IntPtr pBody, float pTimestep, AuroraODEPhysicsScene pParentScene, AuroraODEPrim parent)
{
m_body = pBody;
if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
if (!d.BodyIsEnabled(Body))
d.BodyEnable(Body);
frcount++; // used to limit debug comment output
if (frcount > 100)
frcount = 0;
MoveLinear(pTimestep, pParentScene);
MoveAngular(pTimestep, pParentScene);
LimitRotation(pTimestep);
/*if (!parent.m_angularlock.ApproxEquals(Vector3.One, 0.003f) &&
parent.Amotor != IntPtr.Zero)
{
d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0f);
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.Vel, 9000f);
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, int.MaxValue);
d.Vector3 avel2 = d.BodyGetAngularVel(Body);
if (parent.m_angularlock.X == 0)
avel2.X = 0;
if (parent.m_angularlock.Y == 0)
avel2.Y = 0;
if (parent.m_angularlock.Z == 0)
avel2.Z = 0;
d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
d.BodySetAngularDamping(Body, 1);
d.BodySetTorque(Body, 0, 0, 0);
}*/
// WE deal with updates
parent.RequestPhysicsterseUpdate();
} // end Step
开发者ID:kow,项目名称:Aurora-Sim,代码行数:44,代码来源:AODEDynamics.cs
示例14: AddChange
public void AddChange(AuroraODEPhysicsScene.changes what, object arg)
{
_parent_scene.AddChange(this, what, arg);
}
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:4,代码来源:AODEPrim.cs
示例15: AuroraODEPrim
private Vector3 showposition; // a temp hack for now rest of code expects position to be changed immediately
public AuroraODEPrim(ISceneChildEntity entity, AuroraODEPhysicsScene parent_scene, bool pisPhysical)
{
m_vehicle = new AuroraODEDynamics();
//gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
// correct for changed timestep
PID_D /= (parent_scene.ODE_STEPSIZE * 50f); // original ode fps of 50
PID_G /= (parent_scene.ODE_STEPSIZE * 50f);
body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
prim_geom = IntPtr.Zero;
_size = entity.Scale;
_position = entity.AbsolutePosition;
fakepos = 0;
_orientation = entity.GetWorldRotation();
fakeori = 0;
_pbs = entity.Shape;
_parent_entity = entity;
_parent_scene = parent_scene;
m_targetSpace = IntPtr.Zero;
/*
m_isphysical = pisPhysical;
if (m_isphysical)
m_targetSpace = _parent_scene.space;
*/
m_isphysical = false;
m_forceacc = Vector3.Zero;
m_angularforceacc = Vector3.Zero;
hasOOBoffsetFromMesh = false;
_triMeshData = IntPtr.Zero;
CalcPrimBodyData();
_parent_scene.AddSimulationChange(() => changeadd());
}
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:43,代码来源:AODEPrim.cs
示例16: MoveAngular
// end MoveLinear()
private void MoveAngular(float pTimestep, AuroraODEPhysicsScene _pParentScene, AuroraODEPrim parent)
{
d.Vector3 angularVelocity = d.BodyGetAngularVel(Body);
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
// Vector3 angularVelocity = Vector3.Zero;
/*if ((m_flags & VehicleFlag.MOUSELOOK_STEER) == VehicleFlag.MOUSELOOK_STEER)
{
if (m_userLookAt != Quaternion.Identity)
{
Quaternion camrot = Quaternion.Subtract (m_userLookAt, rotq);
camrot.Normalize ();
m_angularMotorVelocity += Vector3.One * camrot;
Console.WriteLine (Vector3.One * camrot);
}
}*/
if (m_angularMotorDirection.LengthSquared() > 1e-6f)
{
m_angularMotorVelocity.X = (m_angularMotorDirection.X - angularVelocity.X)/(m_angularMotorTimescale);
m_angularMotorVelocity.Y = (m_angularMotorDirection.Y - angularVelocity.Y)/(m_angularMotorTimescale);
m_angularMotorVelocity.Z = (m_angularMotorDirection.Z - angularVelocity.Z)/(m_angularMotorTimescale);
m_angularMotorDirection *= (1.0f - 1.0f/m_angularMotorDecayTimescale);
}
else
{
m_angularMotorVelocity = Vector3.Zero;
} // end motor section
// Vertical attractor section
Vector3 vertattr = Vector3.Zero;
Vector3 deflection = Vector3.Zero;
Vector3 banking = Vector3.Zero;
if (m_verticalAttractionTimescale < 300 && m_lastAngularVelocity != Vector3.Zero)
{
float VAservo = 0;
if (Type == Vehicle.TYPE_BOAT)
{
VAservo = 0.2f/(m_verticalAttractionTimescale);
VAservo *= (m_verticalAttractionEfficiency*m_verticalAttractionEfficiency);
}
else
{
if (parent.LinkSetIsColliding)
VAservo = 0.05f/(m_verticalAttractionTimescale);
else
VAservo = 0.2f/(m_verticalAttractionTimescale);
VAservo *= (m_verticalAttractionEfficiency*m_verticalAttractionEfficiency);
}
// get present body rotation
// make a vector pointing up
Vector3 verterr = Vector3.Zero;
verterr.Z = 1.0f;
// rotate it to Body Angle
verterr = verterr*rotq;
// verterr.X and .Y are the World error ammounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1.
// As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go
// negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body.
if (verterr.Z < 0.0f)
{
verterr.X = 2.0f - verterr.X;
verterr.Y = 2.0f - verterr.Y;
}
// Error is 0 (no error) to +/- 2 (max error)
// scale it by VAservo
verterr = verterr*VAservo;
//if (frcount == 0) Console.WriteLine("VAerr=" + verterr);
// As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so
// Change Body angular velocity X based on Y, and Y based on X. Z is not changed.
vertattr.X = verterr.Y;
vertattr.Y = -verterr.X;
vertattr.Z = 0f;
// scaling appears better usingsquare-law
float bounce = 1.0f - (m_verticalAttractionEfficiency*m_verticalAttractionEfficiency);
vertattr.X += bounce*angularVelocity.X;
vertattr.Y += bounce*angularVelocity.Y;
} // else vertical attractor is off
#region Deflection
//Forward is the prefered direction, but if the reference frame has changed, we need to take this into account as well
Vector3 PreferredAxisOfMotion =
new Vector3((10*(m_angularDeflectionEfficiency/m_angularDeflectionTimescale)), 0, 0);
PreferredAxisOfMotion *= Quaternion.Add(rotq, m_referenceFrame);
//Multiply it so that it scales linearly
//deflection = PreferredAxisOfMotion;
//deflection = ((PreferredAxisOfMotion * m_angularDeflectionEfficiency) / (m_angularDeflectionTimescale / pTimestep));
#endregion
#region Banking
//.........这里部分代码省略.........
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:101,代码来源:AODEDynamics.cs
示例17: setMesh
public bool setMesh(AuroraODEPhysicsScene parent_scene, IMesh mesh)
{
// This sleeper is there to moderate how long it takes between
// setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
//Thread.Sleep(10);
//Kill Body so that mesh can re-make the geom
if (IsPhysical && Body != IntPtr.Zero)
{
if (childPrim)
{
if (_parent != null)
{
AuroraODEPrim parent = (AuroraODEPrim)_parent;
parent.ChildDelink(this);
}
}
else
{
DestroyBody();
}
}
IntPtr vertices, indices;
int vertexCount, indexCount;
int vertexStride, triStride;
mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount);
// Note, that vertices are fixed in unmanaged heap
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount);
// Also fixed, needs release after usage
if (vertexCount == 0 || indexCount == 0)
{
MainConsole.Instance.WarnFormat("[PHYSICS]: Got invalid mesh on prim at <{0},{1},{2}>. It can be a sculpt with alpha channel in map. Replacing it by a small box.", _position.X, _position.Y, _position.Z);
_size.X = 0.01f;
_size.Y = 0.01f;
_size.Z = 0.01f;
return false;
}
primOOBoffset = mesh.GetCentroid();
hasOOBoffsetFromMesh = true;
mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
if (m_MeshToTriMeshMap.ContainsKey(mesh.Key))
{
_triMeshData = m_MeshToTriMeshMap[mesh.Key];
}
else
{
_triMeshData = d.GeomTriMeshDataCreate();
d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount,
triStride);
d.GeomTriMeshDataPreprocess(_triMeshData);
m_MeshToTriMeshMap[mesh.Key] = _triMeshData;
}
try
{
if (prim_geom == IntPtr.Zero)
{
SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null));
}
}
catch (AccessViolationException)
{
MainConsole.Instance.Error("[PHYSICS]: MESH LOCKED");
return false;
}
return true;
}
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:74,代码来源:AODEPrim.cs
示例18: Enable
}//end SetDefaultsForType
internal void Enable(IntPtr pBody, AuroraODEPrim parent, AuroraODEPhysicsScene pParentScene)
{
if (m_enabled)
return;
m_enabled = true;
m_previousMaterial = (Material)parent.m_material;
parent.SetMaterial((int)Material.Glass); //This seems to happen in SL... and its needed for here
parent.ThrottleUpdates = false;
m_body = pBody;
if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
d.Mass mass;
d.BodyGetMass(pBody, out mass);
Mass = mass.mass;
Mass *= 2;
}
开发者ID:x8ball,项目名称:Aurora-Sim,代码行数:20,代码来源:AODEDynamics.cs
示例19: ODESpecificAvatar
public ODESpecificAvatar(String avName, AuroraODEPhysicsScene parent_scene, Vector3 pos, Quaternion rotation,
Vector3 size) : base(avName, parent_scene, pos, rotation, size)
{
base._parent_ref = this;
}
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:5,代码来源:ODESpecificAvatar.cs
示例20: Step
internal void Step(IntPtr pBody, float pTimestep, AuroraODEPhysicsScene pParentScene, AuroraODEPrim parent)
{
m_body = pBody;
if (pBody == IntPtr.Zero || m_type == Vehicle.TYPE_NONE)
return;
if (!d.BodyIsEnabled(Body))
d.BodyEnable(Body);
frcount++; // used to limit debug comment output
if (frcount > 100)
frcount = 0;
MoveLinear(pTimestep, pParentScene);
MoveAngular(pTimestep, pParentScene);
LimitRotation(pTimestep);
// WE deal with updates
parent.RequestPhysicsterseUpdate();
} // end Step
开发者ID:x8ball,项目名称:Aurora-Sim,代码行数:19,代码来源:AODEDynamics.cs
注:本文中的Aurora.Physics.AuroraOpenDynamicsEngine.AuroraODEPhysicsScene类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论