本文整理汇总了C#中WhiteCore.Region.Physics.BulletSPlugin.BulletBody类的典型用法代码示例。如果您正苦于以下问题:C# BulletBody类的具体用法?C# BulletBody怎么用?C# BulletBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BulletBody类属于WhiteCore.Region.Physics.BulletSPlugin命名空间,在下文中一共展示了BulletBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BSConstraintHinge
public BSConstraintHinge(BulletWorld world, BulletBody obj1, BulletBody obj2,
Vector3 pivotInA, Vector3 pivotInB,
Vector3 axisInA, Vector3 axisInB,
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
: base(world)
{
m_body1 = obj1;
m_body2 = obj2;
m_constraint = PhysicsScene.PE.CreateHingeConstraint(world, obj1, obj2,
pivotInA, pivotInB, axisInA, axisInB,
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
m_enabled = true;
}
示例2: BSConstraint6Dof
// Create a btGeneric6DofConstraint
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
Vector3 frame1, Quaternion frame1rot,
Vector3 frame2, Quaternion frame2rot,
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
: base(world)
{
m_body1 = obj1;
m_body2 = obj2;
m_constraint = PhysicsScene.PE.Create6DofConstraint(m_world, m_body1, m_body2,
frame1, frame1rot,
frame2, frame2rot,
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
m_enabled = true;
world.physicsScene.DetailLog("{0},BS6DofConstraint,createFrame,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
BSScene.DetailLogZero, world.worldID,
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
}
示例3: BSConstraint6Dof
// 6 Dof constraint based on a midpoint between the two constrained bodies
public BSConstraint6Dof(BulletWorld world, BulletBody obj1, BulletBody obj2,
Vector3 joinPoint,
bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies)
: base(world)
{
m_body1 = obj1;
m_body2 = obj2;
if (!obj1.HasPhysicalBody || !obj2.HasPhysicalBody)
{
world.physicsScene.DetailLog(
"{0},BS6DOFConstraint,badBodyPtr,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
BSScene.DetailLogZero, world.worldID,
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
world.physicsScene.Logger.ErrorFormat(
"{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}",
LogHeader, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
m_enabled = false;
}
else
{
m_constraint = PhysicsScene.PE.Create6DofConstraintToPoint(m_world, m_body1, m_body2,
joinPoint,
useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies);
PhysicsScene.DetailLog(
"{0},BS6DofConstraint,createMidPoint,wID={1}, csrt={2}, rID={3}, rBody={4}, cID={5}, cBody={6}",
BSScene.DetailLogZero, world.worldID, m_constraint.AddrString,
obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString);
if (!m_constraint.HasPhysicalConstraint)
{
world.physicsScene.Logger.ErrorFormat(
"{0} Failed creation of 6Dof constraint. rootID={1}, childID={2}",
LogHeader, obj1.ID, obj2.ID);
m_enabled = false;
}
else
{
m_enabled = true;
}
}
}
示例4: GetAngularFactor
public override Vector3 GetAngularFactor(BulletBody pBody)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
IndexedVector3 iv3 = body.GetAngularFactor();
return new Vector3(iv3.X, iv3.Y, iv3.Z);
}
示例5: GetActivationState
public override int GetActivationState(BulletBody pBody)
{
/* TODO */
return 0;
}
示例6: DestroyObject
public override void DestroyObject(BulletWorld pWorld, BulletBody pBody)
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
CollisionObject co = (pBody as BulletBodyXNA).rigidBody;
RigidBody bo = co as RigidBody;
if (bo == null)
{
if (world.IsInWorld(co))
{
world.RemoveCollisionObject(co);
}
}
else
{
if (world.IsInWorld(bo))
{
world.RemoveRigidBody(bo);
}
}
if (co != null)
{
if (co.GetUserPointer() != null)
{
uint localId = (uint)co.GetUserPointer();
if (specialCollisionObjects.ContainsKey(localId))
{
specialCollisionObjects.Remove(localId);
}
}
}
}
示例7: CreatePoint2PointConstraint
public override BulletConstraint CreatePoint2PointConstraint(BulletWorld pWorld, BulletBody pBody1,
BulletBody pBody2,
Vector3 ppivotInA, Vector3 ppivotInB,
bool pdisableCollisionsBetweenLinkedBodies)
{
Point2PointConstraint constrain = null;
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
RigidBody rb1 = (pBody1 as BulletBodyXNA).rigidBody;
RigidBody rb2 = (pBody2 as BulletBodyXNA).rigidBody;
if (rb1 != null && rb2 != null)
{
IndexedVector3 pivotInA = new IndexedVector3(ppivotInA.X, ppivotInA.Y, ppivotInA.Z);
IndexedVector3 pivotInB = new IndexedVector3(ppivotInB.X, ppivotInB.Y, ppivotInB.Z);
constrain = new Point2PointConstraint(rb1, rb2, ref pivotInA, ref pivotInB);
world.AddConstraint(constrain, pdisableCollisionsBetweenLinkedBodies);
}
return new BulletConstraintXNA(constrain);
}
示例8: ApplyDamping
public override void ApplyDamping(BulletBody pBody, float timeStep)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
body.ApplyDamping(timeStep);
}
示例9: AddToCollisionFlags
public override CollisionFlags AddToCollisionFlags(BulletBody pCollisionObject, CollisionFlags pcollisionFlags)
{
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
CollisionFlags existingcollisionFlags = (CollisionFlags)(uint)collisionObject.GetCollisionFlags();
existingcollisionFlags |= pcollisionFlags;
collisionObject.SetCollisionFlags((BulletXNA.BulletCollision.CollisionFlags)(uint)existingcollisionFlags);
return (CollisionFlags)(uint)existingcollisionFlags;
}
示例10: AddObjectToWorld
public override bool AddObjectToWorld(BulletWorld pWorld, BulletBody pBody)
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
CollisionObject cbody = (pBody as BulletBodyXNA).body;
RigidBody rbody = cbody as RigidBody;
// Bullet resets several variables when an object is added to the world. In particular,
// BulletXNA resets position and rotation. Gravity is also reset depending on the static/dynamic
// type. Of course, the collision flags in the broadphase proxy are initialized to default.
IndexedMatrix origPos = cbody.GetWorldTransform();
if (rbody != null)
{
IndexedVector3 origGrav = rbody.GetGravity();
world.AddRigidBody(rbody);
rbody.SetGravity(origGrav);
}
else
{
world.AddCollisionObject(cbody);
}
cbody.SetWorldTransform(origPos);
pBody.ApplyCollisionMask(pWorld.physicsScene);
//if (body.GetBroadphaseHandle() != null)
// world.UpdateSingleAabb(body);
return true;
}
示例11: GetDebugProperties
private static EntityProperties GetDebugProperties(BulletWorld pWorld, BulletBody pCollisionObject)
{
EntityProperties ent = new EntityProperties();
// 20131224 not used DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).rigidBody;
IndexedMatrix transform = collisionObject.GetWorldTransform();
IndexedVector3 LinearVelocity = collisionObject.GetInterpolationLinearVelocity();
IndexedVector3 AngularVelocity = collisionObject.GetInterpolationAngularVelocity();
IndexedQuaternion rotation = transform.GetRotation();
ent.Acceleration = Vector3.Zero;
ent.ID = (uint)collisionObject.GetUserPointer();
ent.Position = new Vector3(transform._origin.X, transform._origin.Y, transform._origin.Z);
ent.Rotation = new Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W);
ent.Velocity = new Vector3(LinearVelocity.X, LinearVelocity.Y, LinearVelocity.Z);
ent.RotationalVelocity = new Vector3(AngularVelocity.X, AngularVelocity.Y, AngularVelocity.Z);
return ent;
}
示例12: WantsSleeping
public override bool WantsSleeping(BulletBody pBody)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
return body.WantsSleeping();
}
示例13: UpdateSingleAabb
public override void UpdateSingleAabb(BulletWorld pWorld, BulletBody pCollisionObject)
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
CollisionObject collisionObject = (pCollisionObject as BulletBodyXNA).body;
world.UpdateSingleAabb(collisionObject);
}
示例14: UpdateInertiaTensor
public override void UpdateInertiaTensor(BulletBody pBody)
{
RigidBody body = (pBody as BulletBodyXNA).rigidBody;
if (body != null) // can't update inertia tensor on CollisionObject
body.UpdateInertiaTensor();
}
示例15: Create6DofConstraintToPoint
/// <summary>
///
/// </summary>
/// <param name="pWorld"></param>
/// <param name="pBody1"></param>
/// <param name="pBody2"></param>
/// <param name="pjoinPoint"></param>
/// <param name="puseLinearReferenceFrameA"></param>
/// <param name="pdisableCollisionsBetweenLinkedBodies"></param>
/// <returns></returns>
public override BulletConstraint Create6DofConstraintToPoint(BulletWorld pWorld, BulletBody pBody1,
BulletBody pBody2, Vector3 pjoinPoint, bool puseLinearReferenceFrameA,
bool pdisableCollisionsBetweenLinkedBodies)
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
RigidBody body1 = (pBody1 as BulletBodyXNA).rigidBody;
RigidBody body2 = (pBody2 as BulletBodyXNA).rigidBody;
IndexedMatrix frame1 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0));
IndexedMatrix frame2 = new IndexedMatrix(IndexedBasisMatrix.Identity, new IndexedVector3(0, 0, 0));
IndexedVector3 joinPoint = new IndexedVector3(pjoinPoint.X, pjoinPoint.Y, pjoinPoint.Z);
IndexedMatrix mat = IndexedMatrix.Identity;
mat._origin = new IndexedVector3(pjoinPoint.X, pjoinPoint.Y, pjoinPoint.Z);
frame1._origin = body1.GetWorldTransform().Inverse() * joinPoint;
frame2._origin = body2.GetWorldTransform().Inverse() * joinPoint;
Generic6DofConstraint consttr = new Generic6DofConstraint(body1, body2, ref frame1, ref frame2,
puseLinearReferenceFrameA);
consttr.CalculateTransforms();
world.AddConstraint(consttr, pdisableCollisionsBetweenLinkedBodies);
return new BulletConstraintXNA(consttr);
}