Author Topic: OpenGl moving 3d models again  (Read 1982 times)

Fordcars123

  • Guest
OpenGl moving 3d models again
« on: February 17, 2012, 09:51:03 PM »
Ahhhh! I'm going nuts! I'm still on the same problem. I'm trying to move 3D models using opengl with Pangea's ultimate programming book. I'm using the chapter 13 sample code. I'm trying to modify the code for rotating the models. Here is a part of my code for moving models: static void MoveObjects(void)
{
   static   OGLPoint3D   raptCoord = {0,0,10};
   static   OGLPoint3D   lookAtPt   = {0,0,0};
   static   OGLVector3D   upVec      = {0,1,0};
   static   float      rot         = 0;
   static OGLPoint3D raptorCoord   = {0,0,0};
   OGLMatrix4x4   moveMatrix;
   MOMatrixObject   *matrixObj;
   
   void glMatrixMode(   GLenum     mode);

   
   void glTranslated(   GLdouble     x,
                 GLdouble     y,
                 GLdouble     z);
   void glTranslatef(   GLfloat     x,
                 GLfloat     y,
                 GLfloat     z);
   
   
   /**********************************************/
   /* CHECK HID DEVICE VALUES FOR MOTION CONTROL */
   /**********************************************/
   
   /* SEE IF A FORWARD BUTTON WAS PRESSED */
   
   if (gControlNeeds[kNeed_Forward_Button].value != 0)
   {
      matrixObj = (MOMatrixObject *)gRaptorObject->objectData.groupContents[0];      // matrix object is 1st object in the base group
      
      OGLMatrix4x4_SetTranslate(&moveMatrix, 3.0 * gOneOverFramesPerSecond);
      
      OGLMatrix4x4_Multiply(&moveMatrix, &matrixObj->matrix, &matrixObj->matrix);
   }
   
   
   
      
   /* SEE IF BACKWARD BUTTON WAS PRESSED */
   else
      if (gControlNeeds[kNeed_Backward_Button].value != 0)
      {
         glPushMatrix();
         glTranslatef(0.0f, -0.5f, 0.0f);
         glPopMatrix();

      }
   
   /* SEE IF TURN LEFT BUTTON WAS PRESSED */
   
   if (gControlNeeds[kNeed_TurnLeft_Button].value != 0)
   {
      matrixObj = (MOMatrixObject *)gRaptorObject->objectData.groupContents[0];      // matrix object is 1st object in the base group
      
      raptorCoord.x += gOneOverFramesPerSecond * 1.0f;
      
      OGLMatrix4x4_Multiply(&moveMatrix, &matrixObj->matrix, &matrixObj->matrix);
   }
   /* SEE IF TURN RIGHT BUTTON WAS PRESSED */
   else
      if (gControlNeeds[kNeed_TurnRight_Button].value != 0)
      {
         matrixObj = (MOMatrixObject *)gRaptorObject->objectData.groupContents[0];      // matrix object is 1st object in the base group
         
         glPushMatrix();
         glRotatef(90.0f, 0.0f, 1.0f, 0.0f); // Rotate 90 Degrees
         glPopMatrix();
         
         
      }

   }
   




#pragma mark -

For each arrow on the keyboard, I have a different code for trying things out.

It would be great if someone helped me.

You ROCK Pangea! I have all your games except Enigmo 2 full version and a few iPhone versions.