@@ -14,236 +14,235 @@ class ofCamera : public ofNode {
1414public:
1515 // / \name Constructor and Destructor
1616 // / \{
17-
18- // / \brief Construct a default camera.
17+
18+ // / \brief Construct a default camera.
1919 ofCamera ();
2020
21- // / \brief Destroy the camera.
22- virtual ~ofCamera ();
23-
21+ // / \brief Destroy the camera.
22+ virtual ~ofCamera ();
23+
2424 // / \}
25- // / \name Camera Settings
26- // / \{
25+ // / \name Camera Settings
26+ // / \{
2727
2828 // / \brief Set the field of view for a perspective camera.
2929 // /
3030 // / This sets the vertical field of view for the camera, in degrees.
31- // / This only operates with perspective cameras, and will have no effect
32- // / with cameras in orthographic mode.
31+ // / This only operates with perspective cameras, and will have no effect
32+ // / with cameras in orthographic mode.
3333 // /
3434 // / \param f The desired field of view for the camera, in degrees.
3535 void setFov (float f);
36-
36+
3737 void setNearClip (float f);
3838
39- void setFarClip (float f);
40-
39+ void setFarClip (float f);
40+
4141 // / \brief Set the "lens offset" applied to this camera.
42- // /
42+ // /
4343 // / Ordinarily, the camera is pointed straight down the center of its view
44- // / frustum. However, it is possible to orient the camera towards a location
45- // / offset from the center of its frustum. This is called an "assymetric
46- // / frustum" and is used (for example) in stereo views. It is acheived by
47- // / applying an offset to the center of projection. This function sets this
48- // / offset from an glm::vec2 argument. For more information see
49- // / <http://www.orthostereo.com/geometryopengl.html>.
44+ // / frustum. However, it is possible to orient the camera towards a location
45+ // / offset from the center of its frustum. This is called an "assymetric
46+ // / frustum" and is used (for example) in stereo views. It is acheived by
47+ // / applying an offset to the center of projection. This function sets this
48+ // / offset from an glm::vec2 argument. For more information see
49+ // / <http://www.orthostereo.com/geometryopengl.html>.
5050 // /
5151 // / \param lensOffset The "lens offset" to apply to this camera, encoded in
52- // / an glm::vec2.
52+ // / an glm::vec2.
5353 void setLensOffset (const glm::vec2 & lensOffset);
54-
54+
5555 // / \brief Set the recommended aspect ratio for a perspective camera.
5656 // /
5757 // / Sets the aspect ratio of the camera to the desired float, and forces the
58- // / use of aspect ratio calculations. Currently only used with perspective
59- // / cameras. The default value (and the value used with orthographic
60- // / cameras) is the ratio of the viewport's width to the viewport's height.
61- // /
58+ // / use of aspect ratio calculations. Currently only used with perspective
59+ // / cameras. The default value (and the value used with orthographic
60+ // / cameras) is the ratio of the viewport's width to the viewport's height.
61+ // /
6262 // / \param aspectRatio The desired aspect ratio, e.g. 1.3333, 1.6, etc.
6363 void setAspectRatio (float aspectRatio);
64-
64+
6565 // / \brief Set whether or not the aspect ratio of this camera is forced to a non-default setting.
66- // /
66+ // /
6767 // / The camera's aspect ratio, by default, is the aspect ratio of your
68- // / viewport. If you have set a non-default value (with
69- // / ofCamera::setAspectRatio()), you can toggle whether or not this value is
70- // / applied.
71- // /
72- // / \param forceAspectRatio Whether or not this camera should use an aspect ratio you have set yourself.
68+ // / viewport. If you have set a non-default value (with
69+ // / ofCamera::setAspectRatio()), you can toggle whether or not this value is
70+ // / applied.
71+ // /
72+ // / \param forceAspectRatio Whether or not this camera should use an aspect ratio you have set yourself.
7373 void setForceAspectRatio (bool forceAspectRatio);
7474
7575 // / \brief Get the camera's field of view, in degrees.
7676 // /
7777 // / Get the camera's vertical field of view, in degrees. This is only
78- // / meaningful for perspective cameras.
78+ // / meaningful for perspective cameras.
7979 // /
8080 // / \returns The camera's field of view, in degrees.
8181 float getFov () const { return fov; };
82-
83- float getNearClip () const { return nearClip; };
8482
85- float getFarClip () const { return farClip; };
86-
83+ float getNearClip () const { return nearClip; };
84+
85+ float getFarClip () const { return farClip; };
86+
8787 // / \brief Get the "lens offset" applied to this camera, encoded as an glm::vec2.
88- // /
88+ // /
8989 // / Ordinarily, the camera is pointed straight down the center of its view
90- // / frustum. However, it is possible to orient the camera towards a
91- // / location offset from the center of its frustum. This is called an
92- // / "asymetric frustum" and is used (for example) in stereo views. It is
93- // / acheived by applying an offset to the center of projection. This
94- // / function returns the offset that has been applied, as an glm::vec2. For
95- // / more information see http://www.orthostereo.com/geometryopengl.html.
90+ // / frustum. However, it is possible to orient the camera towards a
91+ // / location offset from the center of its frustum. This is called an
92+ // / "asymetric frustum" and is used (for example) in stereo views. It is
93+ // / acheived by applying an offset to the center of projection. This
94+ // / function returns the offset that has been applied, as an glm::vec2. For
95+ // / more information see http://www.orthostereo.com/geometryopengl.html.
9696 // /
9797 // / \returns The "lens offset" applied to this camera, encoded in an glm::vec2.
9898 glm::vec2 getLensOffset () const { return lensOffset; };
99-
99+
100100 // / \brief Get the boolean state which indicates whether the aspect ratio of this camera is forced to a non-default setting.
101- // /
102- // / \returns A boolean: whether or not this camera's aspect ratio is set to a non-default value.
103- bool getForceAspectRatio () const {return forceAspectRatio;};
104-
101+ // /
102+ // / \returns A boolean: whether or not this camera's aspect ratio is set to a non-default value.
103+ bool getForceAspectRatio () const { return forceAspectRatio; };
104+
105105 // / \brief Get the aspect ratio of this camera's viewport.
106106 // /
107107 // / Returns the aspect ratio of this camera's viewport. Usually this will be
108- // / the ratio of the width to height of your display. Intended for
109- // / perspective cameras.
110- // /
108+ // / the ratio of the width to height of your display. Intended for
109+ // / perspective cameras.
110+ // /
111111 // / \returns The aspect ratio of this camera's viewport.
112- float getAspectRatio () const {return aspectRatio; };
112+ float getAspectRatio () const { return aspectRatio; };
113113
114114 // / \}
115115 // / \name OpenGL Setup
116116 // / \{
117-
117+
118118 void setupPerspective (bool vFlip = true , float fov = 60 , float nearDist = 0 , float farDist = 0 , const glm::vec2 & lensOffset = glm::vec2(0 .0f , 0 .0f ));
119119
120120 void setupOffAxisViewPortal (const glm::vec3 & topLeft, const glm::vec3 & bottomLeft, const glm::vec3 & bottomRight);
121-
121+
122122 void setVFlip (bool vflip);
123123
124- bool isVFlipped () const ;
124+ bool isVFlipped () const ;
125125
126126 void enableOrtho ();
127127
128- void disableOrtho ();
128+ void disableOrtho ();
129+
130+ bool getOrtho () const ;
129131
130- bool getOrtho () const ;
131-
132132 float getImagePlaneDistance (const ofRectangle & viewport = ofRectangle()) const ;
133133
134134 // / \}
135135 // / \name Rendering
136136 // / \{
137137
138138 // / \brief Begins rendering with the camera.
139- // /
140- // / ~~~~{.cpp}
141- // / void draw() {
142- // / // Begin rendering from the camera's perspective.
143- // / camera.begin();
144- // /
145- // / ofLine(0, 0, ofGetWidth(), ofGetHeight());
146- // / // Additional rendering ...
147- // /
148- // / // End rendering form the camera's perspective.
149- // / camera.end();
150- // / }
151- // / ~~~~
152- // / \param viewport The camera's rendering viewport.
153- virtual void begin (){
139+ // /
140+ // / ~~~~{.cpp}
141+ // / void draw() {
142+ // / // Begin rendering from the camera's perspective.
143+ // / camera.begin();
144+ // /
145+ // / ofLine(0, 0, ofGetWidth(), ofGetHeight());
146+ // / // Additional rendering ...
147+ // /
148+ // / // End rendering form the camera's perspective.
149+ // / camera.end();
150+ // / }
151+ // / ~~~~
152+ virtual void begin () {
154153 begin (getViewport ());
155154 }
156155 virtual void begin (const ofRectangle & viewport);
157156
158- // / \brief Ends rendering with the camera.
157+ // / \brief Ends rendering with the camera.
159158 virtual void end ();
160-
159+
161160 // / \}
162161 // / \name OpenGL Matrix
163162 // / \{
164163
165164 // / \brief Access the projection matrix.
166- // / \returns the current 4x4 projection matrix.
167- glm::mat4 getProjectionMatrix () const {
165+ // / \returns the current 4x4 projection matrix.
166+ glm::mat4 getProjectionMatrix () const {
168167 return getProjectionMatrix (getViewport ());
169168 }
170169 glm::mat4 getProjectionMatrix (const ofRectangle & viewport) const ;
171170
172- // / \brief Access the model view matrix.
173- // / \returns the current 4x4 model view matrix.
171+ // / \brief Access the model view matrix.
172+ // / \returns the current 4x4 model view matrix.
174173 glm::mat4 getModelViewMatrix () const ;
175174
176- // / \todo getModelViewProjectionMatrix()
175+ // / \todo getModelViewProjectionMatrix()
177176 glm::mat4 getModelViewProjectionMatrix (const ofRectangle & viewport) const ;
178- glm::mat4 getModelViewProjectionMatrix () const {
177+ glm::mat4 getModelViewProjectionMatrix () const {
179178 return getModelViewProjectionMatrix (getViewport ());
180179 }
181180
182- // / \}
183- // / \name Coordinate Conversion
184- // / \{
185-
186- // / \brief Obtain the screen coordinates of a point in the 3D world.
181+ // / \}
182+ // / \name Coordinate Conversion
183+ // / \{
184+
185+ // / \brief Obtain the screen coordinates of a point in the 3D world.
187186 // /
188187 // / Takes an (X,Y,Z) point in your 3D world, encoded as an glm::vec3,
189188 // / and returns the location (also as an glm::vec3) where this point would
190- // / appear on your (two-dimensional) display. The screen position's "Z
191- // / coordinate" is set to be the same as your camera's.
189+ // / appear on your (two-dimensional) display. The screen position's "Z
190+ // / coordinate" is set to be the same as your camera's.
192191 // /
193- // / \param WorldXYZ A 3D point in the world, whose screen coordinates you wish to know.
194- // / \param viewport (Optional) A viewport. The default is ofGetCurrentViewport().
192+ // / \param WorldXYZ A 3D point in the world, whose screen coordinates you wish to know.
193+ // / \param viewport (Optional) A viewport. The default is ofGetCurrentViewport().
195194 // / \returns An glm::vec3 containing the screen coordinates of your 3D point of interest.
196195 glm::vec3 worldToScreen (glm::vec3 WorldXYZ, const ofRectangle & viewport) const ;
197- glm::vec3 worldToScreen (glm::vec3 WorldXYZ) const {
196+ glm::vec3 worldToScreen (glm::vec3 WorldXYZ) const {
198197 return worldToScreen (WorldXYZ, getViewport ());
199198 }
200-
199+
201200 // / \brief Obtain the coordinates, in the 3D world, of a 2D point presumed to be on your screen.
202201 // /
203202 // / Takes a pixel location on your screen, encoded in an glm::vec3,
204203 // / and returns (also as an glm::vec3) the 3D world coordinates of that point.
205- // / You'll also need to specify a Z value when providing your screen point.
206- // / This Z value is interpreted as a distance into or away from the screen.
204+ // / You'll also need to specify a Z value when providing your screen point.
205+ // / This Z value is interpreted as a distance into or away from the screen.
207206 // /
208207 // / \param ScreenXYZ A point on your screen, whose 3D world coordinates you wish to know.
209208 glm::vec3 screenToWorld (glm::vec3 ScreenXYZ, const ofRectangle & viewport) const ;
210- glm::vec3 screenToWorld (glm::vec3 ScreenXYZ) const {
209+ glm::vec3 screenToWorld (glm::vec3 ScreenXYZ) const {
211210 return screenToWorld (ScreenXYZ, getViewport ());
212211 }
213-
212+
214213 // / \todo worldToCamera()
215214 glm::vec3 worldToCamera (glm::vec3 WorldXYZ, const ofRectangle & viewport) const ;
216- glm::vec3 worldToCamera (glm::vec3 WorldXYZ) const {
215+ glm::vec3 worldToCamera (glm::vec3 WorldXYZ) const {
217216 return worldToCamera (WorldXYZ, getViewport ());
218217 }
219218
220219 // / \todo cameraToWorld()
221220 glm::vec3 cameraToWorld (glm::vec3 CameraXYZ, const ofRectangle & viewport) const ;
222- glm::vec3 cameraToWorld (glm::vec3 CameraXYZ) const {
221+ glm::vec3 cameraToWorld (glm::vec3 CameraXYZ) const {
223222 return cameraToWorld (CameraXYZ, getViewport ());
224223 }
225224
226225 // / \}
227226 // / \name Renderer
228227 // / \{
229-
230- void setRenderer (std::shared_ptr<ofBaseRenderer> renderer);
231-
228+
229+ void setRenderer (std::shared_ptr<ofBaseRenderer> renderer);
230+
232231 // / \}
233232
234233 // / \brief Draw a visual representation of the camera's frustum
235- // / \note This will only be visible when the camera drawing its
234+ // / \note This will only be visible when the camera drawing its
236235 // / frustum is viewed through another camera.
237236 void drawFrustum (const ofRectangle & viewport) const ;
238- void drawFrustum () const {
237+ void drawFrustum () const {
239238 drawFrustum (getViewport ());
240239 }
241240
242241protected:
243242 ofRectangle getViewport () const ;
244243 std::shared_ptr<ofBaseRenderer> getRenderer () const ;
245244 void calcClipPlanes (const ofRectangle & viewport);
246-
245+
247246private:
248247 bool isOrtho;
249248 float fov;
@@ -255,4 +254,3 @@ class ofCamera : public ofNode {
255254 bool vFlip;
256255 std::shared_ptr<ofBaseRenderer> renderer;
257256};
258-
0 commit comments