home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Madness / VRMAD96_ONE.ISO / virtek / libex / libex002.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  1KB  |  23 lines

  1.                                     // Example: 002 from Library Reference
  2. #include "..\3D-Ware\dddware.h"
  3. #include <stdio.h>
  4. short    angle[]={0,0};
  5. long     object[]={0,0,0};
  6. long     target[]={1000,0,0};       // X pos of target a little to the right.
  7. float    yaw, pitch;
  8. short  main(void)
  9. {
  10.   dddAlign16(angle,target,object);  // Find the angles to point object at the target
  11.   pitch=angle[0];                   // Get a floating point copy of xangle.
  12.   pitch=(long)(pitch/(0xffc0/360)); // Calculate the real Degrees of the 3D-Ware degrees.
  13.   pitch=(int)(pitch+360)%360;       // Make sure in the range 0-359.
  14.   yaw=angle[1];
  15.   yaw=(long)(yaw/(0xffc0/360));
  16.   yaw=(int)(yaw+360)%360;
  17.                                     // NOTE. 0-360 degrees may not be absolutely accurate
  18.                                     // due to rounding  errors.
  19.   printf("\n\nThe angles returned are :- 0x%X (xangle/pitch %.0f°)    0x%X (yangle/yaw %.0f°)\n\n",angle[0],
  20.   pitch, angle[1], yaw);
  21.   return 0;
  22. }
  23.