コード例 #1
0
        //public override Mat3 GetInertiaTensor()
        //{
        //   if( Static )
        //      return Mat3.Identity;
        //   if( bodyID == dBodyID.Zero )
        //      return Mat3.Zero;

        //   Ode.dMass mass = new Ode.dMass();
        //   Ode.dBodyGetMass( bodyID, ref mass );

        //   return new Mat3(
        //      mass.I.M00, mass.I.M01, mass.I.M02,
        //      mass.I.M10, mass.I.M11, mass.I.M12,
        //      mass.I.M20, mass.I.M21, mass.I.M22 );
        //}

        protected override void ApplyForce(ForceType type, ref Vec3 vector, ref Vec3 pos)
        {
            if (bodyID == dBodyID.Zero)
            {
                return;
            }

            Ode.dBodyEnable(bodyID);

            switch (type)
            {
            case ForceType.Local:
                Ode.dBodyAddRelForce(bodyID, vector.X, vector.Y, vector.Z);
                break;

            case ForceType.Global:
                Ode.dBodyAddForce(bodyID, vector.X, vector.Y, vector.Z);
                break;

            case ForceType.LocalTorque:
                Ode.dBodyAddRelTorque(bodyID, vector.X, vector.Y, vector.Z);
                break;

            case ForceType.GlobalTorque:
                Ode.dBodyAddTorque(bodyID, vector.X, vector.Y, vector.Z);
                break;

            case ForceType.LocalAtLocalPos:
                Ode.dBodyAddRelForceAtRelPos(bodyID, vector.X, vector.Y, vector.Z, pos.X, pos.Y, pos.Z);
                break;

            case ForceType.LocalAtGlobalPos:
                Ode.dBodyAddRelForceAtPos(bodyID, vector.X, vector.Y, vector.Z, pos.X, pos.Y, pos.Z);
                break;

            case ForceType.GlobalAtLocalPos:
                Ode.dBodyAddForceAtRelPos(bodyID, vector.X, vector.Y, vector.Z, pos.X, pos.Y, pos.Z);
                break;

            case ForceType.GlobalAtGlobalPos:
                Ode.dBodyAddForceAtPos(bodyID, vector.X, vector.Y, vector.Z, pos.X, pos.Y, pos.Z);
                break;
            }

            //// Invalidate the "freely-spinning" parameter.
            //freelySpinning = false;
        }