コード例 #1
0
        protected override Body[] OnVolumeCast(Capsule capsule, int contactGroup)
        {
            Vec3 center;

            capsule.GetCenter(out center);
            float length = capsule.GetLength();
            Vec3  direction;

            capsule.GetDirection(out direction);

            dGeomID volumeCastGeomID = Ode.dCreateCapsule(rootSpaceID, capsule.Radius, length);

            Quat rotation = Quat.FromDirectionZAxisUp(direction);

            Mat3 rot;

            rotation.ToMat3(out rot);

            Mat3 rotationMat;

            Mat3.FromRotateByY(MathFunctions.PI / 2, out rotationMat);
            Mat3 mat3;

            Mat3.Multiply(ref rot, ref rotationMat, out mat3);

            Ode.dMatrix3 odeMat3;
            Convert.ToODE(ref mat3, out odeMat3);
            Ode.dGeomSetRotation(volumeCastGeomID, ref odeMat3);
            Ode.dGeomSetPosition(volumeCastGeomID, center.X, center.Y, center.Z);

            Body[] result = DoVolumeCastGeneral(volumeCastGeomID, contactGroup);

            Ode.dGeomDestroy(volumeCastGeomID);

            return(result);
        }