public virtual void SetUpBulletPhysicsBody(float mass, IMotionState motionState, CollisionShape collisionShape, Vector3 localInertia) { Mass = mass; CollisionShape = collisionShape; Inertia = localInertia; SetUpBulletPhysicsBody(); }
///btRigidBody constructor for backwards compatibility. ///To specify friction (etc) during rigid body construction, please use the other constructor (using btRigidBodyConstructionInfo) public RigidBody(float mass, IMotionState motionState, CollisionShape collisionShape, IndexedVector3 localInertia) { RigidBodyConstructionInfo cinfo = new RigidBodyConstructionInfo(mass, motionState, collisionShape, localInertia); motionState.SetRigidBody(this); SetupRigidBody(cinfo); }
public RigidBody(float mass, IMotionState motionState, CollisionShape collisionShape, btVector3 localInertia) { shape = collisionShape; MotionState = motionState; shape.act.setMass(mass); shape.act.setMotionState(motionState); inertia = localInertia; }
public void SetMotionState(IMotionState motionState) { m_optionalMotionState = motionState; if (m_optionalMotionState != null) { motionState.GetWorldTransform(out m_worldTransform); } }
///setupRigidBody is only used internally by the constructor protected void SetupRigidBody(RigidBodyConstructionInfo constructionInfo) { m_internalType = CollisionObjectTypes.CO_RIGID_BODY; m_linearVelocity = IndexedVector3.Zero; m_angularVelocity = IndexedVector3.Zero; m_angularFactor = IndexedVector3.One; m_linearFactor = IndexedVector3.One; m_gravity = IndexedVector3.Zero; m_gravity_acceleration = IndexedVector3.Zero; m_totalForce = IndexedVector3.Zero; m_totalTorque = IndexedVector3.Zero; SetDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping); m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold; m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold; m_optionalMotionState = constructionInfo.m_motionState; m_contactSolverType = 0; m_frictionSolverType = 0; m_additionalDamping = constructionInfo.m_additionalDamping; m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor; m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr; m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr; m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor; if (m_optionalMotionState != null) { m_optionalMotionState.GetWorldTransform(out m_worldTransform); } else { SetWorldTransform(ref constructionInfo.m_startWorldTransform); } m_interpolationWorldTransform = m_worldTransform; m_interpolationLinearVelocity = IndexedVector3.Zero; m_interpolationAngularVelocity = IndexedVector3.Zero; //moved to btCollisionObject m_friction = constructionInfo.m_friction; m_restitution = constructionInfo.m_restitution; SetCollisionShape(constructionInfo.m_collisionShape); m_debugBodyId = uniqueId++; SetMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia); UpdateInertiaTensor(); m_rigidbodyFlags = RigidBodyFlags.BT_NONE; m_constraintRefs = new List <TypedConstraint>(); m_deltaLinearVelocity = IndexedVector3.Zero; m_deltaAngularVelocity = IndexedVector3.Zero; m_invMass = m_inverseMass * m_linearFactor; m_pushVelocity = IndexedVector3.Zero; m_turnVelocity = IndexedVector3.Zero; }
/// <summary> /// RigidBodyを生成するときに初期化される /// </summary> /// <param name="ms"></param> public void setMotionState(IMotionState ms) { motionState = ms; // MMDXのパーツ座標を取得する btTransform world; motionState.getWorldTransform(out world); // 初期値をセットする actorDesc.GlobalPose = world.getMatrix(); }
public RigidBodyConstructionInfo(float mass, IMotionState motionState, CollisionShape collisionShape, IndexedVector3 localInertia) { m_mass = mass; m_motionState = motionState; m_collisionShape = collisionShape; m_localInertia = localInertia; m_linearDamping = 0f; m_angularDamping = 0f; m_friction = 0.5f; m_restitution = 0f; m_linearSleepingThreshold = 0.8f; m_angularSleepingThreshold = 1f; m_additionalDamping = false; m_additionalDampingFactor = 0.005f; m_additionalLinearDampingThresholdSqr = 0.01f; m_additionalAngularDampingThresholdSqr = 0.01f; m_additionalAngularDampingFactor = 0.01f; m_startWorldTransform = IndexedMatrix.Identity; }
public RigidBodyConstructionInfo(float mass, IMotionState motionState, CollisionShape collisionShape, Vector3 localInertia) { m_mass = mass; m_motionState = motionState; m_collisionShape = collisionShape; m_localInertia = localInertia; m_linearDamping = 0f; m_angularDamping = 0f; m_friction = 0.5f; m_restitution = 0f; m_linearSleepingThreshold = 0.8f; m_angularSleepingThreshold = 1f; m_additionalDamping = false; m_additionalDampingFactor = 0.005f; m_additionalLinearDampingThresholdSqr = 0.01f; m_additionalAngularDampingThresholdSqr = 0.01f; m_additionalAngularDampingFactor = 0.01f; m_startWorldTransform = Matrix.Identity; }
public IMotionState GetMotionState(string stateKey) { if (motionStateFlyweights.ContainsKey(stateKey)) { return(motionStateFlyweights[stateKey]); } else { IMotionState motionState = null; switch (stateKey) { case "turnAround": motionState = new TurnAroundState(); break; case "straightFast": motionState = new MoveStraightFastState(); break; case "straightSlow": motionState = new MoveStraightSlowState(); break; case "turnLeft": motionState = new TurnLeftState(); break; case "turnRight": motionState = new TurnRightState(); break; default: motionState = new DoNothingState(); break; } motionStateFlyweights.Add(stateKey, motionState); return(motionState); } }
internal void setupRigidBody(RigidBodyConstructionInfo constructionInfo) { m_linearVelocity.setValue(0.0f, 0.0f, 0.0f); m_angularVelocity.setValue(0f, 0f, 0f); m_angularFactor.setValue(1, 1, 1); m_linearFactor.setValue(1, 1, 1); m_gravity.setValue(0.0f, 0.0f, 0.0f); m_gravity_acceleration.setValue(0.0f, 0.0f, 0.0f); m_totalForce.setValue(0.0f, 0.0f, 0.0f); m_totalTorque.setValue(0.0f, 0.0f, 0.0f); m_linearDamping = 0f; m_angularDamping = 0.5f; m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold; m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold; m_optionalMotionState = constructionInfo.m_motionState; m_contactSolverType = 0; m_frictionSolverType = 0; m_additionalDamping = constructionInfo.m_additionalDamping; m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor; m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr; m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr; m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor; if (m_optionalMotionState != null) { m_optionalMotionState.getWorldTransform(out WorldTransform); } else { WorldTransform = constructionInfo.m_startWorldTransform; } m_interpolationWorldTransform = WorldTransform; m_interpolationLinearVelocity.setValue(0, 0, 0); m_interpolationAngularVelocity.setValue(0, 0, 0); //moved to btCollisionObject m_friction = constructionInfo.m_friction; m_restitution = constructionInfo.m_restitution; this.CollisionShape = constructionInfo.m_collisionShape; m_debugBodyId = uniqueId++; setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia); setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping); updateInertiaTensor(); RigidBodyFlag = RigidBodyFlags.BT_NONE; m_deltaLinearVelocity.setZero(); m_deltaAngularVelocity.setZero(); m_invMass = m_linearFactor * m_inverseMass; m_pushVelocity.setZero(); m_turnVelocity.setZero(); }
public RigidBodyConstructionInfo(float mass, IMotionState motionState, CollisionShape collisionShape) : this(mass, motionState, collisionShape, new IndexedVector3(0)) { }
public void SetMotionState(IMotionState state) { _motionState = state; }
public void SetState(IMotionState _state) { currentMotionState = _state; }
public Transport() { name = "Transport"; currentMotionState = null; }
public RigidBody(float mass, IMotionState motionState, CollisionShape collisionShape, btVector3 localInertia) { setupRigidBody(new RigidBodyConstructionInfo(mass, motionState, collisionShape, localInertia)); }
///btRigidBody constructor for backwards compatibility. ///To specify friction (etc) during rigid body construction, please use the other constructor (using btRigidBodyConstructionInfo) public RigidBody(float mass, IMotionState motionState, CollisionShape collisionShape, IndexedVector3 localInertia) { RigidBodyConstructionInfo cinfo = new RigidBodyConstructionInfo(mass,motionState,collisionShape,localInertia); SetupRigidBody(cinfo); }
public void SetMotionState(IMotionState motionState) { m_optionalMotionState = motionState; if (m_optionalMotionState != null) { motionState.GetWorldTransform(out m_worldTransform); } }
///setupRigidBody is only used internally by the constructor protected void SetupRigidBody(RigidBodyConstructionInfo constructionInfo) { m_internalType=CollisionObjectTypes.CO_RIGID_BODY; m_linearVelocity = IndexedVector3.Zero; m_angularVelocity = IndexedVector3.Zero; m_angularFactor = IndexedVector3.One; m_linearFactor = IndexedVector3.One; m_gravity = IndexedVector3.Zero; m_gravity_acceleration = IndexedVector3.Zero; m_totalForce = IndexedVector3.Zero; m_totalTorque = IndexedVector3.Zero; SetDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping); m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold; m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold; m_optionalMotionState = constructionInfo.m_motionState; m_contactSolverType = 0; m_frictionSolverType = 0; m_additionalDamping = constructionInfo.m_additionalDamping; m_additionalDampingFactor = constructionInfo.m_additionalDampingFactor; m_additionalLinearDampingThresholdSqr = constructionInfo.m_additionalLinearDampingThresholdSqr; m_additionalAngularDampingThresholdSqr = constructionInfo.m_additionalAngularDampingThresholdSqr; m_additionalAngularDampingFactor = constructionInfo.m_additionalAngularDampingFactor; if (m_optionalMotionState != null) { m_optionalMotionState.GetWorldTransform(out m_worldTransform); } else { SetWorldTransform(ref constructionInfo.m_startWorldTransform); } m_interpolationWorldTransform = m_worldTransform; m_interpolationLinearVelocity = IndexedVector3.Zero; m_interpolationAngularVelocity = IndexedVector3.Zero; //moved to btCollisionObject m_friction = constructionInfo.m_friction; m_restitution = constructionInfo.m_restitution; SetCollisionShape( constructionInfo.m_collisionShape ); m_debugBodyId = uniqueId++; SetMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia); UpdateInertiaTensor(); m_rigidbodyFlags = RigidBodyFlags.BT_NONE; m_constraintRefs = new List<TypedConstraint>(); m_deltaLinearVelocity = IndexedVector3.Zero; m_deltaAngularVelocity = IndexedVector3.Zero; m_invMass = m_inverseMass * m_linearFactor; m_pushVelocity = IndexedVector3.Zero; m_turnVelocity = IndexedVector3.Zero; }
public RigidBodyConstructionInfo(float mass, IMotionState motionState, CollisionShape collisionShape): this(mass,motionState,collisionShape,new IndexedVector3(0)) { }