@@ -54,7 +54,7 @@ namespace omega {
5454 // ! Implements a listener that can be attached to cameras to listen to draw
5555 // ! methods. All user method implementations must be reentrant, since they
5656 // ! can be called from mulitple threads.
57- class ICameraListener
57+ class OMEGA_API ICameraListener
5858 {
5959 public:
6060 virtual void endDraw (Camera* cam, DrawContext& context) {}
@@ -75,6 +75,7 @@ namespace omega {
7575 {
7676 DrawScene = 1 << 1 ,
7777 DrawOverlay = 1 << 2 ,
78+ CullingEnabled = 1 << 3 ,
7879 DefaultFlags = DrawScene | DrawOverlay
7980 };
8081
@@ -122,6 +123,14 @@ namespace omega {
122123 // ! this camera. Set to true by default.
123124 void setOverlayEnabled (bool value);
124125 bool isOverlayEnabled ();
126+ // ! When set to false, disables all culling for this camera.
127+ // ! All drawables will attempt drawing, even the ones that
128+ // ! are outside of this camera frustum.
129+ // ! This is useful to force drawing of all objects when we want to
130+ // ! use vertex shaders with custom projections.
131+ // ! By default, culling is enabled.
132+ void setCullingEnabled (bool value);
133+ bool isCullingEnabled ();
125134 // @}
126135
127136 // ! Navigation management
@@ -144,6 +153,10 @@ namespace omega {
144153 // ! render. If it's enabled it will still be checked agains the active
145154 // ! draw context.
146155 void setEnabled (bool value);
156+ // ! Returns true if the frame is enabled, false otherwise
157+ // ! @remarks even if the camera is enabled, this method can return
158+ // ! false if on-demand frame drawing is on and the camera is not
159+ // ! currently scheduled to draw a frame
147160 bool isEnabled ();
148161
149162 // ! Observer control
@@ -209,6 +222,20 @@ namespace omega {
209222 bool isClearDepthEnabled () { return myClearDepth; }
210223 // @}
211224
225+ // ! On-demand drawing
226+ // @{
227+ // ! Queues one frame for drawing. Use this to force a frame
228+ // ! draw when MaxFps is set to 0.
229+ void queueFrameDraw ();
230+ // ! Set the maximum fps that this camera will render at.
231+ // ! Use 0 to stop camera drawing and use queueFrameDraw to
232+ // ! draw frames on-demand.
233+ // ! Use -1 to disable the fps cap and let this camera draw
234+ // ! at the maximum renderer speed (typically 60fps)
235+ void setMaxFps (float fps);
236+ float getMaxFps ();
237+ // @}
238+
212239 // ! DEPRECATED
213240 // @{
214241 Vector3f localToWorldPosition (const Vector3f& position);
@@ -299,6 +326,11 @@ namespace omega {
299326 Vector3f myCanvasPosition;
300327 Quaternion myCanvasOrientation;
301328 Vector3f myCanvasScale;
329+
330+ // On-demand drawing
331+ bool myDrawNextFrame;
332+ float myMaxFps;
333+ float myTimeSinceLastFrame;
302334 };
303335
304336 // /////////////////////////////////////////////////////////////////////////
@@ -373,7 +405,7 @@ namespace omega {
373405
374406 // /////////////////////////////////////////////////////////////////////////
375407 inline bool Camera::isEnabled ()
376- { return myEnabled; }
408+ { return myEnabled && (myDrawNextFrame || myMaxFps < 0 ) ; }
377409
378410 // /////////////////////////////////////////////////////////////////////////
379411 inline void Camera::setSceneEnabled (bool value)
@@ -391,6 +423,18 @@ namespace omega {
391423 inline bool Camera::isOverlayEnabled ()
392424 { return myFlags & DrawOverlay; }
393425
426+ // /////////////////////////////////////////////////////////////////////////
427+ inline void Camera::setCullingEnabled (bool value)
428+ {
429+ if (value) myFlags |= CullingEnabled; else myFlags &= ~CullingEnabled;
430+ }
431+
432+ // /////////////////////////////////////////////////////////////////////////
433+ inline bool Camera::isCullingEnabled ()
434+ {
435+ return myFlags & CullingEnabled;
436+ }
437+
394438 // /////////////////////////////////////////////////////////////////////////
395439 inline const Vector3f& Camera::getCanvasPosition () const
396440 { return myCanvasPosition; }
@@ -403,6 +447,19 @@ namespace omega {
403447 inline const Vector3f& Camera::getCanvasScale () const
404448 { return myCanvasScale; }
405449
450+ // /////////////////////////////////////////////////////////////////////////
451+ inline void Camera::queueFrameDraw ()
452+ { myDrawNextFrame = true ; }
453+
454+ // /////////////////////////////////////////////////////////////////////////
455+ inline void Camera::setMaxFps (float fps)
456+ { myMaxFps = fps; }
457+
458+ // /////////////////////////////////////////////////////////////////////////
459+ inline float Camera::getMaxFps ()
460+ { return myMaxFps; }
461+
462+
406463}; // namespace omega
407464
408465#endif
0 commit comments