#pragma once #include #include "Vector.hpp" #include "Transformed.h" class Mesh; class SubMesh; class Entity; class RenderStrategy; class SubEntity { friend class FinalCompositionRenderStrategy; protected: Entity* parent; int nNearClusters; SubMesh* subMesh; //!< mesh Transformed* rayTraceEntity; //!< raytracable entity containing the subMesh's TriangleMesh LPDIRECT3DTEXTURE9 prmTexture; //!< a collection of tiled UV atlases containing illuminaton contributions of nearest entry point clusters LPDIRECT3DSURFACE9 prmSurface; //!< prmTexture's surface int prmxres; int prmyres; void createRayTraceEntity(); //!< setup rayTraceEntity //! array of cluster indices storing which clusters are relevant. PRM tiles correspond to these clusters unsigned int nearClusterIndices[32]; public: //! clear PRM to float4(0, 0, 0, 0) void clearPRM(); //! render contributions of virtual light sources in 'bushRadions' to atlas corresponding to cluster 'bushId' void renderPRM( std::vector& clusterRadions, unsigned int clusterId); //! downscale pixel values according to alpha (render-to-the-pixel counter) to get rid of overlapping edge artifacts void normalizePRM(); //! fill the nearClusterIndices array void findNearClusters(const std::vector& starters, unsigned int nClusters); public: SubEntity(Entity* parent, SubMesh* subMesh, int nNearClusters); ~SubEntity(void); Intersectable* getRayTraceEntity(); void draw(const RenderStrategy& renderStrategy); float getSurfaceArea(); const Material* sampleSurface(Radion& sample); void savePRM(); void loadPRM(); void saveSceneInfo(std::ofstream& psf); };