Exemplo n.º 1
0
        /// <summary>
        /// ワールドのupdateから呼ばれる
        /// </summary>
        public void updateToPhisics(float timeStep)
        {
            lock (this.actor)
            {
                if (motionState != null)
                {
                    btTransform world;

                    // MMDXのパーツ座標を取得する
                    motionState.getWorldTransform(out world);

                    // 物理にモデルの位置を適用する
                    actor.GlobalPose = world.getMatrix();

                    // Kinamticならそのまま使う
                    if (kinematic_mode)
                    {
                        Matrix pre = world.getMatrix();
                    }

                    // 物理を適用する
                    world.setMatrix(actor.GlobalPose);

                    // 適用結果をパーツ座標に反映する
                    motionState.setWorldTransform(world);
                }
            }
        }
Exemplo n.º 2
0
        /// <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();
        }
Exemplo n.º 3
0
        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();

        }