示例#1
0
        private int SPHERERESOLUTION = 20;   // Number of lines to build up spheres from

        /// <summary>
        /// Draws the Joint
        /// </summary>
        /// <param name="joint">The joint</param>
        public void Draw(StroMoHab_Objects.Objects.Joint joint)
        {
            Gl.glTranslatef(joint.xCoordinate / SCALLINGFACTOR, joint.yCoordinate / SCALLINGFACTOR, -joint.zCoordinate / SCALLINGFACTOR);
            Gl.glScalef(40f / SCALLINGFACTOR, 40f / SCALLINGFACTOR, 40f / SCALLINGFACTOR);
            SetDrawingMode(true);
            DrawUnitSphere();
            SetDrawingMode(false);
            DrawUnitSphere();
            Gl.glScalef(1 / 40f / SCALLINGFACTOR, 1 / 40f / SCALLINGFACTOR, 1 / 40f / SCALLINGFACTOR);
            Gl.glTranslatef(-joint.xCoordinate / SCALLINGFACTOR, -joint.yCoordinate / SCALLINGFACTOR, joint.zCoordinate / SCALLINGFACTOR);
            SetDrawingMode(true);
        }
示例#2
0
 /// <summary>
 /// Draws the body part based on the trackable
 /// </summary>
 /// <param name="trackable">The trackable</param>
 /// <param name="joint1">The first joint</param>
 /// <param name="joint2">The second joint</param>
 public virtual void Draw(StroMoHab_Objects.Objects.Trackable trackable, StroMoHab_Objects.Objects.Joint joint1, StroMoHab_Objects.Objects.Joint joint2)
 {
     //CalculateScallingAndOffsets(trackable, joint1, joint2);
     CalculateBoundingBox(trackable);
     MoveIn(trackable);
     ScaleIn();
     SetDrawingMode(true);
     DrawBodyPart();
     SetDrawingMode(false);
     DrawBodyPart();
     ScaleOut();
     MoveOut(trackable);
     SetDrawingMode(true);
 }
示例#3
0
        /// <summary>
        /// Calculates the scalling and offset values for the trackable which determin its size and position
        /// </summary>
        /// <param name="trackable"></param>
        /// <param name="joint1"></param>
        /// <param name="joint2"></param>
        protected override void CalculateScallingAndOffsets(StroMoHab_Objects.Objects.Trackable trackable, StroMoHab_Objects.Objects.Joint joint1, StroMoHab_Objects.Objects.Joint joint2)
        {
            if (joint1.Exists)
            {
                // Set up matricies
                StroMoHab_Matrix.PointMatrix    joint1PointVector     = new StroMoHab_Matrix.PointMatrix(joint1.xCoordinate - trackable.xCoordinate, joint1.yCoordinate - trackable.yCoordinate, joint1.zCoordinate - trackable.zCoordinate);
                StroMoHab_Matrix.RotationMatrix rotationMatrixReverse = new StroMoHab_Matrix.RotationMatrix(-Math.PI * trackable.Pitch / 180, -Math.PI * trackable.Yaw / 180, -Math.PI * trackable.Roll / 180);

                // Rotate the joint
                StroMoHab_Matrix.PointMatrix joint1NewPointVector = StroMoHab_Matrix.Operations.Rotate(joint1PointVector, rotationMatrixReverse);

                // Calculate the scaling and offsets based on the vector from the trackable to the joint
                scaleZ = (float)joint1NewPointVector.ZCoordinate / SCALLINGFACTOR;
                scaleY = (float)joint1NewPointVector.YCoordinate / SCALLINGFACTOR;

                // Protect against really small limbs
                if (joint1NewPointVector.ZCoordinate < 100)
                {
                    scaleZ = Math.Abs((float)100 / SCALLINGFACTOR);
                }

                offsetY = -scaleY;
            }
        }
示例#4
0
        /// <summary>
        /// Calculates the scalling and offset values for the trackable which determin its size and position
        /// </summary>
        /// <param name="trackable"></param>
        /// <param name="joint1"></param>
        /// <param name="joint2"></param>
        protected override void CalculateScallingAndOffsets(StroMoHab_Objects.Objects.Trackable trackable, StroMoHab_Objects.Objects.Joint joint1, StroMoHab_Objects.Objects.Joint joint2)
        {
            if (joint1.Exists && joint2.Exists == false)
            {
                // Set up matricies
                StroMoHab_Matrix.PointMatrix    joint1PointVector     = new StroMoHab_Matrix.PointMatrix(joint1.xCoordinate - trackable.xCoordinate, joint1.yCoordinate - trackable.yCoordinate, joint1.zCoordinate - trackable.zCoordinate);
                StroMoHab_Matrix.RotationMatrix rotationMatrixReverse = new StroMoHab_Matrix.RotationMatrix(-Math.PI * trackable.Pitch / 180, -Math.PI * trackable.Yaw / 180, -Math.PI * trackable.Roll / 180);

                // Rotate the joint
                StroMoHab_Matrix.PointMatrix joint1NewPointVector = StroMoHab_Matrix.Operations.Rotate(joint1PointVector, rotationMatrixReverse);

                // Calculate the scaling and offsets based on the vector from the trackable to the joint
                scaleZ = (float)joint1NewPointVector.ZCoordinate / SCALLINGFACTOR;
                scaleY = (float)joint1NewPointVector.YCoordinate / SCALLINGFACTOR;

                if (joint1NewPointVector.ZCoordinate < 150)
                {
                    scaleZ = Math.Abs((float)150 / SCALLINGFACTOR);
                }
                if (joint1NewPointVector.YCoordinate < 30)
                {
                    scaleY = Math.Abs((float)30 / SCALLINGFACTOR);
                }


                offsetY = -scaleY;
            }
            else if (joint2.Exists && joint1.Exists == false)
            {
                // Set up matricies
                StroMoHab_Matrix.PointMatrix    joint2PointVector     = new StroMoHab_Matrix.PointMatrix(joint2.xCoordinate - trackable.xCoordinate, joint2.yCoordinate - trackable.yCoordinate, joint2.zCoordinate - trackable.zCoordinate);
                StroMoHab_Matrix.RotationMatrix rotationMatrixReverse = new StroMoHab_Matrix.RotationMatrix(-Math.PI * trackable.Pitch / 180, -Math.PI * trackable.Yaw / 180, -Math.PI * trackable.Roll / 180);

                // Rotate the joint
                StroMoHab_Matrix.PointMatrix joint2NewPointVector = StroMoHab_Matrix.Operations.Rotate(joint2PointVector, rotationMatrixReverse);


                // Calculate the scaling and offsets based on the vector from the trackable to the joint
                scaleZ = Math.Abs((float)joint2NewPointVector.ZCoordinate / SCALLINGFACTOR);
                scaleY = Math.Abs((float)joint2NewPointVector.YCoordinate / SCALLINGFACTOR);
                if (joint2NewPointVector.ZCoordinate < 150)
                {
                    scaleZ = Math.Abs((float)150 / SCALLINGFACTOR);
                }
                if (joint2NewPointVector.YCoordinate < 30)
                {
                    scaleY = Math.Abs((float)30 / SCALLINGFACTOR);
                }


                offsetY = -scaleY;
            }
            else if (joint1.Exists && joint2.Exists)
            {
                // Set up matricies
                StroMoHab_Matrix.PointMatrix    joint2PointVector     = new StroMoHab_Matrix.PointMatrix(joint2.xCoordinate - trackable.xCoordinate, joint2.yCoordinate - trackable.yCoordinate, joint2.zCoordinate - trackable.zCoordinate);
                StroMoHab_Matrix.RotationMatrix rotationMatrixReverse = new StroMoHab_Matrix.RotationMatrix(-Math.PI * trackable.Pitch / 180, -Math.PI * trackable.Yaw / 180, -Math.PI * trackable.Roll / 180);
                StroMoHab_Matrix.PointMatrix    joint1PointVector     = new StroMoHab_Matrix.PointMatrix(joint1.xCoordinate - trackable.xCoordinate, joint1.yCoordinate - trackable.yCoordinate, joint1.zCoordinate - trackable.zCoordinate);

                // Rotate the joint
                StroMoHab_Matrix.PointMatrix joint1NewPointVector = StroMoHab_Matrix.Operations.Rotate(joint1PointVector, rotationMatrixReverse);

                // Rotate the joint
                StroMoHab_Matrix.PointMatrix joint2NewPointVector = StroMoHab_Matrix.Operations.Rotate(joint2PointVector, rotationMatrixReverse);

                // Calculate the scaling and offsets based on the vector from the trackable to the joint
                //Half of the distance between the two joints
                scaleZ = (float)(Math.Abs(joint1NewPointVector.ZCoordinate) + Math.Abs(joint2NewPointVector.ZCoordinate) / 2) / SCALLINGFACTOR;
                if (scaleZ < Math.Abs((float)150 / SCALLINGFACTOR))
                {
                    scaleZ = Math.Abs((float)150 / SCALLINGFACTOR);
                }
                scaleY = Math.Abs((float)joint1NewPointVector.YCoordinate / SCALLINGFACTOR);


                offsetY = -scaleY;
            }
        }
示例#5
0
        /// <summary>
        /// Draws each Trackable in the list supplied
        /// If joint data is avaliable the limb will be scalled, otherwise it will be a generic size
        /// </summary>
        /// <param name="trackableList">The trackable list</param>
        /// <param name="jointList">The joint list</param>
        public void Draw(List <StroMoHab_Objects.Objects.Trackable> trackableList, List <StroMoHab_Objects.Objects.Joint> jointList)
        {
            //Clear the boundingbox list before it is updated
            boundingBoxList.Clear();

            // If the joint list doesn't have enough joints in it, generate som blank ones
            for (int j = jointList.Count; j < MAXNUMJOINTS + 1; j++)
            {
                StroMoHab_Objects.Objects.Joint joint;
                joint = new StroMoHab_Objects.Objects.Joint();
                jointList.Add(joint);
            }

            // Go through the trackable list and update (Draw) the opengl body parts for the trackables present using joint data if possible
            // add their data to the bounding box list
            foreach (StroMoHab_Objects.Objects.Trackable trackable in trackableList)
            {
                switch (trackable.ID)
                {
                case 1:     // Left Foot
                    leftFoot.Draw(trackable, jointList[0], null);
                    boundingBoxList.Add(leftFoot.CollisionModel);
                    break;

                case 2:     // Right Foot
                    rightFoot.Draw(trackable, jointList[1], null);
                    boundingBoxList.Add(rightFoot.CollisionModel);
                    break;

                case 3:     // Left Lower Leg
                    leftLowerLeg.Draw(trackable, jointList[2], jointList[0]);
                    boundingBoxList.Add(leftLowerLeg.CollisionModel);
                    break;

                case 4:     // Right Lower Leg
                    rightLowerLeg.Draw(trackable, jointList[3], jointList[1]);
                    boundingBoxList.Add(rightLowerLeg.CollisionModel);
                    break;

                case 5:     // Left Upper Leg
                    leftUpperLeg.Draw(trackable, null, jointList[2]);
                    boundingBoxList.Add(leftUpperLeg.CollisionModel);
                    break;

                case 6:     // Right Upper Leg
                    rightUpperLeg.Draw(trackable, null, jointList[3]);
                    boundingBoxList.Add(rightUpperLeg.CollisionModel);
                    break;
                } //Close switch
            }     //Close foreach

            // Draw the joints on the screen
            if (DRAWJOINTS)
            {
                int i = 0;
                foreach (StroMoHab_Objects.Objects.Joint joint in jointList)
                {
                    if (joint.Exists)
                    {
                        openGLJointList[i].Draw(joint);
                    }
                    i++;
                }
            }
        } //Close Method Draw
示例#6
0
 /// <summary>
 /// Implement code to calculate to size of the body part so that the unit shape can be scalled correctly
 /// and so it can be offset correctly based on connecting joint data
 /// </summary>
 /// <param name="trackable"></param>
 /// <param name="joint1"></param>
 /// <param name="joint2"></param>
 protected abstract void CalculateScallingAndOffsets(StroMoHab_Objects.Objects.Trackable trackable, StroMoHab_Objects.Objects.Joint joint1, StroMoHab_Objects.Objects.Joint joint2);
示例#7
0
        /// <summary>
        /// Draws each Trackable in the list supplied
        /// If joint data is avaliable the limb will be scalled, otherwise it will be a generic size
        /// </summary>
        /// <param name="trackableList">The trackable list</param>
        /// <param name="jointList">The joint list</param>
        public void Draw(List<StroMoHab_Objects.Objects.Trackable> trackableList, List<StroMoHab_Objects.Objects.Joint> jointList)
        {
            //Clear the boundingbox list before it is updated
            boundingBoxList.Clear();

            // If the joint list doesn't have enough joints in it, generate som blank ones
            for (int j = jointList.Count; j < MAXNUMJOINTS + 1; j++)
            {
                StroMoHab_Objects.Objects.Joint joint;
                joint = new StroMoHab_Objects.Objects.Joint();
                jointList.Add(joint);

            }

            // Go through the trackable list and update (Draw) the opengl body parts for the trackables present using joint data if possible
            // add their data to the bounding box list
            foreach (StroMoHab_Objects.Objects.Trackable trackable in trackableList)
            {                 
                switch (trackable.ID)
                { 
                    case 1: // Left Foot
                        leftFoot.Draw(trackable, jointList[0], null);
                        boundingBoxList.Add(leftFoot.CollisionModel);
                        break;
                    case 2: // Right Foot
                        rightFoot.Draw(trackable, jointList[1], null);
                        boundingBoxList.Add(rightFoot.CollisionModel);
                        break;
                        
                    case 3: // Left Lower Leg
                        leftLowerLeg.Draw(trackable, jointList[2], jointList[0]);
                        boundingBoxList.Add(leftLowerLeg.CollisionModel);
                        break;
                    case 4: // Right Lower Leg
                        rightLowerLeg.Draw(trackable, jointList[3], jointList[1]);
                        boundingBoxList.Add(rightLowerLeg.CollisionModel);
                        break;
                    case 5: // Left Upper Leg
                        leftUpperLeg.Draw(trackable, null, jointList[2]);
                        boundingBoxList.Add(leftUpperLeg.CollisionModel);
                        break;
                    case 6: // Right Upper Leg
                        rightUpperLeg.Draw(trackable, null, jointList[3]);
                        boundingBoxList.Add(rightUpperLeg.CollisionModel);
                        break;
                         
                       
                }//Close switch          
            }//Close foreach

            // Draw the joints on the screen
            if(DRAWJOINTS)
            {
                int i=0;
                foreach (StroMoHab_Objects.Objects.Joint joint in jointList)
                {

                    if (joint.Exists)
                        openGLJointList[i].Draw(joint);
                    i++;
                }
            }

        }//Close Method Draw