class RenderQueue ...{ //...... typedef std::map< RenderQueueGroupID, RenderQueueGroup*> RenderQueueGroupMap; /**//// Iterator over queue groups typedef MapIterator<RenderQueueGroupMap> QueueGroupIterator; protected: RenderQueueGroupMap mGroups; /**//// The current default queue group RenderQueueGroupID mDefaultQueueGroup; //...... public: /**//** Add a renderable object to the queue. @remarks This methods adds a Renderable to the queue, which will be rendered later by the SceneManager. This is the advanced version of the call which allows the renderable to be added to any queue. @note Called by implementation of MovableObject::_updateRenderQueue. @param pRend Pointer to the Renderable to be added to the queue @param groupID The group the renderable is to be added to. This can be used to schedule renderable objects in separate groups such that the SceneManager respects the divisions between the groupings and does not reorder them outside these boundaries. This can be handy for overlays where no matter what you want the overlay to be rendered last. @param priority Controls the priority of the renderable within the queue group. If this number is raised, the renderable will be rendered later in the group compared to it's peers. Don't use this unless you really need to, manually ordering renderables prevents OGRE from sorting them for best efficiency. However this could be useful for ordering 2D elements manually for example. */ void addRenderable(Renderable* pRend, RenderQueueGroupID groupID, ushort priority); /**//** Add a renderable object to the queue. @remarks This methods adds a Renderable to the queue, which will be rendered later by the SceneManager. This is the simplified version of the call which does not require a priority to be specified. The queue priority is take from the current default (see setDefaultRenderablePriority). @note Called by implementation of MovableObject::_updateRenderQueue. @param pRend Pointer to the Renderable to be added to the queue @param groupID The group the renderable is to be added to. This can be used to schedule renderable objects in separate groups such that the SceneManager respects the divisions between the groupings and does not reorder them outside these boundaries. This can be handy for overlays where no matter what you want the overlay to be rendered last. */ void addRenderable(Renderable* pRend, RenderQueueGroupID groupId); /**//** Add a renderable object to the queue. @remarks This methods adds a Renderable to the queue, which will be rendered later by the SceneManager. This is the simplified version of the call which does not require a queue or priority to be specified. The queue group is taken from the current default (see setDefaultQueueGroup). The queue priority is take from the current default (see setDefaultRenderablePriority). @note Called by implementation of MovableObject::_updateRenderQueue. @param pRend Pointer to the Renderable to be added to the queue */ void addRenderable(Renderable* pRend); }; enum RenderQueueGroupID ...{ /**//// Use this queue for objects which must be rendered first e.g. backgrounds RENDER_QUEUE_BACKGROUND =0, /**//// First queue (after backgrounds), used for skyboxes if rendered first RENDER_QUEUE_SKIES_EARLY =5, RENDER_QUEUE_1 =10, RENDER_QUEUE_2 =20, RENDER_QUEUE_3 =30, RENDER_QUEUE_4 =40, /**//// The default render queue RENDER_QUEUE_MAIN =50, RENDER_QUEUE_6 =60, RENDER_QUEUE_7 =70, RENDER_QUEUE_8 =80, RENDER_QUEUE_9 =90, /**//// Penultimate queue(before overlays), used for skyboxes if rendered last RENDER_QUEUE_SKIES_LATE =95, /**//// Use this queue for objects which must be rendered last e.g. overlays RENDER_QUEUE_OVERLAY =100 }; class RenderQueueGroup ...{ public: typedef std::map<ushort, RenderPriorityGroup*, std::less<ushort>> PriorityMap; typedef MapIterator<PriorityMap> PriorityMapIterator; } ; class RenderPriorityGroup ...{ /**//** Internal struct reflecting a single Pass for a Renderable. This is used to sort transparent objects. */ struct RenderablePass ...{ /**//// Pointer to the Renderable details Renderable* renderable; /**//// Pointer to the Pass Pass* pass; RenderablePass(Renderable* rend, Pass* p) :renderable(rend), pass(p) ...{} }; }; class _OgreExport Pass ...{ protected: Technique* mParent; unsigned short mIndex; // pass index unsigned long mHash; // pass hash //------------------------------------------------------------------------- // Colour properties, only applicable in fixed-function passes ColourValue mAmbient; ColourValue mDiffuse; ColourValue mSpecular; ColourValue mEmissive; Real mShininess; //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Blending factors SceneBlendFactor mSourceBlendFactor; SceneBlendFactor mDestBlendFactor; //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Depth buffer settings bool mDepthCheck; bool mDepthWrite; CompareFunction mDepthFunc; ushort mDepthBias; // Colour buffer settings bool mColourWrite; //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Culling mode CullingMode mCullMode; ManualCullingMode mManualCullMode; //------------------------------------------------------------------------- /**//// Lighting enabled? bool mLightingEnabled; /**//// Max simultaneous lights unsigned short mMaxSimultaneousLights; /**//// Run this pass once per light? bool mRunOncePerLight; // Should it only be run for a certain light type? bool mRunOnlyForOneLightType; Light::LightTypes mOnlyLightType; /**//// Shading options ShadeOptions mShadeOptions; //------------------------------------------------------------------------- // Fog bool mFogOverride; FogMode mFogMode; ColourValue mFogColour; Real mFogStart; Real mFogEnd; Real mFogDensity; //------------------------------------------------------------------------- /**//// Storage of texture unit states typedef std::vector<TextureUnitState*> TextureUnitStates; TextureUnitStates mTextureUnitStates; // Vertex program details GpuProgramUsage *mVertexProgramUsage; // Vertex program details GpuProgramUsage *mShadowCasterVertexProgramUsage; // Vertex program details GpuProgramUsage *mShadowReceiverVertexProgramUsage; // Fragment program details GpuProgramUsage *mFragmentProgramUsage; // Is this pass queued for deletion? bool mQueuedForDeletion; public: typedef std::set<Pass*> PassSet; protected: /**//// List of Passes whose hashes need recalculating static PassSet msDirtyHashList; /**//// The place where passes go to die static PassSet msPassGraveyard; }; void SceneManager::_renderScene(Camera* camera, Viewport* vp, bool includeOverlays) ...{ // Parse the scene and tag visibles _findVisibleObjects(camera, mIlluminationStage == IRS_RENDER_TO_TEXTURE?true : false); } -> void SceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) ->mSceneRoot->_findVisibleObjects(cam, getRenderQueue(), true, mDisplayNodes, onlyShadowCasters); ->for (iobj = mObjectsByName.begin(); iobj != iobjend; ++iobj) ...{ // Tell attached objects about camera position (incase any extra processing they want to do) iobj->second->_notifyCurrentCamera(cam); if (iobj->second->isVisible() && (!onlyShadowCasters || iobj->second->getCastShadows())) ...{ iobj->second->_updateRenderQueue(queue); } } -> void Entity::_updateRenderQueue(RenderQueue* queue) ...{ // Add each visible SubEntity to the queue SubEntityList::iterator i, iend; iend = mSubEntityList.end(); for (i = mSubEntityList.begin(); i != iend; ++i) ...{ if((*i)->isVisible()) ...{ if(mRenderQueueIDSet) ...{ queue->addRenderable(*i, mRenderQueueID); } else ...{ queue->addRenderable(*i); } } } } class _OgreExport Technique ...{ protected: typedef std::vector<Pass*> Passes; } class _OgreExport Renderable ...{ public: /**//** Virtual destructor needed as class has virtual methods. */ virtual~Renderable() ...{ } /**//** Retrieves a pointer to the material this renderable object uses. @remarks Note that the Renderable also has the option to override the getTechnique method to specify a particular Technique to use instead of the best one available. */ virtual Material* getMaterial(void) const=0; /**//** Retrieves a pointer to the Material Technique this renderable object uses. @remarks This is to allow Renderables to use a chosen Technique if they wish, otherwise they will use the best Technique available for the Material they are using. */ virtual Technique* getTechnique(void) const...{ return getMaterial()->getBestTechnique(); } }; class _OgreExport Material : public Resource ...{ friend class SceneManager; friend class MaterialManager; public: /**//// distance list used to specify LOD typedef std::vector<Real> LodDistanceList; typedef ConstVectorIterator<LodDistanceList> LodDistanceIterator; protected: /**//// Default material settings - set up by SceneManager static Material* mDefaultSettings; /**//** Internal method which sets the material up from the default settings. */ void applyDefaults(void); typedef std::vector<Technique*> Techniques; Techniques mTechniques; Techniques mSupportedTechniques; typedef std::map<unsigned short, Technique*> BestTechniqueList; BestTechniqueList mBestTechniqueList; };