#pragma once #include "RenderingRun.h" class TechniqueGroup; #define RUN_TYPE_COUNT 24 /** @brief Enum of RenderingRun types. If a new class is derived from RenderingRun, this enum should be extended. These types are used in messages sent when a run changes or updates. */ enum RenderingRunType { ILLUMRUN_CUBEMAP, ILLUMRUN_COLOR_CUBEMAP, ILLUMRUN_COLOR_CUBEMAP_L1, ILLUMRUN_COLOR_CUBEMAP_L2, ILLUMRUN_COLOR_CUBEMAP_L3, ILLUMRUN_COLOR_CUBEMAP_L4, ILLUMRUN_COLOR_CUBEMAP_L5, ILLUMRUN_COLOR_CUBEMAP_L6, ILLUMRUN_DISTANCE_CUBEMAP, ILLUMRUN_DISTANCE_CUBEMAP_L1, ILLUMRUN_DISTANCE_CUBEMAP_L2, ILLUMRUN_DISTANCE_CUBEMAP_L3, ILLUMRUN_DISTANCE_CUBEMAP_L4, ILLUMRUN_DISTANCE_CUBEMAP_L5, ILLUMRUN_DISTANCE_CUBEMAP_L6, ILLUMRUN_CAUSTIC_CUBEMAP, ILLUMRUN_REDUCED_CUBEMAP, ILLUMRUN_PHOTONMAP, ILLUMRUN_DEPTH_SHADOWMAP, ILLUMRUN_SCENE_CAMERA_DEPTH, ILLUMRUN_HPP_IMPOSTOR, ILLUMRUN_FOCUSING_MAP, ILLUMRUN_LIGHTVOLUME_MAP, ILLUMRUN_PHASE_TEXTURE, ILLUMRUN_PM_ENTRYPOINTMAP, ILLUMRUN_PM_WEIGHTMAP }; /** @brief Base abstract class for a collection of shared resources (RenderingRuns). Technique resources which can be shared between several techniques or objects are managed by SharedRuns. These SharedRuns store the shared resources. They also act like nodes of a binary tree, as separate SharedRuns can also be joined if for example the objects for which they store resources are close enough so even one shared resources is enough for the given objects. */ class SharedRuns { public: /** &brief Constructor. */ SharedRuns(void); /** &brief Returns true if this shared run object has a given run type. It returns true if the shared run object node has a rendering run object with the given type. It checks only the current node of the tree, no children nodes are searched for existing rendering runs. @param runType enum, type of the RenderingRun to search for @return search result */ virtual bool hasOwnRun(RenderingRunType runType) = 0; /** &brief Retrieves a shared resource. @param runType enum, type of the RenderingRun to be retrieved @return pointer to the RenderingRun of type "runType", null if this type does not exists */ virtual RenderingRun* getRun(RenderingRunType runType) = 0; /** &brief Adds a RenderingRun instance to the shared resources. @param runType enum, type of the RenderingRun to add @param run pointer to the RenderingRun instance to add */ virtual void addRun(RenderingRunType runType, RenderingRun* run)=0; /** &brief Updates a shared RenderingRun. @param runType enum, type of the RenderingRun to update @param frameNum current framenumber */ virtual void updateRun(RenderingRunType runType, unsigned long frameNum) = 0; /** &brief Joines two SharedRuns. The resulting SharedRuns become the parent of the two SharedRuns. @param otherRuns pointer to the SharedRuns instance to join with @return the new parent SharedRuns instance */ virtual SharedRuns* joinRuns(SharedRuns* otherRuns); /** @brief Called after one of he shared runs changes. This message will be forwarded to each child. @param runType enum describing the type of the changed run @param run pointer to the changed RenderingRun */ virtual void runChanged(RenderingRunType runType, RenderingRun* run); /** @brief Called after one of he shared runs updates. This message will be forwarded to each child. @param runType enum describing the type of the updated run @param run pointer to the updated RenderingRun */ virtual void runUpdated(RenderingRunType runType, RenderingRun* run); /** @brief Adds a child TechniqueGroup. @param group pointer to the TechniqueGroup instance to add. */ virtual void addTechniqueGroup(TechniqueGroup* group) = 0; /** @brief Shows or hides this SharedRuns (and also all childnodes). @param visible visibility */ virtual void setVisible(bool visible); /** @brief Hides this SharedRuns (and also all childs). The previous visibility is saved. */ virtual void hide(); /** @brief Restores the visibility of this SharedRuns (and also all childs). */ virtual void restoreVisibility(); /** @brief Retrieves the root node of this SharedRuns node. @return pointer to the root SharedRuns instance */ virtual SharedRuns* getRoot(); /** @brief Retrieves the topmost parent node of this SharedRuns node, which have a specified RenderingRun type. @param runType the RenderingRun type @return pointer to the parent SharedRuns instance */ virtual SharedRuns* getRoot(RenderingRunType runType); /** @brief Updates the boundary of this SharedRuns (and also it's parent). */ virtual void updateBounds() = 0; /** @brief Validate this SharedRuns (and also all childs). Validation meens that all the SharedRuns that are joined will be examined if the sharing is still valid. If it finds out that two SharedRuns can't be joined anymore (eg.: they moved far from each other), their parent will be split and destroyed (all parent of this node also should be deleted recursively). */ virtual void validate() = 0; /** @brief Destroys the node (and all parents recursively). */ virtual void destroy() = 0; /** @brief Unbinds the parent of the node, called at splitting. */ virtual void unbindParent(){parent = 0;} /** @brief Unbinds the deletes the parent of the node, called at splitting. */ virtual void unbindAndKillParent(){delete parent; parent = 0;} virtual void freeAllResources()=0; protected: /** @brief parent SharedRuns instance */ SharedRuns* parent; /** @brief child SharedRuns instance */ SharedRuns* child1; /** @brief child SharedRuns instance */ SharedRuns* child2; /** @brief Collects RenderingRuns references from the child nodes, used when joining */ virtual void gatherRuns() = 0; /** @brief Sends runChanged events for each RenderingRun type, used after join and split */ virtual void fireRunChanges() = 0; /** @brief Creates a new SharedRuns instance. All derivatives should implement this. @return a new SharedRuns instance */ virtual SharedRuns* createInstance() = 0; //{ return 0; } /** @brief Set visibility of connected renderables, only used if this is a leaf. @param visible visibility */ virtual void setRenderablesVisible(bool visible) = 0; /** @brief Hides all the connected renderables, only used if this is a leaf. */ virtual void hideRenderables() = 0; /** @brief Restires visibility of all the connected renderables, only used if this is a leaf. */ virtual void restoreRenderableVisibility() = 0; };