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

  1.                                                // Example: 109 from Library Reference
  2. #include "..\3D-Ware\dddware.h"
  3. short    Xpos=0, Ypos=0, Zpos=800;
  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, x, y;
  8. char     Semaphores, palette_color;
  9.  
  10. void     setup(void);                          // Declare the function prototype.
  11.  
  12. short  main(void)
  13. {
  14.   dddInitAll();                                // Initialise 3D-Ware.
  15.   dddLoadColors("EXAMPLE.COL");                // Load in the color palette called 'example.col' to 'standardpal'.
  16.   dddSetPal(dddstandardpal);                   // Set up the palette.
  17.   ShapeHandle = (dddShapeLoad("EXAMPLE.3D"));  // Load the .3D data file.
  18.   dddSetViewPos16(VXpos,VYpos,VZpos);          // Set the viewers angles in the 3D engine.
  19.   dddScreenSwap();                             // Setup the screen swapping.
  20.   setup();                                     // Setup the first screen buffer.
  21.   setup();                                                  // Setup the second screen buffer.
  22.   while  (!dddkeycode)                         // Loop until a key is pressed.
  23.   {
  24.     dddSetClipArea(50,149,50,149);             // Set up clipping boundaries for left box.
  25.     dddSetCenter(100,100,149,149);             // Set centre for left box.
  26.     dddBox(0,50,50,149,149);                   // Just clear the area we need to use.
  27.     dddClearObjects();                         // Clear the viewing table.
  28.     Xangle += 0x80;                            // Rotate the shape in the Y plane.
  29.     Yangle += 0x200;                           // Rotate the shape in the Y plane.
  30.     Zangle += 0x100;                           // Rotate the shape in the Z plane.
  31.     dddSetViewAngles(VXangle,VYangle,VZangle); // Set the viewers angles.
  32.     dddInsertObject16(DRW_MOBILE,ShapeHandle,Semaphores,Xpos,Ypos,Zpos,Xangle,Yangle,Zangle);
  33.                                                // Insert an object to be rendered.
  34.     dddDrawObjects();                          // Render all 3D objects we have inserted.
  35.                                                // The next few lines copy the block of image data that
  36.                                                // has just been rendered to the right hand side of the
  37.                                                // screen.
  38.     for  (y=50; y<150; y++)
  39.     {
  40.       for  (x=50; x<150; x++)
  41.       {
  42.         palette_color = dddReadPix(x,y);       // Read the color of the pixel.
  43.         dddPlot(palette_color,x+111,y);        // Plot a pixel in the same color.
  44.       }
  45.     }
  46.     dddScreenSwap();                           // Flip the real screen and the dummy screen.
  47.   }
  48.   dddRestoreAll();
  49.   return 0;                                    // Bye.
  50. }
  51. void  setup(void)
  52. {
  53.   dddPrint7(2,78,40,"PRESS ANY KEY TO EXIT.");
  54.                                                // Draw the left box boundaries first.
  55.   dddLineBox(234,49,49,150,150);
  56.                                                // Draw the right box boundaries last.
  57.   dddLineBox(234,160,49,261,150);
  58.  
  59.   dddScreenSwap();                             // Flip the real screen and the dummy screen.
  60. }
  61.