home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / BSP Tree Demo / include / view.h < prev   
Encoding:
Text File  |  1995-04-05  |  3.7 KB  |  65 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    view.h
  3. //    Date:                    9/18/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a view of space
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include    "gworld.h"
  11. #include    "interface.h"
  12. #include    "matrix_3d.h"
  13. #include    "point_2d.h"
  14. #include    "polyptr_3d.h"
  15. #include    "camera_3d.h"
  16.  
  17. #ifndef VIEW
  18. #define VIEW
  19.  
  20. //------------------------------------------------------------------------------
  21. //    classes
  22. //------------------------------------------------------------------------------
  23. class    view : public gworld                                                                                                            //    view class
  24. {                                                                                                                                                                //    begin view definition
  25.     private:                                                                                                                                            //    private interface
  26.                 point_2d        dctovdc (const Point &p) const;                                                            //    map screen coordinates to virtual device coordinates
  27.                 Point        vdctodc (const point_2d &p) const;                                                            //    map virtual device coordinates to screen coordinates
  28.     protected:                                                                                                                                        //    protected interface
  29.                 camera        cam;                                                                                                                    //    camera_3d
  30.                 bool            cull;                                                                                                                    //    flag to control backface culling
  31.                 interface    *gui;                                                                                                                    //    pointer to the interface controller
  32.                 matrix_3d    sum,                                                                                                                    //    the sum of the interface transformations
  33.                                     transformation,                                                                                                //    the transformation for points
  34.                                     inverse,                                                                                                            //    the inverse of the current transformation matrix_3d
  35.                                     viewing;                                                                                                            //    the final viewing transformation
  36.                 real            xsize, ysize, aspect;                                                                                    //    parameters for mapping
  37.                 point_3d    eye;                                                                                                                    //    eye point_3d
  38.     public:                                                                                                                                                //    public interface
  39. static    view            *current;                                                                                                            //    static value for the current view
  40.                 view (window *w);                                                                                                                //    constructor
  41. virtual    ~view (void);                                                                                                                        //    destructor
  42.                 void            AddInterface (interface *i);                                                                    //    add an interface to the view
  43.                 void            MoveToPt (const point_2d &pt) const;                                                    //    move to a point_2d
  44.                 void            LineToPt (const point_2d &pt) const;                                                    //    draw a line to a point_2d
  45.                 void            Circle (const point_2d &a, const point_2d &b) const;                    //    draw a circle defined by the rectangle 'ab'
  46.                 void            CrossHair (const point_2d &p) const;                                                    //    draw a crosshair at the specified location
  47.                 void            DrawPolygon (polyptr poly);                                                                        //    draw a polygon (transformed by the camera_3d)
  48.                 void            DrawScene (void);                                                                                            //    draw the scene that this view is for
  49. virtual    void            HandleClick (EventRecord &event);                                                            //    handle mouse down/up
  50. virtual    void            Resize (EventRecord &event);                                                                    //    recompute sizing information from parent
  51. virtual    void            StartDrawing (gw_erase e = ERASE);                                                        //    lock down the gworld and set the port appropriately
  52. virtual    void            StopDrawing (gw_update u = UPDATE);                                                        //    unlock the gworld and reset the port
  53. };                                                                                                                                                            //    end view class definition
  54.  
  55. //------------------------------------------------------------------------------
  56. //    inlines
  57. //------------------------------------------------------------------------------
  58. inline    void        view::AddInterface (interface *i)                                                                //    add an interface to the view
  59. {                                                                                                                                                                //    begin
  60.     gui = i;                                                                                                                                            //    store the interface
  61. }                                                                                                                                                                //    end
  62.  
  63. //------------------------------------------------------------------------------
  64.  
  65. #endif //VIEW