Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Projector.h
Go to the documentation of this file.
1 /* Project nGenEx
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: nGenEx.lib
6  FILE: Projector.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  3D Projection Camera class
13 */
14 
15 #ifndef Projector_h
16 #define Projector_h
17 
18 #include "Geometry.h"
19 #include "Window.h"
20 #include "Camera.h"
21 #include "Polygon.h"
22 
23 // +--------------------------------------------------------------------+
24 
25 class Projector
26 {
27 public:
28  Projector(Window* win, Camera* cam);
29  virtual ~Projector();
30 
31  // Operations:
32  virtual void UseWindow(Window* win);
33  virtual void UseCamera(Camera* cam);
34  virtual void SetDepthScale(float scale);
35  virtual double GetDepthScale() const;
36  virtual void SetFieldOfView(double fov);
37  virtual double GetFieldOfView() const;
38  virtual int SetInfinite(int i);
39  virtual void StartFrame();
40 
41  // accessor:
42  Point Pos() const { return camera->Pos(); }
43  Point vrt() { return camera->vrt(); }
44  Point vup() { return camera->vup(); }
45  Point vpn() { return camera->vpn(); }
46  const Matrix& Orientation() const { return camera->Orientation(); }
47 
48  double XAngle() const { return xangle; }
49  double YAngle() const { return yangle; }
50 
51  bool IsOrthogonal() const { return orthogonal; }
52  void SetOrthogonal(bool o) { orthogonal = o; }
53 
54  // projection and clipping geometry:
55  virtual void Transform(Vec3& vec) const;
56  virtual void Transform(Point& point) const;
57 
58  virtual void Project(Vec3& vec, bool clamp=true) const;
59  virtual void Project(Point& point, bool clamp=true) const;
60  virtual void ProjectRect(Point& origin, double& w, double& h) const;
61 
62  virtual float ProjectRadius(const Vec3& vec, float radius) const;
63 
64  virtual void Unproject(Point& point) const;
65  int IsVisible(const Vec3& v, float radius) const;
66  int IsBoxVisible(const Point* p) const;
67 
68  float ApparentRadius(const Vec3& v, float radius) const;
69 
71  virtual void SetViewSpace() { frustum_planes = view_planes; }
72 
74 
75  void SetUpFrustum();
76  void ViewToWorld(Point& pin, Point& pout);
77  void ViewToWorld(Vec3& vin, Vec3& vout);
78  void SetWorldspaceClipPlane(Vec3& normal, Plane& plane);
79 
80 protected:
82 
83  int width, height;
84  double field_of_view;
86  double xcenter, ycenter;
87  double xangle, yangle;
88 
89  int infinite;
90  float depth_scale;
91  bool orthogonal;
92 
95  };
96 
100 
101  float xclip0, xclip1;
102  float yclip0, yclip1;
103 };
104 
105 #endif Projector_h
106