home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter52 / l52-6.c < prev    next >
C/C++ Source or Header  |  1997-06-18  |  1KB  |  33 lines

  1. /* Rotates and moves a polygon-based object around the three axes.
  2.    Movement is implemented only along the Z axis currently.
  3. Tested with Borland C++ 4.02 in small model by Jim Mischel 12/16/94.
  4. */
  5.  
  6. #include "polygon.h"
  7.  
  8. void RotateAndMovePObject(PObject * ObjectToMove)
  9. {
  10.    if (--ObjectToMove->RDelayCount == 0) {   /* rotate */
  11.       ObjectToMove->RDelayCount = ObjectToMove->RDelayCountBase;
  12.       if (ObjectToMove->Rotate.RotateX != 0.0)
  13.          AppendRotationX(ObjectToMove->XformToWorld,
  14.                ObjectToMove->Rotate.RotateX);
  15.       if (ObjectToMove->Rotate.RotateY != 0.0)
  16.          AppendRotationY(ObjectToMove->XformToWorld,
  17.                ObjectToMove->Rotate.RotateY);
  18.       if (ObjectToMove->Rotate.RotateZ != 0.0)
  19.          AppendRotationZ(ObjectToMove->XformToWorld,
  20.                ObjectToMove->Rotate.RotateZ);
  21.       ObjectToMove->RecalcXform = 1;
  22.    }
  23.    /* Move in Z, checking for bouncing and stopping */
  24.    if (--ObjectToMove->MDelayCount == 0) {
  25.       ObjectToMove->MDelayCount = ObjectToMove->MDelayCountBase;
  26.       ObjectToMove->XformToWorld[2][3] += ObjectToMove->Move.MoveZ;
  27.       if (ObjectToMove->XformToWorld[2][3]>ObjectToMove->Move.MaxZ)
  28.          ObjectToMove->Move.MoveZ = 0; /* stop if close enough */
  29.       ObjectToMove->RecalcXform = 1;
  30.    }
  31. }
  32.  
  33.