本文整理匯總了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;
}