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

  1.                                                // Example: 132 from Library Reference
  2. #include "..\3D-Ware\dddware.h"
  3. short    Xpos=0, Ypos=0, Zpos=400;
  4. short    Xangle=0, Yangle=0, Zangle=0;
  5. short    VXpos=0, VYpos=0, VZpos=0;
  6. short    VXangle=0, VYangle=0, VZangle=0;
  7. short    ShapeHandle;
  8. char     Semaphores;
  9. short    clipx=160, clipy=100;
  10. short  main(void)
  11. {
  12.   dddInitAll();
  13.   ShapeHandle = (dddShapeLoad("EXAMPLE.3D"));  // Load the .3D data file.
  14.   VXangle = VYangle = VZangle = 0;             // Set viewers angles to 0,0,0
  15.   VXpos = VYpos = VZpos = 0;                   // Set viewer to centre of 3D world scene.
  16.   dddSetViewPos16(VXpos,VYpos,VZpos);          // Set the viewers angles in the 3D engine.
  17.   dddSetViewAngles(VXangle,VYangle,VZangle);   // Set the viewers position in the 3D engine.
  18.   dddSetClipArea(0,319,0,199);                 // Set up clipping boundaries.
  19.   while  (dddkeycode!=_ESC)
  20.   {
  21.   dddCls();
  22.  
  23.   if (dddkeypressed[ _DN_ARROW ])
  24.   {
  25.       if (clipy<100)
  26.       {
  27.          clipy++;
  28.       }
  29.    }
  30.    if (dddkeypressed[ _UP_ARROW ])
  31.    {
  32.       if (clipy>2)
  33.       {
  34.          clipy--;
  35.       }
  36.    }
  37.  
  38.    if (dddkeypressed[ _RT_ARROW ])
  39.    {
  40.       if (clipx<160)
  41.       {
  42.          clipx++;
  43.       }
  44.    }
  45.    if (dddkeypressed[ _LF_ARROW ])
  46.    {
  47.       if (clipx>2)
  48.       {
  49.          clipx--;
  50.       }
  51.    }
  52.     dddSetClipArea(160-clipx,159+clipx,100-clipy,99+clipy);
  53.                                                // Set up clipping boundaries.
  54.     dddFillClipArea(244);
  55.  
  56.     dddSetViewAngles(VXangle,VYangle,VZangle); // Set the viewers angles.
  57.     dddClearObjects();                         // Clear the viewing table.
  58.     Yangle += 0x200;                           // Rotate the shape in the Y plane.
  59.     Zangle += 0x200;                           // Rotate the shape in the Z plane.
  60.     dddInsertObject16(DRW_MOBILE,ShapeHandle,Semaphores,Xpos,Ypos,Zpos,Xangle,Yangle,Zangle);
  61.                                                // Insert on object to be rendered.
  62.     dddDrawObjects();                          // Render all 3D objects we have inserted.
  63.     dddPrint7(2,0,0,"USE CURSORS KEYS");
  64.     dddScreenSwap();                           // Flip the real screen and the dummy screen.
  65.   }
  66.   dddRestoreAll();
  67.   return 0;                                    // Bye.
  68. }
  69.