Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://visualizationlibrary.org */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #ifndef Rendering_INCLUDE_ONCE 00033 #define Rendering_INCLUDE_ONCE 00034 00035 #include <vlGraphics/RenderingAbstract.hpp> 00036 #include <vlGraphics/RenderQueueSorter.hpp> 00037 #include <vlGraphics/Actor.hpp> 00038 #include <vlGraphics/RenderQueue.hpp> 00039 #include <vlGraphics/Renderer.hpp> 00040 #include <vlGraphics/Framebuffer.hpp> 00041 #include <vlGraphics/Camera.hpp> 00042 #include <vlGraphics/SceneManager.hpp> 00043 #include <vlCore/Transform.hpp> 00044 #include <vlCore/Collection.hpp> 00045 00046 namespace vl 00047 { 00069 class VLGRAPHICS_EXPORT Rendering: public RenderingAbstract 00070 { 00071 VL_INSTRUMENT_CLASS(vl::Rendering, RenderingAbstract) 00072 00073 public: 00075 Rendering(); 00076 00078 Rendering(const Rendering& other): RenderingAbstract(other) { *this = other; } 00079 00081 Rendering& operator=(const Rendering& other); 00082 00084 virtual void render(); 00085 00087 void setRenderQueueSorter(RenderQueueSorter* render_queue_sorter) { mRenderQueueSorter = render_queue_sorter; } 00088 00090 RenderQueueSorter* renderQueueSorter() { return mRenderQueueSorter.get(); } 00091 00095 const std::vector< ref<Renderer> >& renderers() const { return mRenderers; } 00096 00100 std::vector< ref<Renderer> >& renderers() { return mRenderers; } 00101 00103 void setRenderer(Renderer* renderer) 00104 { 00105 renderers().clear(); 00106 renderers().push_back(renderer); 00107 } 00108 00110 const Renderer* renderer() const 00111 { 00112 if (renderers().empty()) 00113 return NULL; 00114 else 00115 return renderers()[0].get(); 00116 } 00117 00119 Renderer* renderer() 00120 { 00121 if (renderers().empty()) 00122 return NULL; 00123 else 00124 return renderers()[0].get(); 00125 } 00126 00128 void setCamera(Camera* camera) { mCamera = camera; } 00129 00131 const Camera* camera() const { return mCamera.get(); } 00132 00134 Camera* camera() { return mCamera.get(); } 00135 00137 Collection<SceneManager>* sceneManagers() { return mSceneManagers.get(); } 00138 00140 const Collection<SceneManager>* sceneManagers() const { return mSceneManagers.get(); } 00141 00144 void setTransform(Transform* transform) { mTransform = transform; } 00145 00148 const Transform* transform() const { return mTransform.get(); } 00149 00152 Transform* transform() { return mTransform.get(); } 00153 00155 void setEvaluateLOD(bool evaluate_lod) { mEvaluateLOD = evaluate_lod; } 00156 00158 bool evaluateLOD() const { return mEvaluateLOD; } 00159 00163 void setShaderAnimationEnabled(bool animate_shaders) { mShaderAnimationEnabled = animate_shaders; } 00164 00168 bool shaderAnimationEnabled() const { return mShaderAnimationEnabled; } 00169 00171 void setCullingEnabled(bool enabled) { mCullingEnabled = enabled; } 00172 00174 bool cullingEnabled() const { return mCullingEnabled; } 00175 00179 void setAutomaticResourceInit(bool enable) { mAutomaticResourceInit = enable; } 00180 00182 bool automaticResourceInit() const { return mAutomaticResourceInit; } 00183 00185 bool nearFarClippingPlanesOptimized() const { return mNearFarClippingPlanesOptimized; } 00186 00191 void setNearFarClippingPlanesOptimized(bool enabled) { mNearFarClippingPlanesOptimized = enabled; } 00192 00197 const std::map<unsigned int, ref<Effect> >& effectOverrideMask() const { return mEffectOverrideMask; } 00198 00203 std::map<unsigned int, ref<Effect> >& effectOverrideMask() { return mEffectOverrideMask; } 00204 00205 protected: 00206 // mic fixme: it would be nice to have a mechanism to request the visible actors at will and to 00207 // compile and save the render-queue for later renderings to be reused without recomputing the culling. 00208 // The user could be able to install actor-list or render-queue and use the flags READ|WRITE|TERMINATE 00209 // to define wether the list should be used for reading, filled, cleaned up after rendering. 00210 void fillRenderQueue( ActorCollection* actor_list ); 00211 RenderQueue* renderQueue() { return mRenderQueue.get(); } 00212 ActorCollection* actorQueue() { return mActorQueue.get(); } 00213 00214 protected: 00215 ref<RenderQueueSorter> mRenderQueueSorter; 00216 ref<ActorCollection> mActorQueue; 00217 ref<RenderQueue> mRenderQueue; 00218 std::vector< ref<Renderer> > mRenderers; 00219 ref<Camera> mCamera; 00220 ref<Transform> mTransform; 00221 ref<Collection<SceneManager> > mSceneManagers; 00222 std::map<unsigned int, ref<Effect> > mEffectOverrideMask; 00223 00224 bool mAutomaticResourceInit; 00225 bool mCullingEnabled; 00226 bool mEvaluateLOD; 00227 bool mShaderAnimationEnabled; 00228 bool mNearFarClippingPlanesOptimized; 00229 }; 00230 } 00231 00232 #endif