本文整理汇总了C#中BulletSharp.CollisionShape.CalculateLocalInertia方法的典型用法代码示例。如果您正苦于以下问题:C# CollisionShape.CalculateLocalInertia方法的具体用法?C# CollisionShape.CalculateLocalInertia怎么用?C# CollisionShape.CalculateLocalInertia使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.CollisionShape
的用法示例。
在下文中一共展示了CollisionShape.CalculateLocalInertia方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Prop
public Prop(CollisionShape shape, float mass, Matrix4 start)
{
Physics physics = Game.Instance.Physics;
Shape = shape;
IsDynamic = (mass != 0.0f);
physics.Props.Add(this);
Vector3 inertia = Vector3.Zero;
if (IsDynamic) shape.CalculateLocalInertia(mass, out inertia);
DefaultMotionState motionState = new DefaultMotionState(start);
RigidBody.RigidBodyConstructionInfo info = new RigidBody.RigidBodyConstructionInfo(mass, motionState, shape, inertia);
Body = new RigidBody(info);
physics.World.AddRigidBody(Body);
}
示例2: LocalCreateRigidBody
protected RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
{
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if (isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
body = new RigidBody(rbInfo);
return body;
}
示例3: LocalCreateRigidBody
public override RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
{
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if (isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, null, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);
rbInfo.Dispose();
body.ContactProcessingThreshold = defaultContactProcessingThreshold;
body.WorldTransform = startTransform;
World.AddRigidBody(body);
return body;
}
示例4: LocalCreateRigidBody
public RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape)
{
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if (isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBody body;
using (var rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia))
{
body = new RigidBody(rbInfo);
}
ownerWorld.AddRigidBody(body);
return body;
}
示例5: LocalCreateRigidBody
public RigidBody LocalCreateRigidBody(float mass, Matrix4 startTransform, CollisionShape shape)
{
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.ZERO;
if (isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBody body;
using (var rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia))
{
body = new RigidBody(rbInfo);
}
World.AddRigidBody(body);
return body;
}
示例6: CreateRigidBody
public virtual RigidBody CreateRigidBody(bool isDynamic, float mass, ref Matrix startTransform, CollisionShape shape, string bodyName)
{
Vector3 localInertia;
if (mass != 0.0f)
{
shape.CalculateLocalInertia(mass, out localInertia);
}
else
{
localInertia = Vector3.Zero;
}
RigidBodyConstructionInfo info = new RigidBodyConstructionInfo(mass, null, shape, localInertia);
RigidBody body = new RigidBody(info);
info.Dispose();
body.WorldTransform = startTransform;
if (_dynamicsWorld != null)
{
_dynamicsWorld.AddRigidBody(body);
}
if (bodyName != null)
{
_objectNameMap.Add(body, bodyName);
_nameBodyMap.Add(bodyName, body);
}
_allocatedRigidBodies.Add(body);
return body;
}
示例7: LocalCreateRigidBody
public virtual RigidBody LocalCreateRigidBody(float mass, Matrix startTransform, CollisionShape shape, bool isKinematic = false)
{
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if (isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);
if (isKinematic) {
body.CollisionFlags = body.CollisionFlags | CollisionFlags.KinematicObject;
body.ActivationState = ActivationState.DisableDeactivation;
}
rbInfo.Dispose();
_world.AddRigidBody(body);
return body;
}
示例8: CreateRigidBody
private RigidBody CreateRigidBody(float mass, Matrix4 startTransform, CollisionShape shape)
{
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if(isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);
body.SetSleepingThresholds(0, 0);
body.ContactProcessingThreshold = 0;
body.CcdMotionThreshold = 0;
//World.AddRigidBody(body);
return body;
}
示例9: CreateOrConfigureRigidBody
/**
Creates or configures a RigidBody based on the current settings. Does not alter the internal state of this component in any way.
Can be used to create copies of this BRigidBody for use in other physics simulations.
*/
public bool CreateOrConfigureRigidBody(ref RigidBody rb, ref BulletSharp.Math.Vector3 localInertia, CollisionShape cs, MotionState motionState)
{
//rigidbody is dynamic if and only if mass is non zero, otherwise static
localInertia = BulletSharp.Math.Vector3.Zero;
if (isDynamic())
{
cs.CalculateLocalInertia(_mass, out localInertia);
}
if (rb == null)
{
float bulletMass = _mass;
if (!isDynamic())
{
bulletMass = 0f;
}
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(bulletMass, motionState, cs, localInertia);
rbInfo.Friction = _friction;
rbInfo.RollingFriction = _rollingFriction;
rbInfo.LinearDamping = _linearDamping;
rbInfo.AngularDamping = _angularDamping;
rbInfo.Restitution = _restitution;
rbInfo.LinearSleepingThreshold = _linearSleepingThreshold;
rbInfo.AngularSleepingThreshold = _angularSleepingThreshold;
rbInfo.AdditionalDamping = _additionalDamping;
rbInfo.AdditionalAngularDampingFactor = _additionalAngularDampingFactor;
rbInfo.AdditionalAngularDampingThresholdSqr = _additionalAngularDampingThresholdSqr;
rbInfo.AdditionalDampingFactor = _additionalDampingFactor;
rbInfo.AdditionalLinearDampingThresholdSqr = _additionalLinearDampingThresholdSqr;
rb = new RigidBody(rbInfo);
rbInfo.Dispose();
}
else {
float usedMass = 0f;
if (isDynamic())
{
usedMass = _mass;
}
rb.SetMassProps(usedMass, localInertia);
rb.Friction = _friction;
rb.RollingFriction = _rollingFriction;
rb.SetDamping(_linearDamping, _angularDamping);
rb.Restitution = _restitution;
rb.SetSleepingThresholds(_linearSleepingThreshold, _angularSleepingThreshold);
rb.CollisionShape = cs;
}
rb.AngularVelocity = angularVelocity.ToBullet();
rb.LinearVelocity = velocity.ToBullet();
rb.CollisionFlags = m_collisionFlags;
rb.LinearFactor = _linearFactor.ToBullet();
rb.AngularFactor = _angularFactor.ToBullet();
if (m_rigidBody != null)
{
rb.DeactivationTime = m_rigidBody.DeactivationTime;
rb.InterpolationLinearVelocity = m_rigidBody.InterpolationLinearVelocity;
rb.InterpolationAngularVelocity = m_rigidBody.InterpolationAngularVelocity;
rb.InterpolationWorldTransform = m_rigidBody.InterpolationWorldTransform;
}
//if kinematic then disable deactivation
if ((m_collisionFlags & BulletSharp.CollisionFlags.KinematicObject) != 0)
{
rb.ActivationState = ActivationState.DisableDeactivation;
}
return true;
}
示例10: CreateRigidBody
public RigidBody CreateRigidBody(float mass, Matrix4 startTransform, CollisionShape shape, Mesh3d reference)
{
bool isDynamic = (mass != 0.0f);
Vector3 localInertia = Vector3.Zero;
if(isDynamic)
shape.CalculateLocalInertia(mass, out localInertia);
DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia);
RigidBody body = new RigidBody(rbInfo);
body.UserObject = reference;
PhysicalWorld.AddRigidBody(body);
return body;
}