home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Jeux / demos / crystalPPC.lha / viewpoly.cpp < prev    next >
C/C++ Source or Header  |  1998-02-05  |  1KB  |  51 lines

  1. #include <math.h>
  2. #include <time.h>
  3. #include "system.h"
  4.  
  5. #ifndef DEF_H
  6. #include "def.h"
  7. #endif
  8.  
  9. #ifndef VIEWPOLY_H
  10. #include "viewpoly.h"
  11. #endif
  12.  
  13. //---------------------------------------------------------------------------
  14.  
  15. ViewPolygon::ViewPolygon (int num)
  16. {
  17.   max_vertices = num;
  18.   bbox.start_bounding_box ();
  19.   vertices = new Vector2 [num];
  20.   num_vertices = 0;
  21. }
  22.  
  23. ViewPolygon::~ViewPolygon ()
  24. {
  25.   if (vertices) delete [] vertices;
  26. }
  27.  
  28. void ViewPolygon::add_vertex (float x, float y)
  29. {
  30.   vertices[num_vertices].x = x;
  31.   vertices[num_vertices].y = y;
  32.   num_vertices++;
  33.   bbox.add_bounding_vertex (x, y);
  34. }
  35.  
  36. void ViewPolygon::dump (char* name)
  37. {
  38.   MSG (("Dump view '%s':\n", name));
  39.   MSG (("    num_vertices=%d  max_vertices=%d\n", num_vertices, max_vertices));
  40.   MSG (("    Bounding box: ")); bbox.dump (); MSG (("\n"));
  41.   int i;
  42.   for (i = 0 ; i < num_vertices ; i++)
  43.     MSG (("        vector2[%d]: (%2.2f,%2.2f)\n",
  44.         i,
  45.         vertices[i].x,
  46.         vertices[i].y));
  47.   fflush (stdout);
  48. }
  49.  
  50. //---------------------------------------------------------------------------
  51.