本文整理汇总了C#中Aurora.Physics.AuroraOpenDynamicsEngine.AuroraODEPrim类的典型用法代码示例。如果您正苦于以下问题:C# AuroraODEPrim类的具体用法?C# AuroraODEPrim怎么用?C# AuroraODEPrim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuroraODEPrim类属于Aurora.Physics.AuroraOpenDynamicsEngine命名空间,在下文中一共展示了AuroraODEPrim类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: changelink
private void changelink (AuroraODEPrim newparent)
{
// If the newly set parent is not null
// create link
if (_parent == null && newparent != null)
{
if (newparent.PhysicsActorType == (int)ActorTypes.Prim)
{
AuroraODEPrim obj = (AuroraODEPrim)newparent;
obj.ParentPrim (this);
}
}
// If the newly set parent is null
// destroy link
else if (_parent != null && newparent == null)
{
//Console.WriteLine(" changelink B");
if (_parent is AuroraODEPrim)
{
AuroraODEPrim obj = (AuroraODEPrim)_parent;
obj.ChildDelink (this);
childPrim = false;
//_parent = null;
}
}
_parent = newparent;
}
示例3: ChildSetGeom
private void ChildSetGeom(AuroraODEPrim odePrim)
{
DestroyBody();
MakeBody();
}
示例4: ParentPrim
// I'm the parent
// prim is the child
public void ParentPrim(AuroraODEPrim prim)
{
//Console.WriteLine("ParentPrim " + m_primName);
if (this.m_localID != prim.m_localID)
{
if (Body == IntPtr.Zero)
{
Body = d.BodyCreate(_parent_scene.world);
setMass();
}
if (Body != IntPtr.Zero)
{
lock (childrenPrim)
{
if (!childrenPrim.Contains(prim))
{
//Console.WriteLine("childrenPrim.Add " + prim);
childrenPrim.Add(prim);
foreach (AuroraODEPrim prm in childrenPrim)
{
d.Mass m2;
d.MassSetZero(out m2);
prim.Mass = prim.CalculateMass();
d.MassSetBoxTotal(out m2, prim.Mass, prm._size.X, prm._size.Y, prm._size.Z);
d.Quaternion quat = new d.Quaternion();
quat.W = prm._orientation.W;
quat.X = prm._orientation.X;
quat.Y = prm._orientation.Y;
quat.Z = prm._orientation.Z;
d.Matrix3 mat = new d.Matrix3();
d.RfromQ(out mat, ref quat);
d.MassRotate(ref m2, ref mat);
d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
d.MassAdd(ref pMass, ref m2);
}
foreach (AuroraODEPrim prm in childrenPrim)
{
prm.m_collisionCategories |= CollisionCategories.Body;
prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
if (prm.prim_geom == IntPtr.Zero)
{
m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet");
continue;
}
//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + m_primName);
d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
d.Quaternion quat = new d.Quaternion();
quat.W = prm._orientation.W;
quat.X = prm._orientation.X;
quat.Y = prm._orientation.Y;
quat.Z = prm._orientation.Z;
d.Matrix3 mat = new d.Matrix3();
d.RfromQ(out mat, ref quat);
if (Body != IntPtr.Zero)
{
d.GeomSetBody(prm.prim_geom, Body);
prm.childPrim = true;
d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z);
//d.GeomSetOffsetPosition(prim.prim_geom,
// (Position.X - prm.Position.X) - pMass.c.X,
// (Position.Y - prm.Position.Y) - pMass.c.Y,
// (Position.Z - prm.Position.Z) - pMass.c.Z);
d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
//d.GeomSetOffsetRotation(prm.prim_geom, ref mat);
d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
d.BodySetMass(Body, ref pMass);
}
else
{
m_log.Debug("[PHYSICS]:I ain't got no boooooooooddy, no body");
}
prm.m_interpenetrationcount = 0;
prm.m_collisionscore = 0;
prm.m_disabled = false;
// The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.ApproxEquals(Vector3.One, 0f)) && _parent == null)
{
prm.createAMotor(m_angularlock);
}
prm.Body = Body;
_parent_scene.addActivePrim(prm);
}
m_collisionCategories |= CollisionCategories.Body;
m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
//.........这里部分代码省略.........
示例5: ChildDelink
private void ChildDelink(AuroraODEPrim odePrim)
{
// Okay, we have a delinked child.. need to rebuild the body.
lock (childrenPrim)
{
foreach (AuroraODEPrim prm in childrenPrim)
{
prm.childPrim = true;
prm.disableBody();
//prm.m_taintparent = null;
//prm._parent = null;
//prm.m_taintPhysics = false;
//prm.m_disabled = true;
//prm.childPrim = false;
}
}
disableBody();
lock (childrenPrim)
{
//Console.WriteLine("childrenPrim.Remove " + odePrim);
childrenPrim.Remove(odePrim);
}
if (Body != IntPtr.Zero)
{
_parent_scene.remActivePrim(this);
}
lock (childrenPrim)
{
foreach (AuroraODEPrim prm in childrenPrim)
{
//Console.WriteLine("ChildDelink calls ParentPrim");
ParentPrim(prm);
}
}
}
示例6: addActivePrim
public void addActivePrim(AuroraODEPrim activatePrim)
{
// adds active prim.. (ones that should be iterated over in collisions_optimized
lock (_activeprimsLock)
{
if (!_activeprims.Contains(activatePrim))
_activeprims.Add(activatePrim);
//else
// MainConsole.Instance.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
}
}
示例7: RemovePrimThreadLocked
///<summary>
/// This is called from within simulate but outside the locked portion
/// We need to do our own locking here
/// Essentially, we need to remove the prim from our space segment, whatever segment it's in.
///
/// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
/// that the space was using.
///</summary>
///<param name = "prim"></param>
public void RemovePrimThreadLocked(AuroraODEPrim prim)
{
//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName);
lock (prim)
{
remCollisionEventReporting(prim);
remActivePrim(prim);
prim.m_frozen = true;
if (prim.prim_geom != IntPtr.Zero)
{
prim.DestroyBody();
prim.IsPhysical = false;
prim.m_targetSpace = IntPtr.Zero;
try
{
if (prim.prim_geom != IntPtr.Zero)
{
d.GeomDestroy(prim.prim_geom);
prim.prim_geom = IntPtr.Zero;
}
else
{
MainConsole.Instance.Warn("[PHYSICS]: Unable to remove prim from physics scene");
}
}
catch (AccessViolationException)
{
MainConsole.Instance.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
}
}
if (!prim.childPrim)
{
lock (prim.childrenPrim)
{
foreach (AuroraODEPrim prm in prim.childrenPrim)
{
RemovePrimThreadLocked(prm);
}
}
}
lock (_prims)
_prims.Remove(prim);
}
}
示例8: addActivePrim
internal void addActivePrim(AuroraODEPrim activatePrim)
{
// adds active prim.. (ones that should be iterated over in collisions_optimized
lock (_activeprimsLock)
{
if (!_activeprims.Contains(activatePrim))
_activeprims.Add(activatePrim);
}
}
示例9: BadPrim
internal void BadPrim(AuroraODEPrim auroraODEPrim)
{
DeletePrim(auroraODEPrim);
//Can't really do this here... as it will be readded before the delete gets called, which is wrong...
//So... leave the prim out there for now
//AddPrimShape(auroraODEPrim.ParentEntity);
}
示例10: AddPrim
private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
{
Vector3 pos = position;
Vector3 siz = size;
Quaternion rot = rotation;
AuroraODEPrim newPrim;
lock (OdeLock)
{
newPrim = new AuroraODEPrim(name, this, pos, siz, rot, mesh, pbs, isphysical, ode);
lock (_prims)
_prims.Add(newPrim);
}
return newPrim;
}
示例11: RemovePrimThreadLocked
/// <summary>
/// This is called from within simulate but outside the locked portion
/// We need to do our own locking here
/// Essentially, we need to remove the prim from our space segment, whatever segment it's in.
///
/// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
/// that the space was using.
/// </summary>
/// <param name="prim"></param>
public void RemovePrimThreadLocked(AuroraODEPrim prim)
{
//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName);
lock (prim)
{
remCollisionEventReporting(prim);
remActivePrim(prim);
lock (ode)
{
prim.m_frozen = true;
if (prim.prim_geom != IntPtr.Zero)
{
prim.DestroyBody();
prim.IsPhysical = false;
// we don't want to remove the main space
// If the geometry is in the targetspace, remove it from the target space
//m_log.Warn(prim.m_targetSpace);
//if (prim.m_targetSpace != IntPtr.Zero)
//{
//if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
//{
//if (d.GeomIsSpace(prim.m_targetSpace))
//{
//waitForSpaceUnlock(prim.m_targetSpace);
//d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
prim.m_targetSpace = IntPtr.Zero;
//}
//else
//{
// m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
//((OdePrim)prim).m_targetSpace.ToString());
//}
//}
//}
//m_log.Warn(prim.prim_geom);
try
{
if (prim.prim_geom != IntPtr.Zero)
{
d.GeomDestroy(prim.prim_geom);
prim.prim_geom = IntPtr.Zero;
}
else
{
m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
}
}
catch (AccessViolationException)
{
m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
}
lock (_prims)
_prims.Remove(prim);
//If there are no more geometries in the sub-space, we don't need it in the main space anymore
//if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
//{
//if (prim.m_targetSpace != null)
//{
//if (d.GeomIsSpace(prim.m_targetSpace))
//{
//waitForSpaceUnlock(prim.m_targetSpace);
//d.SpaceRemove(space, prim.m_targetSpace);
// free up memory used by the space.
//d.SpaceDestroy(prim.m_targetSpace);
//int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
//resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
//}
//else
//{
//m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
//((OdePrim) prim).m_targetSpace.ToString());
//}
//}
//}
if (SupportsNINJAJoints)
{
RemoveAllJointsConnectedToActorThreadLocked(prim);
}
}
}
}
}
示例12: collision_accounting_events
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
{
obj2LocalID = 0;
if (!p2.SubscribedEvents() && !p1.SubscribedEvents())
return;
switch ((ActorTypes)p2.PhysicsActorType)
{
case ActorTypes.Agent:
cc2 = (AuroraODECharacter)p2;
switch ((ActorTypes)p1.PhysicsActorType)
{
case ActorTypes.Agent:
cc1 = (AuroraODECharacter)p1;
obj2LocalID = cc1.m_localID;
cc1.AddCollisionEvent(cc2.m_localID, contact);
break;
case ActorTypes.Prim:
if (p1 is AuroraODEPrim)
{
cp1 = (AuroraODEPrim)p1;
obj2LocalID = cp1.m_localID;
cp1.AddCollisionEvent(cc2.m_localID, contact);
}
break;
case ActorTypes.Ground:
case ActorTypes.Unknown:
obj2LocalID = 0;
break;
}
cc2.AddCollisionEvent(obj2LocalID, contact);
break;
case ActorTypes.Prim:
if (p2 is AuroraODEPrim)
{
cp2 = (AuroraODEPrim)p2;
switch ((ActorTypes)p1.PhysicsActorType)
{
case ActorTypes.Agent:
if (p1 is AuroraODECharacter)
{
cc1 = (AuroraODECharacter)p1;
obj2LocalID = cc1.m_localID;
cc1.AddCollisionEvent(cp2.m_localID, contact);
}
break;
case ActorTypes.Prim:
if (p1 is AuroraODEPrim)
{
cp1 = (AuroraODEPrim)p1;
obj2LocalID = cp1.m_localID;
cp1.AddCollisionEvent(cp2.m_localID, contact);
}
break;
case ActorTypes.Ground:
case ActorTypes.Unknown:
obj2LocalID = 0;
break;
}
cp2.AddCollisionEvent(obj2LocalID, contact);
}
break;
}
}
示例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);
// WE deal with updates
parent.RequestPhysicsterseUpdate();
} // end Step
示例14: Disable
internal void Disable(AuroraODEPrim parent)
{
if (!m_enabled)
return;
m_enabled = false;
parent.SetMaterial((int)m_previousMaterial); //Revert to the original
parent.ThrottleUpdates = true;
//d.BodyDisable(Body);
m_linearMotorDirection = Vector3.Zero;
m_linearMotorDirectionLASTSET = Vector3.Zero;
m_angularMotorDirection = Vector3.Zero;
}
示例15: AddChange
/// <summary>
/// Called to queue a change to a prim
/// to use in place of old taint mechanism so changes do have a time sequence
/// </summary>
public void AddChange(AuroraODEPrim prim,changes what,Object arg)
{
AODEchangeitem item = new AODEchangeitem();
item.prim = prim;
item.what = what;
item.arg = arg;
// lock (ChangesQueue)
{
ChangesQueue.Enqueue(item);
}
}