Esempio n. 1
0
        /// <summary>
        /// Given a vector expressed in the body coordinate system (x,y,z), rotate it to the world coordinate system (result).
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public Vector3 BodyVectorToWorld(Vector3 vec)
        {
            Tao.Ode.Ode.dVector3 temp = new Tao.Ode.Ode.dVector3();

            Tao.Ode.Ode.dBodyVectorToWorld(this, vec.X, vec.Y, vec.Z, ref temp);

            return(temp);
        }
Esempio n. 2
0
        public void BuildSingle(Vector3[] Vertices, int VertexStride, int VertexCount, int[] Indices, int IndexCount, int TriStride)
        {
            if (Vertices == null)
            {
                return;
            }

            if (Vertices.Length == 0)
            {
                return;
            }

            Tao.Ode.Ode.dVector3[] buf = new Tao.Ode.Ode.dVector3[VertexCount];

            for (int i = 0; i < VertexCount; i++)
            {
                buf[i] = Vertices[i];
            }

            Tao.Ode.Ode.dGeomTriMeshDataBuildSingle(this, buf, VertexStride, VertexCount, Indices, IndexCount, TriStride);
        }
Esempio n. 3
0
        public override JointAxis GetAxis(int axisNum)
        {
            // Silently ignore invalid axes.
            if (axisNum < 0 || axisNum >= numAxes)
            {
                return(new JointAxis());
            }

            // First we need to get an updated direction vector from ODE.
            Tao.Ode.Ode.dVector3 direction = new Tao.Ode.Ode.dVector3();

            switch (data.Type)
            {
            case JointType.Hinge:
                Tao.Ode.Ode.dJointGetHingeAxis(jointID, ref direction);
                break;

            case JointType.Universal:
                if (0 == axisNum)
                {
                    Tao.Ode.Ode.dJointGetUniversalAxis1(jointID, ref direction);
                }
                else
                {
                    Tao.Ode.Ode.dJointGetUniversalAxis2(jointID, ref direction);
                }
                break;

            case JointType.Ball:
                if (0 == axisNum)
                {
                    Tao.Ode.Ode.dJointGetAMotorAxis(aMotorID, 0, ref direction);
                }
                else if (1 == axisNum)
                {
                    Tao.Ode.Ode.dJointGetAMotorAxis(aMotorID, 1, ref direction);
                }
                else
                {
                    Tao.Ode.Ode.dJointGetAMotorAxis(aMotorID, 2, ref direction);
                }
                break;

            case JointType.Slider:
                Tao.Ode.Ode.dJointGetSliderAxis(jointID, ref direction);
                break;

            case JointType.Wheel:
                if (0 == axisNum)
                {
                    Tao.Ode.Ode.dJointGetHinge2Axis1(jointID, ref direction);
                }
                else
                {
                    Tao.Ode.Ode.dJointGetHinge2Axis2(jointID, ref direction);
                }
                break;

            case JointType.Fixed:
                // Fixed Joints don't have any axes.
                break;

            default:
                throw new PhysicsException("Unknown bug");
                //break;
            }

            JointAxis axis = data.Axis[axisNum];

            // All data in this JointAxis is valid except for the direction
            // vector.
            axis.Direction = direction;

            return(axis);
        }
Esempio n. 4
0
 static internal Vector3 FromOdeVector3(Tao.Ode.Ode.dVector3 vector)
 {
     return(new Vector3(vector.X, vector.Y, vector.Z));
 }
Esempio n. 5
0
 /// <summary>
 /// Take a point on a body (px,py,pz) and return that point's velocity in body-relative coordinates.
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public Vector3 GetRelPointVel(Vector3 p)
 {
     Tao.Ode.Ode.dVector3 result = new Tao.Ode.Ode.dVector3();
     Tao.Ode.Ode.dBodyGetRelPointVel(this, p.X, p.Y, p.Z, ref result);
     return(result);
 }