Changeset 751
- Timestamp:
- 04/19/06 00:27:14 (19 years ago)
- Location:
- GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE
- Files:
-
- 1 added
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudGenerator.h
r721 r751 2 2 #define _BBCBILLBOARDCLOUDGENERATOR_H 3 3 4 #include <BBCUtil.h>5 4 #include <BBCEntity.h> 6 5 #include <BBCEntityDistribution.h> -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardCloudUVMapper.h
r745 r751 46 46 void generateTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards = false, unsigned int numberGroups = 1); 47 47 48 void addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup, unsigned int iBillboard );48 void addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup, unsigned int iBillboard, unsigned int iBillboardInGroup); 49 49 50 50 void setBillboardCloud(BillboardCloud *billboardCloud); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCBillboardClusterData.h
r745 r751 77 77 Ogre::Vector2 getBillboardUVMapMin(unsigned int iBillboardGroup); 78 78 79 void addBillboardUVMapMin(Ogre::Vector2 min );79 void addBillboardUVMapMin(Ogre::Vector2 minVec); 80 80 81 81 void removeBillboardUVMapMin(unsigned int iBillboardGroup); … … 83 83 Ogre::Vector2 getBillboardUVMapMax(unsigned int iBillboardGroup); 84 84 85 void addBillboardUVMapMax(Ogre::Vector2 max );85 void addBillboardUVMapMax(Ogre::Vector2 maxVec); 86 86 87 87 void removeBillboardUVMapMax(unsigned int iBillboardGroup); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCManager.h
r731 r751 3 3 4 4 #include <BBCPrerequisites.h> 5 #include <BBCUtil.h> 5 6 #include <BBCSingleton.h> 6 7 … … 31 32 void shutdown(void); 32 33 33 Ogre::MeshSerializer* getMeshSerializer(void);34 35 Ogre::XMLMeshSerializer* getXMLMeshSerializer(void);36 37 protected:38 39 34 }; 40 35 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h
r721 r751 130 130 void setMaterialName(Ogre::String value); 131 131 132 //void createUniqueVertices();133 134 132 UniqueVertexList* getUniqueVertices(); 135 133 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCUtil.h
r700 r751 5 5 6 6 namespace BBC { 7 8 class _BBCExport Util 9 { 10 public: 11 static Ogre::String getBaseName(Ogre::String fileName) 12 { 13 Ogre::String baseName; 14 size_t pos = fileName.find_last_of("."); 15 baseName = fileName.substr(0, pos); 16 return baseName; 17 } 18 19 static Ogre::String getExtensionName(Ogre::String fileName) 20 { 21 Ogre::String ext; 22 size_t pos = fileName.find_last_of("."); 23 ext = fileName.substr(pos+1); 24 return ext; 25 } 26 27 static unsigned int nextPowerOf2(unsigned int nPlanes) 28 { 29 unsigned int depth = 1; 30 while (depth < nPlanes) 31 { 32 depth = depth << 1; 33 } 34 return depth; 35 } 36 37 }; 38 7 39 /* 8 40 extern "C" _BBCExport double fround(double n, unsigned d) … … 15 47 return (int)floor(x + 0.5); 16 48 } 17 18 extern "C" _BBCExport unsigned int getUpperPowerOfTwo(unsigned int powerOfTwo)19 {20 unsigned int icount = 0;21 unsigned int depth = 1;22 while (icount < powerOfTwo)23 {24 depth = depth << 1;25 icount++;26 }27 return depth;28 }29 49 */ 30 50 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGTexture.h
r745 r751 55 55 void setRenderTargetListener(Ogre::RenderTargetListener *renderTargetListener); 56 56 57 virtual void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera); 57 virtual void debug(); 58 59 virtual void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour); 58 60 59 61 Ogre::ColourValue getAvgColour(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGTextureAtlas.h
r745 r751 3 3 4 4 #include <IMGPrerequisites.h> 5 #include <IMGUtil.h> 5 6 #include <IMGTexture.h> 6 7 … … 51 52 void debug(); 52 53 53 void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera );54 void create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour); 54 55 55 56 void update(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardCloudTextureViewMode.h
r747 r751 22 22 unsigned int mSubEntityVisible; 23 23 24 Ogre::Entity *mEntity ;24 Ogre::Entity *mEntityClusters; 25 25 26 26 public: 27 27 28 void setEntity (Ogre::Entity *entity)28 void setEntityClusters(Ogre::Entity *entity) 29 29 { 30 mEntity = entity;30 mEntityClusters = entity; 31 31 } 32 32 … … 50 50 if (mCurrentTexture < mNumTextures) 51 51 { 52 //calculateProjectionMatrix(unsigned int iSubEntity, Ogre::Camera *cam);53 //initializeShaderParameters(unsigned int iSubEntity);54 mTexture->getRectangle2D()->setVisible(false);55 mTextureAtlas->getRectangle2D()->setVisible(false);56 52 } 57 53 } … … 76 72 void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) 77 73 { 78 //configureTexture( unsigned int iSubEntity );79 74 } 80 75 … … 90 85 unsigned int mFrame; 91 86 92 Ogre::SceneNode *m ClusterizedEntitiesMergedSceneNode;87 Ogre::SceneNode *mEntityClustersGroupedSceneNode; 93 88 94 Ogre::Entity *mClusterizedEntities; 89 Ogre::SceneNode *mBillboardCloudSplittedSceneNode; 90 91 Ogre::Entity *mEntityClustersGrouped; 92 93 Ogre::Entity *mBillboardCloudSplitted; 95 94 96 95 ClusterTextureListener mClusterTextureListener; … … 120 119 Ogre::String mTextureAtlasFolder; 121 120 122 Ogre::String mEntityName; 121 Ogre::String mEntityClustersGroupedName; 122 123 Ogre::String mBillboardCloudSplittedName; 124 125 Ogre::Matrix4 mCustomProjMatrix; 126 127 Ogre::String mTextureName; 128 129 bool mDebugBillboardGeneration; 130 131 bool mDebugTextureAtlasGeneration; 132 133 unsigned int mCurrentBillboardGroup; 134 135 unsigned int mCurrentBillboard; 123 136 124 137 public: 125 138 126 BillboardCloudTextureViewMode(Ogre::RenderWindow* win, unsigned int ogreFrameListenerModeHandle, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false); 139 BillboardCloudTextureViewMode(Ogre::RenderWindow* win, unsigned int ogreFrameListenerModeHandle, bool useBufferedInputKeys = false, bool useBufferedInputMouse = false); 127 140 128 141 virtual ~BillboardCloudTextureViewMode(); … … 133 146 134 147 virtual void destroyScene(); 148 149 void setBillboardCloudGroupedTextureAtlasDebug(bool debugTextureAtlasGeneration); 150 151 void setTextureName(Ogre::String textureName); 152 153 void configureBillboard(); 154 155 void enableEntityClusterCustomOrthogonalCameraMaterial(unsigned int iEntityClusterGrouped); 156 157 void disableEntityClusterCustomOrthogonalCameraMaterial(unsigned int iEntityClusterGrouped); 158 159 void configureTexture(); 160 161 void configureTextureAtlas(); 162 163 bool processUnbufferedKeyInput(const Ogre::FrameEvent& evt); 164 165 void saveTextureAtlas(); 135 166 136 167 void setTextureAtlasSize(unsigned int size); … … 138 169 void setTextureSize(unsigned int size); 139 170 140 void setEntityName(Ogre::String entityName); 171 void setEntityClustersGroupedName(Ogre::String entityClustersGrouped); 172 173 void setBillboardCloudSplittedName(Ogre::String billboardCloudSplittedName); 141 174 142 175 void setTextureAtlasName(Ogre::String textureAtlasName); … … 145 178 146 179 void setTextureAtlasBitRange(unsigned int bitRange); 180 181 void configureBillboardOrthogonalAlignedCamera(unsigned int iBillboard); 182 183 void initializeEntityClustersGrouped(); 184 185 void initializeBillboardCloudSplitted(); 186 187 void generateTexture(); 188 189 void generateTextureAtlas(); 190 147 191 }; 148 192 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCBillboardViewMode.h
r731 r751 13 13 OBA::OgreFrameListenerMode(win, ogreFrameListenerModeHandle, useBufferedInputKeys, useBufferedInputMouse) 14 14 { 15 showDebugOverlay(false); 16 mReloadedTextures = false; 15 17 } 16 18 … … 19 21 } 20 22 23 bool frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader) 24 { 25 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 26 27 //if (!mReloadedTextures) 28 //{ 29 // for (unsigned int iSubEntity = 0; iSubEntity < mBillboardCloudEntity->getNumSubEntities(); iSubEntity++) 30 // { 31 // Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(mBillboardCloudEntity->getSubEntity(iSubEntity)->getMaterialName()); 32 // Ogre::LogManager::getSingleton().logMessage("Reloading texture:" + materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName()); 33 34 // Ogre::TexturePtr texturePtr = Ogre::TextureManager::getSingleton().getByName(materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName()); 35 // texturePtr->reload(); 36 // materialPtr->reload(); 37 // } 38 // mReloadedTextures = true; 39 //} 40 41 return OgreFrameListenerMode::frameStarted(evt, inputReader); 42 } 43 44 void setBillboardCloudMeshName(Ogre::String billboardCloudMeshName) 45 { 46 mBillboardCloudMeshName = billboardCloudMeshName; 47 } 48 21 49 virtual void createScene() 22 50 { 51 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 52 23 53 Ogre::SceneNode* sNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 24 Ogre::Entity* emesh = mSceneMgr->createEntity("chestnutLeavesBillboardCloudMerged.mesh","chestnutLeavesBillboardCloudGrouped.mesh"); 25 sNode->attachObject(emesh); 54 //mBillboardCloudEntity = mSceneMgr->createEntity(mBillboardCloudMeshName, mBillboardCloudMeshName); 55 mBillboardCloudEntity = mSceneMgr->createEntity("chestnutLeavesBillboardCloudGrouped.mesh", "chestnutLeavesBillboardCloudGrouped.mesh"); 56 sNode->attachObject(mBillboardCloudEntity); 57 sNode->rotate(Ogre::Vector3::UNIT_X, Ogre::Radian(Ogre::Degree(-90.0))); 26 58 } 27 59 60 protected: 61 Ogre::String mBillboardCloudMeshName; 62 63 Ogre::Entity *mBillboardCloudEntity; 64 65 bool mReloadedTextures; 28 66 }; 29 67 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCClusterViewMode.h
r731 r751 13 13 OBA::OgreFrameListenerMode(win, ogreFrameListenerModeHandle, useBufferedInputKeys, useBufferedInputMouse) 14 14 { 15 showDebugOverlay(false); 15 16 } 16 17 … … 19 20 } 20 21 22 bool frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader) 23 { 24 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 25 26 return OgreFrameListenerMode::frameStarted(evt, inputReader); 27 } 28 29 void setEntityClustersMeshName(Ogre::String entityClustersMeshName) 30 { 31 mEntityClustersMeshName = entityClustersMeshName; 32 } 33 21 34 virtual void createScene() 22 35 { 36 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 37 23 38 Ogre::SceneNode* sNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 24 Ogre::Entity* emesh = mSceneMgr->createEntity("chestnutLeavesEntitySample.mesh", "chestnutLeavesEntitySample.mesh"); 25 sNode->attachObject(emesh); 39 //Ogre::Entity* eLeafClustersGrouped = mSceneMgr->createEntity(mEntityClustersMeshName, mEntityClustersMeshName); 40 Ogre::Entity* eLeafClustersGrouped = mSceneMgr->createEntity("chestnutLeafClustersGrouped.mesh", "chestnutLeafClustersGrouped.mesh"); 41 sNode->attachObject(eLeafClustersGrouped); 42 sNode->rotate(Ogre::Vector3::UNIT_X, Ogre::Radian(Ogre::Degree(-90.0))); 26 43 } 44 protected: 45 Ogre::String mEntityClustersMeshName; 46 47 27 48 }; 28 49 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCEntityTextureAtlasViewMode.h
r745 r751 40 40 virtual ~EntityTextureAtlasViewMode(); 41 41 42 unsigned int nextPowerOf2(unsigned int nPlanes);43 44 42 virtual bool frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader); 45 43 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCLeafDistributionGenerator.h
r721 r751 16 16 virtual ~LeafDistributionGenerator(); 17 17 18 void generateAverageLeafPosition(Leaf *leaf); 19 18 20 void generateAverageLeafNormal(Leaf *leaf); 19 21 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCManager.h
r745 r751 69 69 void loadBillboardCloudMergedXML(); 70 70 71 void saveBillboardCloudIndirectSplittedPointMeshName(); 71 72 72 73 protected: -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBCSampleConfigFile.h
r747 r751 50 50 Ogre::String getEntityClustersFolder(); 51 51 52 bool getEntityClustersMergedClusters();53 54 52 bool getEntityClustersSplittedClusters(); 55 53 56 Ogre::String getEntityClustersMergedMeshName(); 54 bool getEntityClustersGroupedClusters(); 55 56 bool getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug(); 57 58 bool getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasDebug(); 59 60 bool getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug(); 61 62 bool getBillboardCloudIndirectMergedBillboardsTextureAtlasDebug(); 63 64 Ogre::String getEntityClustersGroupedMeshName(); 57 65 58 66 Ogre::String getEntityClustersSplittedMeshName(); 59 67 60 Ogre::String getEntityClusters MergedMaterialName();68 Ogre::String getEntityClustersGroupedMaterialName(); 61 69 62 70 Ogre::String getEntityClustersSplittedMaterialName(); 71 72 Ogre::String getEntityClustersGroupedTextureUnit0Name(); 73 74 Ogre::String getEntityClustersSplittedTextureUnit0Name(); 63 75 64 76 bool getBillboardCloudMergedBillboards(); … … 94 106 Ogre::String getBillboardCloudMergedXMLName(); 95 107 108 Ogre::String getBillboardCloudIndirectPointMeshName(); 109 110 Ogre::String getBillboardCloudIndirectPointMaterialName(); 111 96 112 unsigned int getBillboardCloudGroups(); 97 113 … … 102 118 Ogre::String getBillboardCloudDiffuseColorEntityTextureName(); 103 119 104 Ogre::String getBillboardCloudDiffuseColorEntityTextureAtlasName(); 120 Ogre::String getBillboardCloudDiffuseColorEntityTextureAtlasName(); 105 121 106 122 unsigned int getBillboardCloudDiffuseColorEntityTextureAtlasBitRange(); … … 108 124 unsigned int getBillboardCloudDiffuseColorEntityTextureAtlasSize(); 109 125 110 unsigned int getBillboardCloudDiffuseColor BillboardGroupTextureSize();126 unsigned int getBillboardCloudDiffuseColorGroupedBillboardsTextureSize(); 111 127 112 bool getBillboardCloudIndirect BillboardGroupTextureAtlasGeneration();128 bool getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration(); 113 129 114 Ogre::String getBillboardCloudIndirect BillboardGroupTextureAtlasName();130 Ogre::String getBillboardCloudIndirectGroupedBillboardsTextureAtlasName(); 115 131 116 unsigned int getBillboardCloudIndirect BillboardGroupTextureAtlasBitRange();132 unsigned int getBillboardCloudIndirectGroupedBillboardsTextureAtlasBitRange(); 117 133 118 unsigned int getBillboardCloudIndirect BillboardGroupTextureAtlasSize();134 unsigned int getBillboardCloudIndirectGroupedBillboardsTextureAtlasSize(); 119 135 120 unsigned int getBillboardCloudIndirect BillboardGroupTextureSize();136 unsigned int getBillboardCloudIndirectGroupedBillboardsTextureSize(); 121 137 122 bool getBillboardCloudDiffuseColor BillboardGroupTextureAtlasGeneration();138 bool getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration(); 123 139 124 140 bool getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasGeneration(); … … 132 148 unsigned int getBillboardCloudDiffuseColorMergedBillboardsTextureSize(); 133 149 134 unsigned int getBillboardCloudDiffuseColor BillboardGroupTextureAtlasSize();150 unsigned int getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize(); 135 151 136 152 unsigned int getBillboardCloudDiffuseColorEntityTextureAtlasNumSamples(); … … 138 154 bool getBillboardCloudIndirectMergedBillboardsTextureAtlasGeneration(); 139 155 156 Ogre::String getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasName(); 157 140 158 Ogre::String getBillboardCloudIndirectMergedBillboardsTextureAtlasName(); 141 159 142 160 unsigned int getBillboardCloudIndirectMergedBillboardsTextureAtlasBitRange(); 161 162 unsigned int getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasBitRange(); 143 163 144 164 unsigned int getBillboardCloudIndirectMergedBillboardsTextureAtlasSize(); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/OBA/OBAOgreFrameListenerMode.h
r721 r751 74 74 75 75 virtual void destroyScene(void); // Optional to override this 76 77 unsigned int getHandle(); 76 78 }; 77 79 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGenerator.vcproj
r745 r751 30 30 BufferSecurityCheck="TRUE" 31 31 EnableFunctionLevelLinking="TRUE" 32 DisableLanguageExtensions="FALSE" 32 33 UsePrecompiledHeader="0" 33 34 WarningLevel="3" … … 83 84 PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 84 85 RuntimeLibrary="2" 86 DisableLanguageExtensions="FALSE" 85 87 UsePrecompiledHeader="0" 86 88 WarningLevel="3" -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGeneratorCommandLine.vcproj
r731 r751 25 25 BasicRuntimeChecks="3" 26 26 RuntimeLibrary="1" 27 DisableLanguageExtensions="FALSE" 27 28 UsePrecompiledHeader="0" 28 29 WarningLevel="3" … … 73 74 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 74 75 RuntimeLibrary="0" 76 DisableLanguageExtensions="FALSE" 75 77 UsePrecompiledHeader="0" 76 78 WarningLevel="3" -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloud.cpp
r745 r751 237 237 unsigned int billboardHandle = billboardGroup->getBillboardHandle(iBillboard); 238 238 BillboardPtr billboard = this->getBillboard(billboardHandle); 239 EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 240 241 if (entityCluster->getNumEntitiesClusterData() > 0) 242 { 243 subEntity = mEntity->getSubEntity(numGeneratedBillboardClouds); 244 245 while (subEntityGroup->getNumTexCoordSets() < subEntity->getNumTexCoordSets()) 239 240 BillboardClusterData *billboardClusterData = billboard->getBillboardClusterData().get(); 241 242 if (billboardClusterData != NULL) 243 { 244 EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 245 246 if (entityCluster->getNumEntitiesClusterData() > 0) 246 247 { 247 subEntityGroup->addTextureCoordSet(subEntity->getTexCoordDimensions(subEntityGroup->getNumTexCoordSets())); 248 subEntity = mEntity->getSubEntity(numGeneratedBillboardClouds); 249 250 while (subEntityGroup->getNumTexCoordSets() < subEntity->getNumTexCoordSets()) 251 { 252 subEntityGroup->addTextureCoordSet(subEntity->getTexCoordDimensions(subEntityGroup->getNumTexCoordSets())); 253 } 254 255 unsigned int offset = subEntityGroup->getNumFaces() * 3; 256 Ogre::Vector3 indicesA = Ogre::Vector3(offset, offset + 1, offset + 2); 257 subEntityGroup->addFaceVerticesIDs(indicesA); 258 offset = subEntityGroup->getNumFaces()*3; 259 Ogre::Vector3 indicesB = Ogre::Vector3(offset, offset + 1, offset + 2); 260 subEntityGroup->addFaceVerticesIDs(indicesB); 261 262 UniqueVertex vFaceA1,vFaceA2,vFaceA3; 263 // Face A of the billboard quad 264 vFaceA1.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner(); 265 vFaceA1.normal = billboard->getBillboardClusterData()->getNormal(); 266 267 vFaceA2.position = billboard->getBillboardClusterData()->getQuadTopRightCorner(); 268 vFaceA2.normal = billboard->getBillboardClusterData()->getNormal(); 269 270 vFaceA3.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner(); 271 vFaceA3.normal = billboard->getBillboardClusterData()->getNormal(); 272 273 // Face B of the billboard quad 274 UniqueVertex vFaceB1,vFaceB2,vFaceB3; 275 vFaceB1.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner(); 276 vFaceB1.normal = billboard->getBillboardClusterData()->getNormal(); 277 278 vFaceB2.position = billboard->getBillboardClusterData()->getQuadBottomLeftCorner(); 279 vFaceB2.normal = billboard->getBillboardClusterData()->getNormal(); 280 281 vFaceB3.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner(); 282 vFaceB3.normal = billboard->getBillboardClusterData()->getNormal(); 283 284 Ogre::LogManager::getSingleton().logMessage("BBCG-SubEntity(" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + ") - Num.Tex.Coord.Sets:"+ Ogre::StringConverter::toString(subEntity->getNumTexCoordSets())); 285 286 for (unsigned int iTexCoordSet = 0; iTexCoordSet < subEntityGroup->getNumTexCoordSets(); iTexCoordSet++) 287 { 288 vFaceA1.uv[iTexCoordSet] = subEntity->getUniqueVertex(0).uv[iTexCoordSet]; 289 vFaceA2.uv[iTexCoordSet] = subEntity->getUniqueVertex(1).uv[iTexCoordSet]; 290 vFaceA3.uv[iTexCoordSet] = subEntity->getUniqueVertex(2).uv[iTexCoordSet]; 291 vFaceB1.uv[iTexCoordSet] = subEntity->getUniqueVertex(3).uv[iTexCoordSet]; 292 vFaceB2.uv[iTexCoordSet] = subEntity->getUniqueVertex(4).uv[iTexCoordSet]; 293 vFaceB3.uv[iTexCoordSet] = subEntity->getUniqueVertex(5).uv[iTexCoordSet]; 294 } 295 296 subEntityGroup->addUniqueVertex(vFaceA1); 297 subEntityGroup->addUniqueVertex(vFaceA2); 298 subEntityGroup->addUniqueVertex(vFaceA3); 299 subEntityGroup->addUniqueVertex(vFaceB1); 300 subEntityGroup->addUniqueVertex(vFaceB2); 301 subEntityGroup->addUniqueVertex(vFaceB3); 302 303 numGeneratedBillboardClouds++; 248 304 } 249 250 unsigned int offset = subEntityGroup->getNumFaces() * 3;251 Ogre::Vector3 indicesA = Ogre::Vector3(offset, offset + 1, offset + 2);252 subEntityGroup->addFaceVerticesIDs(indicesA);253 offset = subEntityGroup->getNumFaces()*3;254 Ogre::Vector3 indicesB = Ogre::Vector3(offset, offset + 1, offset + 2);255 subEntityGroup->addFaceVerticesIDs(indicesB);256 257 UniqueVertex vFaceA1,vFaceA2,vFaceA3;258 // Face A of the billboard quad259 vFaceA1.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner();260 vFaceA1.normal = billboard->getBillboardClusterData()->getNormal();261 262 vFaceA2.position = billboard->getBillboardClusterData()->getQuadTopRightCorner();263 vFaceA2.normal = billboard->getBillboardClusterData()->getNormal();264 265 vFaceA3.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner();266 vFaceA3.normal = billboard->getBillboardClusterData()->getNormal();267 268 // Face B of the billboard quad269 UniqueVertex vFaceB1,vFaceB2,vFaceB3;270 vFaceB1.position = billboard->getBillboardClusterData()->getQuadBottomRightCorner();271 vFaceB1.normal = billboard->getBillboardClusterData()->getNormal();272 273 vFaceB2.position = billboard->getBillboardClusterData()->getQuadBottomLeftCorner();274 vFaceB2.normal = billboard->getBillboardClusterData()->getNormal();275 276 vFaceB3.position = billboard->getBillboardClusterData()->getQuadTopLeftCorner();277 vFaceB3.normal = billboard->getBillboardClusterData()->getNormal();278 279 Ogre::LogManager::getSingleton().logMessage("BBCG-SubEntity(" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + ") - Num.Tex.Coord.Sets:"+ Ogre::StringConverter::toString(subEntity->getNumTexCoordSets()));280 281 for (unsigned int iTexCoordSet = 0; iTexCoordSet < subEntityGroup->getNumTexCoordSets(); iTexCoordSet++)282 {283 vFaceA1.uv[iTexCoordSet] = subEntity->getUniqueVertex(0).uv[iTexCoordSet];284 vFaceA2.uv[iTexCoordSet] = subEntity->getUniqueVertex(1).uv[iTexCoordSet];285 vFaceA3.uv[iTexCoordSet] = subEntity->getUniqueVertex(2).uv[iTexCoordSet];286 vFaceB1.uv[iTexCoordSet] = subEntity->getUniqueVertex(3).uv[iTexCoordSet];287 vFaceB2.uv[iTexCoordSet] = subEntity->getUniqueVertex(4).uv[iTexCoordSet];288 vFaceB3.uv[iTexCoordSet] = subEntity->getUniqueVertex(5).uv[iTexCoordSet];289 }290 291 subEntityGroup->addUniqueVertex(vFaceA1);292 subEntityGroup->addUniqueVertex(vFaceA2);293 subEntityGroup->addUniqueVertex(vFaceA3);294 subEntityGroup->addUniqueVertex(vFaceB1);295 subEntityGroup->addUniqueVertex(vFaceB2);296 subEntityGroup->addUniqueVertex(vFaceB3);297 298 numGeneratedBillboardClouds++;299 305 } 300 306 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudUVMapper.cpp
r745 r751 118 118 } 119 119 120 void BillboardCloudUVMapper::addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboardClouds, unsigned int iBillboardGroup, unsigned int iBillboard) 121 { 122 unsigned int iUniqueVertex = 0; 123 124 Ogre::LogManager::getSingleton().logMessage("iBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds) + "-" + "iBBCG:" + Ogre::StringConverter::toString(iBillboardGroup)); 125 126 Ogre::LogManager::getSingleton().logMessage("SizeCLList:" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds)); 127 120 void BillboardCloudUVMapper::addTextureAtlasTextureCoords(bool mergeBillboards, bool groupedBillboards, unsigned int numGeneratedBillboards, unsigned int iBillboardGroup, unsigned int iBillboard, unsigned int iBillboardInGroup) 121 { 128 122 IMG::Cluster *cluster = getClusterList(iBillboardGroup)->get(getClusterList(iBillboardGroup)->getSize()-1); 129 123 IMG::Box2d *box = cluster->getBspNodeBound(); … … 131 125 Ogre::Vector2 min = box->getMinimum(); 132 126 133 Ogre::LogManager::getSingleton().logMessage("max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0], max[1], 0.0)) );134 Ogre::LogManager::getSingleton().logMessage("min:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0], min[1], 0.0)) );135 136 127 Ogre::Vector2 umax; 137 128 umax[0] = (max[0] / mTextureAtlasWidth); … … 145 136 umax = umax * 2.0 - 1.0; 146 137 147 Ogre::LogManager::getSingleton().logMessage("Umax:" + Ogre::StringConverter::toString(Ogre::Vector3(umax[0], umax[1], 0.0)) ); 148 Ogre::LogManager::getSingleton().logMessage("Umin:" + Ogre::StringConverter::toString(Ogre::Vector3(umin[0], umin[1], 0.0)) ); 149 138 mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData()->addBillboardUVMapMax(umax); 150 139 mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData()->addBillboardUVMapMin(umin); 151 mBillboardCloud->getBillboard(iBillboard)->getBillboardClusterData()->addBillboardUVMapMax(umax); 152 153 Ogre::LogManager::getSingleton().logMessage("Max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0],max[1],0)) + 154 "\tMin:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0],min[1],0)) + 155 "\tSize(" + Ogre::StringConverter::toString(max[0]-min[0]) + 156 "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 157 158 Ogre::LogManager::getSingleton().logMessage( 159 "UMax:" + Ogre::StringConverter::toString(Ogre::Vector3(umax[0], umax[1],0)) + 160 "\tUMin:" + Ogre::StringConverter::toString(Ogre::Vector3(umin[0], umin[1],0)) + 161 "\tUSize(" + Ogre::StringConverter::toString(umax[0]-umin[0]) + 162 "," + Ogre::StringConverter::toString(umax[1]-umin[1]) + ")"); 163 164 std::cin.get(); 165 166 167 SubEntityPtr subEntity; 140 141 //Ogre::LogManager::getSingleton().logMessage("Max:" + Ogre::StringConverter::toString(Ogre::Vector3(max[0],max[1],0)) + 142 // "\tMin:" + Ogre::StringConverter::toString(Ogre::Vector3(min[0],min[1],0)) + 143 // "\tSize(" + Ogre::StringConverter::toString(max[0]-min[0]) + 144 // "," + Ogre::StringConverter::toString(max[1]-min[1]) + ")"); 145 146 //Ogre::LogManager::getSingleton().logMessage( 147 // "UMax:" + Ogre::StringConverter::toString(Ogre::Vector3(umax[0], umax[1],0)) + 148 // "\tUMin:" + Ogre::StringConverter::toString(Ogre::Vector3(umin[0], umin[1],0)) + 149 // "\tUSize(" + Ogre::StringConverter::toString(umax[0]-umin[0]) + 150 // "," + Ogre::StringConverter::toString(umax[1]-umin[1]) + ")"); 168 151 169 152 Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; 170 texCoords01[0] = min[0] / mTextureAtlasWidth; 171 texCoords01[1] = min[1] / mTextureAtlasHeight; 172 173 texCoords02[0] = max[0] / mTextureAtlasWidth; 174 texCoords02[1] = min[1] / mTextureAtlasHeight; 175 176 texCoords03[0] = max[0] / mTextureAtlasWidth; 177 texCoords03[1] = max[1] / mTextureAtlasHeight; 178 179 texCoords04[0] = min[0] / mTextureAtlasWidth; 180 texCoords04[1] = max[1] / mTextureAtlasHeight; 153 154 texCoords02[0] = min[0] / mTextureAtlasWidth; 155 texCoords02[1] = 1.0 - (min[1] / mTextureAtlasHeight); 156 157 texCoords01[0] = max[0] / mTextureAtlasWidth; 158 texCoords01[1] = 1.0 - (min[1] / mTextureAtlasHeight); 159 160 texCoords04[0] = max[0] / mTextureAtlasWidth; 161 texCoords04[1] = 1.0 - (max[1] / mTextureAtlasHeight); 162 163 texCoords03[0] = min[0] / mTextureAtlasWidth; 164 texCoords03[1] = 1.0 - (max[1] / mTextureAtlasHeight); 181 165 182 166 if (groupedBillboards) 183 167 { 184 Ogre::LogManager::getSingleton().logMessage("DontMerge"); 185 subEntity = mBillboardCloud->getEntity()->getSubEntity(iBillboardGroup); 186 168 SubEntityPtr subEntity; 169 170 unsigned int iUniqueVertex = 0; 171 172 subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboards); 173 174 subEntity->addTextureCoordSet(2); 175 subEntity->enableVertexColours(true); 176 187 177 // Face A 188 178 //(0,0,0); … … 216 206 subEntity->setVertexColour(iUniqueVertex+4, subEntityColour05.getAsRGBA()); 217 207 subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); 218 219 iUniqueVertex = iUniqueVertex + 6;220 208 } 221 209 else 222 210 { 223 if (!mergeBillboards) 224 { 225 Ogre::LogManager::getSingleton().logMessage("DontMerge"); 226 227 subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 228 subEntity->addTextureCoordSet(2); 229 subEntity->enableVertexColours(true); 230 // Face A 231 //(0,0,0); 232 //(1,0,0); 233 //(1,1,0); 234 235 subEntity->setTexCoord(0, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1], 0)); 236 subEntity->setTexCoord(1, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords02[0],texCoords02[1], 0)); 237 subEntity->setTexCoord(2, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1], 0)); 238 239 Ogre::ColourValue subEntityColour01 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 240 Ogre::ColourValue subEntityColour02 = Ogre::ColourValue(0, texCoords02[0],texCoords02[1]); 241 Ogre::ColourValue subEntityColour03 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 242 243 subEntity->setVertexColour(0, subEntityColour01.getAsRGBA()); 244 subEntity->setVertexColour(1, subEntityColour02.getAsRGBA()); 245 subEntity->setVertexColour(2, subEntityColour03.getAsRGBA()); 246 247 // Face B 248 //(1,1,0); 249 //(0,1,0); 250 //(0,0,0); 251 subEntity->setTexCoord(3, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords03[0],texCoords03[1],0)); 252 subEntity->setTexCoord(4, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords04[0],texCoords04[1],0)); 253 subEntity->setTexCoord(5, subEntity->getNumTexCoordSets()-1, Ogre::Vector3(texCoords01[0],texCoords01[1],0)); 254 255 Ogre::ColourValue subEntityColour04 = Ogre::ColourValue(0, texCoords03[0],texCoords03[1]); 256 Ogre::ColourValue subEntityColour05 = Ogre::ColourValue(0, texCoords04[0],texCoords04[1]); 257 Ogre::ColourValue subEntityColour06 = Ogre::ColourValue(0, texCoords01[0],texCoords01[1]); 258 259 subEntity->setVertexColour(3, subEntityColour04.getAsRGBA()); 260 subEntity->setVertexColour(4, subEntityColour05.getAsRGBA()); 261 subEntity->setVertexColour(5, subEntityColour06.getAsRGBA()); 262 263 } 264 else 265 { 266 Ogre::LogManager::getSingleton().logMessage("Merge"); 211 if (mergeBillboards) 212 { 213 SubEntityPtr subEntity; 214 215 unsigned int iUniqueVertex = numGeneratedBillboards * 6; 267 216 268 217 subEntity = mBillboardCloud->getEntity()->getSubEntity(0); … … 300 249 subEntity->setVertexColour(iUniqueVertex+5, subEntityColour06.getAsRGBA()); 301 250 302 iUniqueVertex = iUniqueVertex + 6; 303 } 304 Ogre::LogManager::getSingleton().logMessage("EndAdd"); 251 } 305 252 } 306 253 } … … 310 257 IMG::NodeBspPtr nodeDest; 311 258 IMG::Cluster cluster; 312 Ogre::LogManager::getSingleton().logMessage("w:" + Ogre::StringConverter::toString(mTextureWidth)); 313 Ogre::LogManager::getSingleton().logMessage("h:" + Ogre::StringConverter::toString(mTextureHeight)); 259 314 260 nodeDest = getBsp(iBillboardGroup)->insert(mTextureWidth,mTextureHeight,iBillboard); 315 261 316 262 cluster.setBspNodeBound(nodeDest->getBound()); 317 //cluster.finish();318 263 getClusterList(iBillboardGroup)->insert(&cluster); 319 264 } … … 323 268 unsigned int numBillboardGroups; 324 269 bool enabledTextureCoordSet = false; 325 unsigned int numGeneratedBillboard Clouds = 0;270 unsigned int numGeneratedBillboards = 0; 326 271 327 272 for (unsigned int iBillboard = 0; iBillboard < mBillboardCloud->getNumBillboards(); iBillboard++) … … 342 287 } 343 288 } 344 else 345 { 346 if (groupedBillboards) 347 { 348 SubEntityPtr subEntity = mBillboardCloud->getEntity()->getSubEntity(numGeneratedBillboardClouds); 349 subEntity->addTextureCoordSet(2); 350 subEntity->enableVertexColours(true); 351 } 352 } 353 354 numGeneratedBillboardClouds++; 289 numGeneratedBillboards++; 355 290 } 356 291 } … … 373 308 374 309 unsigned int iBillboardsInGroup = 0; 375 unsigned int numberBillboardsEachGroup = numGeneratedBillboard Clouds / numGroups;376 unsigned int numberBillboardsAddedFirstGroup = numGeneratedBillboard Clouds % numGroups;377 numGeneratedBillboard Clouds = 0;310 unsigned int numberBillboardsEachGroup = numGeneratedBillboards / numGroups; 311 unsigned int numberBillboardsAddedFirstGroup = numGeneratedBillboards % numGroups; 312 numGeneratedBillboards = 0; 378 313 unsigned int iBillboardGroup; 379 314 for (iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) … … 388 323 addBsp(bsp); 389 324 addClusterList(clusterList); 390 391 325 } 392 326 … … 400 334 if (billboardClusterData != NULL) 401 335 { 402 Ogre::LogManager::getSingleton().logMessage("billboardData");336 BillboardPtr billboard = mBillboardCloud->getBillboard(iBillboard); 403 337 EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 338 404 339 if (entityCluster->getNumEntitiesClusterData() > 0) 405 340 { 406 Ogre::LogManager::getSingleton().logMessage("entityCluster");407 408 341 if ((iBillboardGroup == 0) && (iBillboardsInGroup < (numberBillboardsEachGroup + numberBillboardsAddedFirstGroup))) 409 342 { 410 Ogre::LogManager::getSingleton().logMessage("\nA");411 Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds));412 413 343 addTextureInBsp(iBillboardGroup, iBillboard); 414 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboard Clouds, iBillboardGroup, iBillboard);344 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboards, iBillboardGroup, iBillboard, iBillboardsInGroup); 415 345 iBillboardsInGroup++; 416 346 } … … 419 349 if ((iBillboardGroup > 0) && (iBillboardsInGroup < numberBillboardsEachGroup)) 420 350 { 421 Ogre::LogManager::getSingleton().logMessage("\nB");422 Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds));423 424 351 addTextureInBsp(iBillboardGroup, iBillboard); 425 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboard Clouds, iBillboardGroup, iBillboard);352 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboards, iBillboardGroup, iBillboard, iBillboardsInGroup); 426 353 iBillboardsInGroup++; 427 354 } … … 431 358 iBillboardsInGroup = 0; 432 359 433 Ogre::LogManager::getSingleton().logMessage("\nC IG:" + Ogre::StringConverter::toString(iBillboardsInGroup-1) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup-1) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup-1)->getSize()));434 Ogre::LogManager::getSingleton().logMessage("IG:" + Ogre::StringConverter::toString(iBillboardsInGroup) + " SizeCLList(" + Ogre::StringConverter::toString(iBillboardGroup) + "):" + Ogre::StringConverter::toString(getClusterList(iBillboardGroup)->getSize()) + " -- numBBC:" + Ogre::StringConverter::toString(numGeneratedBillboardClouds));435 436 360 addTextureInBsp(iBillboardGroup, iBillboard); 437 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboard Clouds, iBillboardGroup, iBillboard);361 addTextureAtlasTextureCoords(mergeBillboards, groupedBillboards, numGeneratedBillboards, iBillboardGroup, iBillboard, iBillboardsInGroup); 438 362 iBillboardsInGroup++; 439 363 } 440 364 } 441 365 442 numGeneratedBillboard Clouds++;366 numGeneratedBillboards++; 443 367 } 444 368 } 445 369 } 446 //mBsp.Print();447 370 } 448 371 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardClusterData.cpp
r745 r751 6 6 BillboardClusterData::BillboardClusterData(): references(0) // initialize references to 0 7 7 { 8 8 9 } 9 10 … … 134 135 } 135 136 136 void BillboardClusterData::addBillboardUVMapMin(Ogre::Vector2 min )137 void BillboardClusterData::addBillboardUVMapMin(Ogre::Vector2 minVec) 137 138 { 138 mGroupedBillboardUVMapMinList.push_back(min );139 mGroupedBillboardUVMapMinList.push_back(minVec); 139 140 } 140 141 … … 149 150 } 150 151 151 void BillboardClusterData::addBillboardUVMapMax(Ogre::Vector2 max )152 void BillboardClusterData::addBillboardUVMapMax(Ogre::Vector2 maxVec) 152 153 { 153 mGroupedBillboardUVMapMaxList.push_back(max );154 mGroupedBillboardUVMapMaxList.push_back(maxVec); 154 155 } 155 156 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCManager.cpp
r731 r751 22 22 BBCManager::~BBCManager() 23 23 { 24 24 25 } 25 26 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCSubEntity.cpp
r721 r751 167 167 return &mUniqueVertexList; 168 168 } 169 170 /*171 void SubEntity::createUniqueVertices()172 {173 for (unsigned int i = 0; i < getNumVertices(); i++)174 {175 UniqueVertex uniqueVertex;176 uniqueVertex.position = getVertex(i);177 uniqueVertex.normal = getNormal(i);178 for (unsigned int j = 0; j < getNumTexCoordSets(); j++)179 {180 uniqueVertex.uv[j] = getTexCoord(j,i);181 }182 183 }184 }185 */186 169 187 170 void SubEntity::addUniqueVertex(UniqueVertex uniqueVertex) -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp
r747 r751 59 59 //mLBBCManager->loadSampleConfigFile(mOpts.cfg); 60 60 mLBBCManager->initialize(); 61 mLBBCManager->loadBillboardCloudMergedXML(); 61 //mLBBCManager->loadBillboardCloudMergedXML(); 62 mLBBCManager->loadBillboardCloudGroupedXML(); 62 63 this->go(); 63 64 for (unsigned int iFrameListenerMode = 0; iFrameListenerMode < mFrameListener->getNumFrameListenerModes(); iFrameListenerMode++) … … 147 148 148 149 { 149 LBBC::BillboardCloudTextureViewMode *anotherFrameListenerMode;150 anotherFrameListenerMode = new LBBC::BillboardCloudTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes());151 anotherFrameListenerMode->chooseSceneManager();152 anotherFrameListenerMode->createCamera();153 anotherFrameListenerMode->createViewports();154 anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize());155 anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize());156 anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasBitRange());157 anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasName());158 anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder());159 anotherFrameListenerMode->setEntityName(mSampleConfigFile->getEntityClustersMergedMeshName());160 anotherFrameListenerMode->createScene();161 mFrameListener->addFrameListenerMode(anotherFrameListenerMode);162 }163 164 {165 LBBC::ClusterViewMode *anotherFrameListenerMode;166 anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes());167 anotherFrameListenerMode->chooseSceneManager();168 anotherFrameListenerMode->createCamera();169 anotherFrameListenerMode->createViewports();170 anotherFrameListenerMode->createScene();171 mFrameListener->addFrameListenerMode(anotherFrameListenerMode);172 }173 174 {175 LBBC::BillboardViewMode *anotherFrameListenerMode;176 anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes());177 anotherFrameListenerMode->chooseSceneManager();178 anotherFrameListenerMode->createCamera();179 anotherFrameListenerMode->createViewports();180 anotherFrameListenerMode->createScene();181 mFrameListener->addFrameListenerMode(anotherFrameListenerMode);182 }183 184 {185 150 LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode; 186 151 textureAtlasFrameListenerMode = new LBBC::EntityTextureAtlasViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); … … 199 164 } 200 165 166 { 167 LBBC::BillboardCloudTextureViewMode *anotherFrameListenerMode; 168 anotherFrameListenerMode = new LBBC::BillboardCloudTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); 169 anotherFrameListenerMode->chooseSceneManager(); 170 anotherFrameListenerMode->createCamera(); 171 anotherFrameListenerMode->createViewports(); 172 anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize()); 173 anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureSize()); 174 anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasBitRange()); 175 anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasName()); 176 anotherFrameListenerMode->setTextureName(mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureName()); 177 anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder()); 178 anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName()); 179 //anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName()); 180 anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudIndirectPointMeshName()); 181 anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug()); 182 anotherFrameListenerMode->createScene(); 183 mFrameListener->addFrameListenerMode(anotherFrameListenerMode); 184 } 185 186 { 187 LBBC::BillboardViewMode *anotherFrameListenerMode; 188 anotherFrameListenerMode = new LBBC::BillboardViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); 189 anotherFrameListenerMode->chooseSceneManager(); 190 anotherFrameListenerMode->createCamera(); 191 anotherFrameListenerMode->createViewports(); 192 //anotherFrameListenerMode->setBillboardCloudMeshName(mSampleConfigFile->getBillboardCloudGroupedMeshName()); 193 anotherFrameListenerMode->createScene(); 194 mFrameListener->addFrameListenerMode(anotherFrameListenerMode); 195 } 196 197 { 198 LBBC::ClusterViewMode *anotherFrameListenerMode; 199 anotherFrameListenerMode = new LBBC::ClusterViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); 200 anotherFrameListenerMode->chooseSceneManager(); 201 anotherFrameListenerMode->createCamera(); 202 anotherFrameListenerMode->createViewports(); 203 //anotherFrameListenerMode->setEntityClustersMeshName(mSampleConfigFile->getEntityClustersGroupedMeshName()); 204 anotherFrameListenerMode->createScene(); 205 mFrameListener->addFrameListenerMode(anotherFrameListenerMode); 206 } 207 201 208 mFrameListener->removeFrameListenerMode(0); 202 209 mFrameListener->setEnabledFrameListenerMode(0); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGCluster.cpp
r731 r751 110 110 void Cluster::print() 111 111 { 112 Ogre::LogManager::getSingleton().logMessage("\n\nCluster: " + Ogre::StringConverter::toString(id) + ", axisproj: " + Ogre::StringConverter::toString(axisproj) + ", order: " + Ogre::StringConverter::toString(order));112 //Ogre::LogManager::getSingleton().logMessage("\n\nCluster: " + Ogre::StringConverter::toString(id) + ", axisproj: " + Ogre::StringConverter::toString(axisproj) + ", order: " + Ogre::StringConverter::toString(order)); 113 113 114 114 plane.print(); 115 Ogre::LogManager::getSingleton().logMessage("\nOrigin (" + Ogre::StringConverter::toString(lumel_origin) + ")");116 Ogre::LogManager::getSingleton().logMessage("Inc U (" + Ogre::StringConverter::toString(lumel_x_axis) + ")");117 Ogre::LogManager::getSingleton().logMessage("Inc V (" + Ogre::StringConverter::toString(lumel_y_axis.z) + ")");115 //Ogre::LogManager::getSingleton().logMessage("\nOrigin (" + Ogre::StringConverter::toString(lumel_origin) + ")"); 116 //Ogre::LogManager::getSingleton().logMessage("Inc U (" + Ogre::StringConverter::toString(lumel_x_axis) + ")"); 117 //Ogre::LogManager::getSingleton().logMessage("Inc V (" + Ogre::StringConverter::toString(lumel_y_axis.z) + ")"); 118 118 119 119 bound.print(); … … 121 121 bspnodebound.print(); 122 122 123 Ogre::LogManager::getSingleton().logMessage("Printant els vertexs: ");123 //Ogre::LogManager::getSingleton().logMessage("Printant els vertexs: "); 124 124 } 125 125 … … 145 145 void Cluster::finish() 146 146 { 147 Ogre::LogManager::getSingleton().logMessage("\nCluster::Finish()");147 //Ogre::LogManager::getSingleton().logMessage("\nCluster::Finish()"); 148 148 Plane3 *plane = getPlane(); 149 149 Ogre::Vector3 normal = *plane->getNormal(); … … 157 157 bool type = true; 158 158 159 Ogre::LogManager::getSingleton().logMessage("\tCreant cluster 2d");159 //Ogre::LogManager::getSingleton().logMessage("\tCreant cluster 2d"); 160 160 axisproj = cluster2d.create2d (this, 0, true); 161 Ogre::LogManager::getSingleton().logMessage("\t Imprimint el que hi al del cluster");161 //Ogre::LogManager::getSingleton().logMessage("\t Imprimint el que hi al del cluster"); 162 162 163 163 std::vector<Ogre::Vector2> vector2; … … 172 172 max = bound.getMaximum(); 173 173 174 Ogre::LogManager::getSingleton().logMessage("Caixa Englobant del cluster 2d");174 //Ogre::LogManager::getSingleton().logMessage("Caixa Englobant del cluster 2d"); 175 175 bound.print(); 176 176 177 177 Ogre::Vector3 aux (-9999,-9999,-9999); 178 178 179 Ogre::LogManager::getSingleton().logMessage("Axisproj:" + Ogre::StringConverter::toString(axisproj));179 //Ogre::LogManager::getSingleton().logMessage("Axisproj:" + Ogre::StringConverter::toString(axisproj)); 180 180 } 181 181 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGTexture.cpp
r745 r751 29 29 // delete mMaterial; 30 30 //} 31 } 32 33 void Texture::debug() 34 { 35 unsigned char* pBufferBox = new unsigned char[mTexture->getBuffer(0, 0)->getSizeInBytes()]; 36 37 // Read pixels 38 Ogre::PixelBox pBox(mWidth, mHeight, 1, mPixelFormat, pBufferBox); 39 40 mTexture->getBuffer(0, 0)->blitToMemory(pBox); 41 42 if (mPixelFormat == Ogre::PF_FLOAT32_RGBA) 43 { 44 imdebug("rgba w=%d h=%d %p b=32f",pBox.getWidth(), pBox.getHeight(), pBox.data); 45 } 46 47 if (mPixelFormat == Ogre::PF_A8R8G8B8) 48 { 49 //unsigned char* pBufferDest = new unsigned char[pBox.getWidth()*pBox.getHeight()*4]; 50 unsigned char* pBufferDest = new unsigned char[pBox.getWidth()*pBox.getHeight()*4]; 51 Ogre::PixelBox pDest(mWidth, mHeight, 1, Ogre::PF_BYTE_RGBA, pBufferDest); 52 Ogre::PixelUtil::bulkPixelConversion(pBox.data, mPixelFormat, pDest.data, Ogre::PF_BYTE_RGBA, pBox.getWidth()*pBox.getHeight()); 53 54 imdebug("rgba w=%d h=%d %p ", pDest.getWidth(), pDest.getHeight(), pDest.data); 55 56 delete [] pBufferDest; 57 } 58 59 delete [] pBufferBox; 31 60 } 32 61 … … 191 220 } 192 221 193 void Texture::create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera )222 void Texture::create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour) 194 223 { 195 224 mCamera = camera; … … 203 232 Ogre::Viewport *v = rt->addViewport(mCamera); 204 233 v->setClearEveryFrame(true); 205 v->setBackgroundColour( Ogre::ColourValue(1.0f, 1.0f, 1.0f, 0.0f));234 v->setBackgroundColour(backgroundColour); 206 235 v->setOverlaysEnabled(false); 207 236 v->setDimensions(0,0,1.0,1.0); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IMGTextureAtlas.cpp
r747 r751 87 87 } 88 88 89 void TextureAtlas::create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera )89 void TextureAtlas::create(Ogre::String fileName, unsigned int width, unsigned int height, Ogre::PixelFormat pixelFormat, Ogre::Camera *camera, Ogre::ColourValue backgroundColour) 90 90 { 91 91 mCamera = camera; … … 101 101 Ogre::Viewport *v = rt->addViewport(mCamera); 102 102 v->setClearEveryFrame(true); 103 v->setBackgroundColour( Ogre::ColourValue(1.0f, 1.0f, 1.0f, 0.0f));103 v->setBackgroundColour(backgroundColour); 104 104 v->setOverlaysEnabled(false); 105 105 v->setDimensions(0,0,1.0,1.0); … … 113 113 Ogre::Viewport *v = rt->addViewport(mCamera); 114 114 v->setClearEveryFrame(true); 115 v->setBackgroundColour( Ogre::ColourValue(1.0f, 1.0f, 1.0f, 0.0f));115 v->setBackgroundColour(backgroundColour); 116 116 v->setOverlaysEnabled(false); 117 117 v->setDimensions(0,0,1.0,1.0); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardCloudTextureViewMode.cpp
r747 r751 10 10 { 11 11 mFrame = 0; 12 mDebugOverlay->setScale(0.0, 0.0); 12 mCurrentBillboardGroup = 0; 13 mCurrentBillboard = 0; 14 showDebugOverlay(false); 15 mDebugBillboardGeneration = false; 16 mDebugTextureAtlasGeneration = false; 13 17 } 14 18 … … 18 22 } 19 23 24 25 void BillboardCloudTextureViewMode::setBillboardCloudGroupedTextureAtlasDebug(bool debugTextureAtlasGeneration) 26 { 27 mDebugTextureAtlasGeneration = debugTextureAtlasGeneration; 28 } 29 30 void BillboardCloudTextureViewMode::configureBillboardOrthogonalAlignedCamera(unsigned int iBillboard) 31 { 32 BBC::BillboardPtr billboardPtr = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboard(iBillboard); 33 Ogre::Vector3 vTopLeft = billboardPtr->getBillboardClusterData()->getQuadTopLeftCorner(); 34 Ogre::Vector3 vTopRight = billboardPtr->getBillboardClusterData()->getQuadTopRightCorner(); 35 Ogre::Vector3 vBottomLeft = billboardPtr->getBillboardClusterData()->getQuadBottomLeftCorner(); 36 Ogre::Vector3 vBottomRight = billboardPtr->getBillboardClusterData()->getQuadBottomRightCorner(); 37 38 Ogre::Vector3 vMidPoint = vTopLeft.midPoint(vBottomRight); 39 Ogre::Vector3 vWidth(vTopRight - vTopLeft); 40 Ogre::Vector3 vHeight(vBottomLeft - vTopLeft); 41 42 Ogre::Real w = vWidth.length(); 43 Ogre::Real h = vHeight.length(); 44 Ogre::Real aspect = w / h; 45 Ogre::Radian fovy = Ogre::Radian(Ogre::Degree(90.0)); 46 Ogre::Real nearPlane = h / Ogre::Math::Tan(fovy/2.0,false); 47 Ogre::Real farPlane = 100000; 48 49 Ogre::Vector3 vUp = vTopLeft - vBottomLeft; 50 vUp.normalise(); 51 52 Ogre::Vector3 vI(vTopRight-vTopLeft); 53 vI.normalise(); 54 55 Ogre::Vector3 vJ(vBottomLeft-vTopLeft); 56 vJ.normalise(); 57 58 Ogre::Vector3 vDir = -vI.crossProduct(vJ); 59 vDir.normalise(); 60 61 Ogre::Vector3 vRight = vDir.crossProduct(vUp); 62 vRight.normalise(); 63 64 Ogre::Quaternion qOrientation(vRight, vUp, -vDir); 65 66 mCamera->setNearClipDistance(nearPlane); 67 mCamera->setOrientation(qOrientation); 68 mCamera->setPosition(vMidPoint - (vDir * (nearPlane*nearPlane))); 69 70 Ogre::Radian thetaY (fovy / 2.0f); 71 Ogre::Real tanThetaY = Ogre::Math::Tan(thetaY); 72 73 Ogre::Real tanThetaX = tanThetaY * aspect; 74 75 Ogre::Real half_w,half_h; 76 half_w = w / 2.0; 77 half_h = h / 2.0; 78 79 Ogre::Real iw = 1.0 / half_w; 80 Ogre::Real ih = 1.0 / half_h; 81 Ogre::Real q; 82 if (farPlane == 0) 83 { 84 q = 0; 85 } 86 else 87 { 88 q = 2.0 / (farPlane - nearPlane); 89 } 90 mCustomProjMatrix = Ogre::Matrix4::ZERO; 91 mCustomProjMatrix[0][0] = iw; 92 mCustomProjMatrix[1][1] = ih; 93 mCustomProjMatrix[2][2] = -q; 94 mCustomProjMatrix[2][3] = - (farPlane + nearPlane)/(farPlane - nearPlane); 95 mCustomProjMatrix[3][3] = 1; 96 } 97 98 void BillboardCloudTextureViewMode::saveTextureAtlas() 99 { 100 if (mBitRange == 32) 101 { 102 mDestPixelFormat = Ogre::PF_FLOAT32_RGBA; 103 } 104 else if (mBitRange == 16) 105 { 106 mDestPixelFormat = Ogre::PF_FLOAT16_RGBA; 107 } 108 else // mBitRange == 8 109 { 110 mDestPixelFormat = Ogre::PF_BYTE_RGBA; 111 } 112 113 Ogre::String textureAtlasFileName = BBC::Util::getBaseName(mTextureAtlasName) + Ogre::StringConverter::toString(mCurrentBillboardGroup) + "." + BBC::Util::getExtensionName(mTextureAtlasName); 114 mTextureAtlas->save(mTextureAtlasFolder, textureAtlasFileName, mDestPixelFormat); 115 } 116 117 void BillboardCloudTextureViewMode::disableEntityClusterCustomOrthogonalCameraMaterial(unsigned int iEntityClusterGrouped) 118 { 119 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->setVertexProgram(""); 120 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->setFragmentProgram(""); 121 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->reload(); 122 } 123 124 void BillboardCloudTextureViewMode::enableEntityClusterCustomOrthogonalCameraMaterial(unsigned int iEntityClusterGrouped) 125 { 126 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->setVertexProgram("diffuseTextureVP"); 127 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->setFragmentProgram("diffuseTextureFP"); 128 129 Ogre::GpuProgramParametersSharedPtr vertParams; 130 Ogre::GpuProgramParametersSharedPtr fragParams; 131 vertParams = mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->getVertexProgramParameters(); 132 fragParams = mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters(); 133 134 vertParams->setNamedConstant("projectionmatrix", mCamera->getProjectionMatrixWithRSDepth()); 135 vertParams->setNamedAutoConstant("worldmatrix", Ogre::GpuProgramParameters::ACT_WORLD_MATRIX); 136 vertParams->setNamedAutoConstant("viewmatrix", Ogre::GpuProgramParameters::ACT_VIEW_MATRIX); 137 mEntityClustersGrouped->getSubEntity(iEntityClusterGrouped)->getMaterial()->reload(); 138 } 139 140 void BillboardCloudTextureViewMode::configureTexture() 141 { 142 mTextureAtlas->getRectangle2D()->setVisible(false); 143 mEntityClustersGrouped->getSubEntity((mCurrentTexture-1) % mEntityClustersGrouped->getNumSubEntities())->setVisible(false); 144 mEntityClustersGrouped->getSubEntity(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->setVisible(true); 145 146 configureBillboardOrthogonalAlignedCamera(mCurrentTexture % mBillboardCloudSplitted->getNumSubEntities()); 147 mCamera->setCustomProjectionMatrix(true,mCustomProjMatrix); 148 149 if (mDebugTextureAtlasGeneration) 150 { 151 mClusterTexture->getMaterial()->getTechnique(0)->getPass(0)->setAmbient(Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0)); 152 mClusterTexture->getMaterial()->getTechnique(0)->getPass(0)->setDiffuse(Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0), 1.0); 153 } 154 } 155 156 void BillboardCloudTextureViewMode::generateTexture() 157 { 158 configureTexture(); 159 160 enableEntityClusterCustomOrthogonalCameraMaterial(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities()); 161 162 mClusterTexture->update(); 163 164 disableEntityClusterCustomOrthogonalCameraMaterial(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities()); 165 } 166 167 void BillboardCloudTextureViewMode::initializeEntityClustersGrouped() 168 { 169 if (mFrame == 1) 170 { 171 for (unsigned int iSubEntity = 0; iSubEntity < mEntityClustersGrouped->getNumSubEntities(); iSubEntity++) 172 { 173 mEntityClustersGrouped->getSubEntity(iSubEntity)->setVisible(false); 174 } 175 } 176 } 177 178 void BillboardCloudTextureViewMode::initializeBillboardCloudSplitted() 179 { 180 if (mFrame == 1) 181 { 182 for (unsigned int iSubEntity = 0; iSubEntity < mBillboardCloudSplitted->getNumSubEntities(); iSubEntity++) 183 { 184 mBillboardCloudSplitted->getSubEntity(iSubEntity)->setVisible(false); 185 } 186 } 187 } 188 189 bool BillboardCloudTextureViewMode::processUnbufferedKeyInput(const Ogre::FrameEvent& evt) 190 { 191 if (mInputDevice->isKeyDown(Ogre::KC_SPACE)) 192 { 193 mCurrentTexture++; 194 } 195 196 return OgreFrameListenerMode::processUnbufferedKeyInput(evt); 197 } 198 199 void BillboardCloudTextureViewMode::configureTextureAtlas() 200 { 201 mEntityClustersGrouped->getSubEntity(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->setVisible(false); 202 203 mClusterTexture->getRectangle2D()->setVisible(true); 204 mTextureAtlas->getRectangle2D()->setVisible(true); 205 206 Ogre::Vector2 uvMapMax = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboard(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->getBillboardClusterData()->getBillboardUVMapMax(0); 207 Ogre::Vector2 uvMapMin = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboard(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->getBillboardClusterData()->getBillboardUVMapMin(0); 208 209 mClusterTexture->setCorners(uvMapMin[0], uvMapMax[1], uvMapMax[0], uvMapMin[1]); 210 } 211 212 void BillboardCloudTextureViewMode::generateTextureAtlas() 213 { 214 configureTextureAtlas(); 215 216 mTextureAtlas->update(); 217 //mTextureAtlas->debug(); 218 219 mClusterTexture->getRectangle2D()->setVisible(false); 220 } 221 20 222 bool BillboardCloudTextureViewMode::frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader) 21 223 { 22 if (mFrame == 1) 23 { 24 for (unsigned int iSubEntity = 0; iSubEntity < mClusterizedEntities->getNumSubEntities(); iSubEntity++) 224 initializeEntityClustersGrouped(); 225 initializeBillboardCloudSplitted(); 226 227 if (mFrame > 1) 228 { 229 if (!mDebugBillboardGeneration) 25 230 { 26 mClusterizedEntities->getSubEntity(iSubEntity)->setVisible(false); 231 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(1.0, 1.0, 1.0, 1.0)); 232 233 if (mCurrentTexture < mNumTextures) 234 { 235 generateTexture(); 236 237 generateTextureAtlas(); 238 239 mCurrentTexture++; 240 mCurrentBillboard++; 241 242 unsigned int numBillboardsCurrentGroups = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboardGroup(mCurrentBillboardGroup)->getNumBillboards(); 243 244 if (mCurrentBillboard == numBillboardsCurrentGroups) 245 { 246 saveTextureAtlas(); 247 248 unsigned int numBillboardGroups = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getNumBillboardGroups(); 249 250 if (mCurrentBillboardGroup < numBillboardGroups) 251 { 252 mCurrentBillboard = 0; 253 mCurrentBillboardGroup++; 254 255 mTextureAtlas->getRectangle2D()->setVisible(false); 256 mTextureAtlas->update(); 257 //mTextureAtlas->debug(); 258 } 259 } 260 } 261 262 if (mCurrentTexture == mNumTextures) 263 { 264 mDebugBillboardGeneration = true; 265 266 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 267 268 mTextureAtlas->getRectangle2D()->setVisible(false); 269 270 mCurrentTexture = 0; 271 } 27 272 } 28 } 29 30 if (mFrame > 1) 31 { 32 mClusterizedEntities->getSubEntity((mCurrentTexture-1) % mClusterizedEntities->getNumSubEntities())->setVisible(false); 33 } 34 35 if (mFrame == 1) 36 { 37 mTextureAtlas->update(); 38 } 39 40 if (mFrame > 1) 41 { 42 mClusterizedEntities->getSubEntity(mCurrentTexture % mClusterizedEntities->getNumSubEntities())->setVisible(true); 43 mClusterTextureListener.setSubEntityVisible(mCurrentTexture% mClusterizedEntities->getNumSubEntities()); 44 mClusterTexture->update(); 45 46 //if (mCurrentTexture <= mNumTextures) 273 else 47 274 { 48 mClusterizedEntities->getSubEntity(mCurrentTexture)->setVisible(false); 49 mClusterTexture->getMaterial()->getTechnique(0)->getPass(0)->setAmbient( Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0), Ogre::Math::RangeRandom(0.0,1.0) ); 50 mClusterTexture->getRectangle2D()->setVisible(true); 51 mTextureAtlas->getRectangle2D()->setVisible(true); 52 Ogre::Vector2 uvMapMax = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboard(mCurrentTexture)->getBillboardClusterData()->getBillboardUVMapMax(0); 53 Ogre::Vector2 uvMapMin = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves()->getBillboardCloud()->getBillboard(mCurrentTexture)->getBillboardClusterData()->getBillboardUVMapMin(0); 54 mClusterTexture->setCorners(uvMapMin[0], uvMapMax[1], uvMapMax[0], uvMapMin[1]); 55 mClusterTexture->getMaterial()->getTechnique(0)->getPass(0)->setAmbient(uvMapMax[0], uvMapMax[1], 0.0); 56 mTextureAtlas->update(); 57 //mTextureAtlas->debug(); 58 mClusterTexture->getRectangle2D()->setVisible(false); 59 60 Ogre::LogManager::getSingleton().logMessage("Billboard(" + Ogre::StringConverter::toString(mCurrentTexture) + ") uvMapMin(" + Ogre::StringConverter::toString(uvMapMin[0]) + "," + 61 Ogre::StringConverter::toString(uvMapMin[1]) + ") uvMapMax(" + Ogre::StringConverter::toString(uvMapMax[0]) + "," + 62 Ogre::StringConverter::toString(uvMapMax[1]) + ")"); 63 Ogre::LogManager::getSingleton().logMessage( 64 "USize(" + Ogre::StringConverter::toString(Ogre::Math::Abs(uvMapMax[0]-uvMapMin[0])) + 65 "," + Ogre::StringConverter::toString(Ogre::Math::Abs(uvMapMax[1]-uvMapMin[1])) + ")"); 66 67 mCurrentTexture++; 68 69 if (mCurrentTexture == mNumTextures) 70 { 71 if (mBitRange == 32) 72 { 73 mDestPixelFormat = Ogre::PF_FLOAT32_RGBA; 74 } 75 else if (mBitRange == 16) 76 { 77 mDestPixelFormat = Ogre::PF_FLOAT16_RGBA; 78 } 79 else // mBitRange == 8 80 { 81 mDestPixelFormat = Ogre::PF_BYTE_RGBA; 82 } 83 mTextureAtlas->save(mTextureAtlasFolder, mTextureAtlasName, mDestPixelFormat); 84 } 275 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0, 1.0)); 276 277 configureBillboard(); 278 279 configureTexture(); 85 280 86 281 mCurrentTexture = mCurrentTexture % mNumTextures; 87 } 282 } 88 283 } 89 284 … … 93 288 } 94 289 290 void BillboardCloudTextureViewMode::configureBillboard() 291 { 292 mBillboardCloudSplitted->getSubEntity((mCurrentTexture-1) % mEntityClustersGrouped->getNumSubEntities())->setVisible(false); 293 mBillboardCloudSplitted->getSubEntity(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->setVisible(true); 294 } 295 95 296 void BillboardCloudTextureViewMode::setTextureAtlasSize(unsigned int size) 96 297 { … … 98 299 } 99 300 100 void BillboardCloudTextureViewMode::setEntityName(Ogre::String entityName) 101 { 102 mEntityName = entityName; 301 void BillboardCloudTextureViewMode::setEntityClustersGroupedName(Ogre::String entityClustersGroupedName) 302 { 303 mEntityClustersGroupedName = entityClustersGroupedName; 304 } 305 306 void BillboardCloudTextureViewMode::setBillboardCloudSplittedName(Ogre::String billboardCloudSplittedName) 307 { 308 mBillboardCloudSplittedName = billboardCloudSplittedName; 103 309 } 104 310 … … 123 329 } 124 330 331 void BillboardCloudTextureViewMode::setTextureName(Ogre::String textureName) 332 { 333 mTextureName = textureName; 334 } 335 125 336 void BillboardCloudTextureViewMode::createScene() 126 337 { … … 139 350 140 351 LBBC::Leaves *mLeaves = ((LBBC::LBBCManager*)LBBC::LBBCManager::getSingletonPtr())->getLeaves(); 141 Ogre::LogManager::getSingleton().logMessage("Num.Billboards:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getNumBillboards()));142 Ogre::LogManager::getSingleton().logMessage("Num.BillboardGroups:" + Ogre::StringConverter::toString(mLeaves->getBillboardCloud()->getNumBillboardGroups()));143 352 Ogre::Vector2 uvMapMax = mLeaves->getBillboardCloud()->getBillboard(0)->getBillboardClusterData()->getBillboardUVMapMax(0); 144 353 Ogre::Vector2 uvMapMin = mLeaves->getBillboardCloud()->getBillboard(0)->getBillboardClusterData()->getBillboardUVMapMin(0); 145 Ogre::LogManager::getSingleton().logMessage("BillboardUVMapMax:" + Ogre::StringConverter::toString( Ogre::Vector3(uvMapMax[0], uvMapMax[1], 0.0) )); 146 Ogre::LogManager::getSingleton().logMessage("BillboardUVMapMin:" + Ogre::StringConverter::toString( Ogre::Vector3(uvMapMin[0], uvMapMin[1], 0.0) )); 147 148 mClusterizedEntitiesMergedSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 149 Ogre::LogManager::getSingleton().logMessage("Mesh:" + mEntityName); 150 std::cin.get(); 151 152 mClusterizedEntities = mSceneMgr->createEntity(mEntityName, mEntityName); 153 //mClusterizedEntities = mSceneMgr->createEntity("mapleLeavesClusterizedEntitiesMerged.mesh", "mapleLeavesClusterizedEntitiesMerged.mesh"); 154 mClusterizedEntitiesMergedSceneNode->attachObject(mClusterizedEntities); 354 355 IMG::TexturePtr texturePtr ( new IMG::Texture() ); 356 texturePtr->bind(mTextureName); 357 Ogre::ColourValue avgColour = texturePtr->getAvgColour(); 358 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(1.0, 1.0, 1.0, 1.0)); 359 360 mEntityClustersGroupedSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 361 mBillboardCloudSplittedSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 362 363 mEntityClustersGrouped = mSceneMgr->createEntity(mEntityClustersGroupedName, mEntityClustersGroupedName); 364 mEntityClustersGroupedSceneNode->attachObject(mEntityClustersGrouped); 365 366 mBillboardCloudSplitted = mSceneMgr->createEntity(mBillboardCloudSplittedName, mBillboardCloudSplittedName); 367 mBillboardCloudSplittedSceneNode->attachObject(mBillboardCloudSplitted); 155 368 156 369 mTextureAtlas = IMG::TextureAtlasPtr( new IMG::TextureAtlas() ); 157 mTextureAtlas->create("TextureAtlas", mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera );370 mTextureAtlas->create("TextureAtlas", mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera, avgColour); 158 371 mTextureAtlas->setRenderTargetListener(&mTextureAtlasListener); 159 mTextureAtlas->setTextureAtlasSceneNode(m ClusterizedEntitiesMergedSceneNode);372 mTextureAtlas->setTextureAtlasSceneNode(mEntityClustersGroupedSceneNode); 160 373 Ogre::MaterialPtr materialPtr1 = Ogre::MaterialManager::getSingleton().create("textureAtlasMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 161 materialPtr1->getTechnique(0)->getPass(0)->setDiffuse( 1.0, 1.0, 1.0, 1.0);162 374 materialPtr1->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 163 375 materialPtr1->getTechnique(0)->getPass(0)->createTextureUnitState("transparent.png"); 164 376 materialPtr1->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE); 165 377 materialPtr1->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP); 378 materialPtr1->getTechnique(0)->getPass(0)->setLightingEnabled(false); 166 379 mTextureAtlas->setMaterial(materialPtr1.getPointer()); 167 380 mTextureAtlas->setCorners(-1.0, 1.0, 1.0, -1.0); 168 381 169 382 mClusterTexture = IMG::TexturePtr( new IMG::Texture() ); 170 mClusterTexture->create("clusterTexture", mTextureSize, mTextureSize, mSrcPixelFormat, mCamera );383 mClusterTexture->create("clusterTexture", mTextureSize, mTextureSize, mSrcPixelFormat, mCamera, avgColour); 171 384 mClusterTexture->setRenderTargetListener(&mClusterTextureListener); 172 Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().create("textureMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 173 materialPtr->getTechnique(0)->getPass(0)->setAmbient( 1.0, Ogre::Math::RangeRandom(0.5,1.0), 1.0 ); 174 materialPtr->getTechnique(0)->getPass(0)->setDiffuse( 1.0, 1.0, 1.0, 1.0 ); 175 //materialPtr->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 176 //materialPtr->getTechnique(0)->getPass(0)->createTextureUnitState("clusterTexture", 0); 385 Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().create("textureMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 386 if (!mDebugTextureAtlasGeneration) 387 { 388 materialPtr->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 389 materialPtr->getTechnique(0)->getPass(0)->createTextureUnitState("clusterTexture", 0); 390 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE); 391 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP); 392 materialPtr->getTechnique(0)->getPass(0)->setLightingEnabled(false); 393 } 177 394 mClusterTexture->setMaterial(materialPtr.getPointer()); 178 395 179 396 mTextureAtlas->addTexture(mClusterTexture); 180 397 181 mClusterTextureListener.setNumTextures(m ClusterizedEntities->getNumSubEntities());398 mClusterTextureListener.setNumTextures(mEntityClustersGrouped->getNumSubEntities()); 182 399 mClusterTextureListener.setTextureAtlas(mTextureAtlas); 183 400 mClusterTextureListener.setTexture(mClusterTexture); 184 mClusterTextureListener.setEntity (mClusterizedEntities);185 186 mNumTextures = m ClusterizedEntities->getNumSubEntities();401 mClusterTextureListener.setEntityClusters(mEntityClustersGrouped); 402 403 mNumTextures = mEntityClustersGrouped->getNumSubEntities(); 187 404 mCurrentTexture = 0; 188 405 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardKMeansClusterData.cpp
r745 r751 181 181 if (iBillboardGroup >= 0) 182 182 { 183 //uvMapMin = billboardNode->ToElement()->InsertEndChild(TiXmlElement("uvMapMin"))->ToElement(); 184 //Ogre::String sUvMapMinX = Ogre::StringConverter::toString(this->getBillboardUVMapMin(iBillboardGroup).x); 185 //uvMapMin->ToElement()->SetAttribute("x",sUvMapMinX.c_str()); 186 //Ogre::String sUvMapMinY = Ogre::StringConverter::toString(this->getBillboardUVMapMin(iBillboardGroup).y); 187 //uvMapMin->ToElement()->SetAttribute("y",sUvMapMinY.c_str()); 188 189 //uvMapMax = billboardNode->ToElement()->InsertEndChild(TiXmlElement("uvMapMax"))->ToElement(); 190 //Ogre::String suvMapMaxX = Ogre::StringConverter::toString(this->getBillboardUVMapMax(iBillboardGroup).x); 191 //uvMapMax->ToElement()->SetAttribute("x",suvMapMaxX.c_str()); 192 //Ogre::String suvMapMaxY = Ogre::StringConverter::toString(this->getBillboardUVMapMax(iBillboardGroup).y); 193 //uvMapMax->ToElement()->SetAttribute("y",suvMapMaxY.c_str()); 194 183 195 uvMapMin = billboardNode->ToElement()->InsertEndChild(TiXmlElement("uvMapMin"))->ToElement(); 184 Ogre::String sUvMapMinX = Ogre::StringConverter::toString(this->getBillboardUVMapMin( iBillboardGroup).x);196 Ogre::String sUvMapMinX = Ogre::StringConverter::toString(this->getBillboardUVMapMin(0).x); 185 197 uvMapMin->ToElement()->SetAttribute("x",sUvMapMinX.c_str()); 186 Ogre::String sUvMapMinY = Ogre::StringConverter::toString(this->getBillboardUVMapMin( iBillboardGroup).y);198 Ogre::String sUvMapMinY = Ogre::StringConverter::toString(this->getBillboardUVMapMin(0).y); 187 199 uvMapMin->ToElement()->SetAttribute("y",sUvMapMinY.c_str()); 188 200 189 201 uvMapMax = billboardNode->ToElement()->InsertEndChild(TiXmlElement("uvMapMax"))->ToElement(); 190 Ogre::String suvMapMaxX = Ogre::StringConverter::toString(this->getBillboardUVMapMax( iBillboardGroup).x);202 Ogre::String suvMapMaxX = Ogre::StringConverter::toString(this->getBillboardUVMapMax(0).x); 191 203 uvMapMax->ToElement()->SetAttribute("x",suvMapMaxX.c_str()); 192 Ogre::String suvMapMaxY = Ogre::StringConverter::toString(this->getBillboardUVMapMax( iBillboardGroup).y);204 Ogre::String suvMapMaxY = Ogre::StringConverter::toString(this->getBillboardUVMapMax(0).y); 193 205 uvMapMax->ToElement()->SetAttribute("y",suvMapMaxY.c_str()); 194 206 } … … 209 221 210 222 void BillboardKMeansClusterData::generateBillboardBoundingQuad() 211 { 212 223 { 213 224 Ogre::Vector3 normal = getNormal(); 214 225 Ogre::Vector3 planePosition; … … 333 344 } 334 345 } 346 347 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 348 { 349 LeafKMeansClusterData *leafKMeansClusterData = (LeafKMeansClusterData*)entityCluster->getEntityClusterData(iLeaf).get(); 350 Leaf *leaf = (Leaf*)leafKMeansClusterData->getEntity().get(); 351 352 Ogre::Vector3 position = leaf->getPosition(); 353 Ogre::Vector4 projPointP1d4 = Ogre::Vector4(position.x,position.y,position.z,1.0f) * invMCoordPlane * constCoord * coordPlane; 354 355 // The point projected in the plane 356 Ogre::Vector3 projPointP1(projPointP1d4.x,projPointP1d4.y,projPointP1d4.z); 357 358 leaf->setPosition(projPointP1); 359 } 335 360 336 361 Ogre::Vector3 aP; -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCEntityTextureAtlasViewMode.cpp
r747 r751 10 10 mTextureAtlasGenerated = false; 11 11 mFrame = 0; 12 mDebugOverlay->setScale(0.0, 0.0);12 showDebugOverlay(false); 13 13 } 14 14 … … 49 49 } 50 50 51 unsigned int EntityTextureAtlasViewMode::nextPowerOf2(unsigned int nPlanes)52 {53 unsigned int depth = 1;54 while (depth < nPlanes)55 {56 depth = depth << 1;57 }58 return depth;59 }60 61 51 bool EntityTextureAtlasViewMode::frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader) 62 52 { 53 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(1.0, 1.0, 1.0, 1.0)); 54 63 55 if (mFrame == 1) 56 { 57 mTextureAtlas->getTextureAtlasSceneNode()->setVisible(false); 58 mTextureAtlas->update(); 59 mTextureAtlas->getTextureAtlasSceneNode()->setVisible(true); 60 } 61 62 if (mFrame == 2) 64 63 { 65 64 if (!mTextureAtlasGenerated) … … 93 92 void EntityTextureAtlasViewMode::createScene() 94 93 { 94 IMG::TexturePtr texturePtr ( new IMG::Texture() ); 95 texturePtr->bind(mTextureName); 96 Ogre::ColourValue avgColour = texturePtr->getAvgColour(); 97 mWindow->getViewport(0)->setBackgroundColour(Ogre::ColourValue(1.0, 1.0, 1.0, 1.0)); 98 95 99 mTextureAtlasNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 96 100 mTextureAtlas = IMG::TextureAtlasPtr( new IMG::TextureAtlas() ); … … 109 113 } 110 114 111 mTextureAtlas->create(mTextureAtlasName, mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera );115 mTextureAtlas->create(mTextureAtlasName, mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera, avgColour); 112 116 mTextureAtlas->setTextureAtlasSceneNode(mTextureAtlasNode); 113 117 … … 116 120 unsigned int irow = 1; 117 121 unsigned int icol = 1; 118 unsigned int nrow = Ogre::Math::Sqrt( nextPowerOf2(numSubTextures));122 unsigned int nrow = Ogre::Math::Sqrt(BBC::Util::nextPowerOf2(numSubTextures)); 119 123 Ogre::Real step = 2.0 / nrow; 120 124 Ogre::Real degreeStep = 360.0 / numSubTextures; 121 125 Ogre::Real degree = 0.0; 122 126 123 IMG::TexturePtr texturePtr ( new IMG::Texture() );124 texturePtr->bind(mTextureName);125 127 Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().create("TextureAtlas" + Ogre::StringConverter::toString(numSubTextures), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 126 materialPtr->getTechnique(0)->getPass(0)->setDiffuse( 1.0, 1.0, 1.0, 0.0); 127 materialPtr->getTechnique(0)->getPass(0)->setAmbient( texturePtr->getAvgColour() ); 128 materialPtr->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 129 materialPtr->getTechnique(0)->getPass(0)->createTextureUnitState("transparent.png"); 130 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE); 131 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP); 132 materialPtr->getTechnique(0)->getPass(0)->setLightingEnabled(false); 128 133 mTextureAtlas->setMaterial(materialPtr.getPointer()); 129 134 mTextureAtlas->setCorners(-1.0, 1.0, 1.0, -1.0); … … 133 138 IMG::TexturePtr texturePtr = IMG::TexturePtr( new IMG::Texture() ); 134 139 Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().create("TextureAtlas" + Ogre::StringConverter::toString(iSubTexture), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 135 materialPtr->getTechnique(0)->getPass(0)->setAmbient(maxTexCoords[0], maxTexCoords[1], 1.0 ); 136 materialPtr->getTechnique(0)->getPass(0)->setDiffuse( 1.0, 1.0, 1.0, 1.0); 140 materialPtr->getTechnique(0)->getPass(0)->setAmbient(Ogre::Math::RangeRandom(1.0, 0.0), 1.0, 0.0); 141 materialPtr->getTechnique(0)->getPass(0)->setDiffuse(1.0, 1.0, 1.0, 1.0); 142 //materialPtr->getTechnique(0)->getPass(0)->setLightingEnabled(false); 137 143 materialPtr->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 138 144 materialPtr->getTechnique(0)->getPass(0)->createTextureUnitState(mTextureName, 0); 139 145 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE); 140 146 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP); 141 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Radian(Ogre::Degree(degree))); 142 materialPtr->getTechnique(0)->getPass(0)->setLightingEnabled(false); 147 materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureRotate(Ogre::Radian(Ogre::Degree(degree))); 143 148 144 149 texturePtr->setMaterial(materialPtr.getPointer()); -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKMeansClusterGenerator.cpp
r721 r751 74 74 void KMeansClusterGenerator::recomputeBillboard(BBC::BillboardPtr billboard) 75 75 { 76 Ogre::Matrix3 nmii = Ogre::Matrix3::ZERO;77 Ogre::Matrix3 nmiiSum = Ogre::Matrix3::ZERO;78 Ogre::Matrix3 miiSum = Ogre::Matrix3::ZERO;79 Ogre::Matrix3 mii = Ogre::Matrix3::ZERO;80 Ogre::Matrix3 mijSum = Ogre::Matrix3::ZERO;81 Ogre::Matrix3 mij = Ogre::Matrix3::ZERO;82 Ogre::Vector3 lastY = Ogre::Vector3::ZERO;83 Ogre::Vector3 piSum = Ogre::Vector3::ZERO;84 Ogre::Vector3 normSum = Ogre::Vector3::ZERO;85 86 76 BillboardKMeansClusterData *billboardClusterData = (BillboardKMeansClusterData*)billboard->getBillboardClusterData().get(); 87 77 BBC::EntityClusterPtr entityCluster = billboardClusterData->getEntityCluster(); 88 78 89 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 90 { 91 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 92 Ogre::Vector3 pi = leaf->getPosition(); 93 Ogre::Vector3 norm2 = leaf->getLeafNormal(); 94 piSum = piSum + pi * (1.0 / (float)entityCluster->getNumEntitiesClusterData()); 79 if (entityCluster->getNumEntitiesClusterData() > 1) 80 { 81 Ogre::Matrix3 nmii = Ogre::Matrix3::ZERO; 82 Ogre::Matrix3 nmiiSum = Ogre::Matrix3::ZERO; 83 Ogre::Matrix3 miiSum = Ogre::Matrix3::ZERO; 84 Ogre::Matrix3 mii = Ogre::Matrix3::ZERO; 85 Ogre::Matrix3 mijSum = Ogre::Matrix3::ZERO; 86 Ogre::Matrix3 mij = Ogre::Matrix3::ZERO; 87 Ogre::Vector3 lastY = Ogre::Vector3::ZERO; 88 Ogre::Vector3 piSum = Ogre::Vector3::ZERO; 89 Ogre::Vector3 normSum = Ogre::Vector3::ZERO; 90 91 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 92 { 93 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 94 Ogre::Vector3 pi = leaf->getPosition(); 95 Ogre::Vector3 norm2 = leaf->getLeafNormal(); 96 piSum = piSum + pi * (1.0 / (float)entityCluster->getNumEntitiesClusterData()); 97 98 mii[0][0] = pi.x * pi.x; 99 mii[0][1] = pi.x * pi.y; 100 mii[0][2] = pi.x * pi.z; 101 mii[1][0] = pi.y * pi.x; 102 mii[1][1] = pi.y * pi.y; 103 mii[1][2] = pi.y * pi.z; 104 mii[2][0] = pi.z * pi.x; 105 mii[2][1] = pi.z * pi.y; 106 mii[2][2] = pi.z * pi.z; 107 nmii[0][0] = norm2.x * norm2.x; 108 nmii[0][1] = norm2.x * norm2.y; 109 nmii[0][2] = norm2.x * norm2.z; 110 nmii[1][0] = norm2.y * norm2.x; 111 nmii[1][1] = norm2.y * norm2.y; 112 nmii[1][2] = norm2.y * norm2.z; 113 nmii[2][0] = norm2.z * norm2.x; 114 nmii[2][1] = norm2.z * norm2.y; 115 nmii[2][2] = norm2.z * norm2.z; 95 116 96 mii[0][0] = pi.x * pi.x; 97 mii[0][1] = pi.x * pi.y; 98 mii[0][2] = pi.x * pi.z; 99 mii[1][0] = pi.y * pi.x; 100 mii[1][1] = pi.y * pi.y; 101 mii[1][2] = pi.y * pi.z; 102 mii[2][0] = pi.z * pi.x; 103 mii[2][1] = pi.z * pi.y; 104 mii[2][2] = pi.z * pi.z; 105 nmii[0][0] = norm2.x * norm2.x; 106 nmii[0][1] = norm2.x * norm2.y; 107 nmii[0][2] = norm2.x * norm2.z; 108 nmii[1][0] = norm2.y * norm2.x; 109 nmii[1][1] = norm2.y * norm2.y; 110 nmii[1][2] = norm2.y * norm2.z; 111 nmii[2][0] = norm2.z * norm2.x; 112 nmii[2][1] = norm2.z * norm2.y; 113 nmii[2][2] = norm2.z * norm2.z; 117 nmiiSum = nmiiSum + ( nmii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 118 119 miiSum = miiSum + ( mii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 120 121 // Generate the initial value for the iterative method as the average... 122 Ogre::Vector3 norm = leaf->getLeafNormal(); 123 lastY = lastY + norm; 124 125 // Generate the sum normal of all the leaves associated to the plane... 126 normSum = normSum + norm; 127 } 114 128 115 nmiiSum = nmiiSum + ( nmii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 116 117 miiSum = miiSum + ( mii * (1.0 / (float)entityCluster->getNumEntitiesClusterData())); 118 119 // Generate the initial value for the iterative method as the average... 120 Ogre::Vector3 norm = leaf->getLeafNormal(); 121 lastY = lastY + norm; 122 123 // Generate the sum normal of all the leaves associated to the plane... 124 normSum = normSum + norm; 125 } 126 127 mijSum[0][0] = piSum.x * piSum.x; 128 mijSum[0][1] = piSum.x * piSum.y; 129 mijSum[0][2] = piSum.x * piSum.z; 130 mijSum[1][0] = piSum.y * piSum.x; 131 mijSum[1][1] = piSum.y * piSum.y; 132 mijSum[1][2] = piSum.y * piSum.z; 133 mijSum[2][0] = piSum.z * piSum.x; 134 mijSum[2][1] = piSum.z * piSum.y; 135 mijSum[2][2] = piSum.z * piSum.z; 136 137 Ogre::Matrix3 mA = miiSum - mijSum; 138 mA = mA - (mAlpha * nmiiSum); 139 mA = mA.Inverse(); 140 141 lastY.normalise(); 142 normSum.normalise(); 143 144 // Apply the iterative approach 145 Ogre::Vector3 currY; 146 currY = mA * lastY; 147 currY.normalise(); 148 149 for(unsigned int icount = 0; icount < 100; icount++) 150 { 151 lastY = currY; 129 mijSum[0][0] = piSum.x * piSum.x; 130 mijSum[0][1] = piSum.x * piSum.y; 131 mijSum[0][2] = piSum.x * piSum.z; 132 mijSum[1][0] = piSum.y * piSum.x; 133 mijSum[1][1] = piSum.y * piSum.y; 134 mijSum[1][2] = piSum.y * piSum.z; 135 mijSum[2][0] = piSum.z * piSum.x; 136 mijSum[2][1] = piSum.z * piSum.y; 137 mijSum[2][2] = piSum.z * piSum.z; 138 139 Ogre::Matrix3 mA = miiSum - mijSum; 140 mA = mA - (mAlpha * nmiiSum); 141 mA = mA.Inverse(); 142 143 lastY.normalise(); 144 normSum.normalise(); 145 146 // Apply the iterative approach 147 Ogre::Vector3 currY; 152 148 currY = mA * lastY; 153 149 currY.normalise(); 154 } 155 156 // Generate the d parameter... 157 float sumD = 0; 158 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 159 { 160 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 161 Ogre::Vector3 pi = leaf->getPosition(); 162 sumD = sumD + pi.dotProduct(currY); 163 } 164 165 sumD = - sumD / (float)entityCluster->getNumEntitiesClusterData(); 166 167 billboardClusterData->setNormal(currY); 168 billboardClusterData->setD(sumD); 150 151 for(unsigned int icount = 0; icount < 100; icount++) 152 { 153 lastY = currY; 154 currY = mA * lastY; 155 currY.normalise(); 156 } 157 158 // Generate the d parameter... 159 float sumD = 0; 160 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 161 { 162 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(iLeaf)->getEntity().get(); 163 Ogre::Vector3 pi = leaf->getPosition(); 164 sumD = sumD + pi.dotProduct(currY); 165 } 166 167 sumD = - sumD / (float)entityCluster->getNumEntitiesClusterData(); 168 169 billboardClusterData->setNormal(currY); 170 billboardClusterData->setD(sumD); 171 } 172 else if (entityCluster->getNumEntitiesClusterData() == 1) 173 { 174 Leaf* leaf = (Leaf*)entityCluster->getEntityClusterData(0)->getEntity().get(); 175 billboardClusterData->setNormal(leaf->getLeafNormal()); 176 billboardClusterData->setD(leaf->getLeafD()); 177 } 169 178 } 170 179 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCKMeansClusterSerializer.cpp
r745 r751 17 17 unsigned int numBillboardGroups = Ogre::StringConverter::parseInt(billboardGroupsNode->ToElement()->Attribute("count")); 18 18 19 for (unsigned int iBillboardGroup = 0; iBillboardGroup < numBillboardGroups; iBillboardGroup++) 19 unsigned int iBillboardGroup = 0; 20 for (TiXmlNode *billboardGroupNode = billboardGroupsNode->FirstChild("billboardGroup"); billboardGroupNode; billboardGroupNode = billboardGroupNode->NextSibling() ) 20 21 { 21 TiXmlNode *billboardGroupNode = billboardGroupsNode->FirstChild("billboardGroup");22 23 22 unsigned int numBillboards = Ogre::StringConverter::parseInt(billboardGroupNode->ToElement()->Attribute("count")); 24 23 … … 49 48 } 50 49 } 50 iBillboardGroup++; 51 51 } 52 52 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCLeafDistributionGenerator.cpp
r721 r751 186 186 { 187 187 Leaf *leaf = (Leaf*) mEntityDistribution->getEntity(ileaf).get(); 188 leaf->setPosition(leaf->getSubEntity(0)->getUniqueVertex(0).position);188 generateAverageLeafPosition(leaf); 189 189 generateAverageLeafNormal(leaf); 190 190 leaf->setLeafD(-leaf->getLeafNormal().dotProduct(leaf->getPosition())); … … 283 283 } 284 284 285 } 285 void LeafDistributionGenerator::generateAverageLeafPosition(Leaf *leaf) 286 { 287 Ogre::Vector3 aVPosition(0,0,0); 288 for (unsigned int iN = 0; iN < leaf->getSubEntity(0)->getNumVertices(); iN++) 289 { 290 aVPosition = aVPosition + leaf->getSubEntity(0)->getPosition(iN); 291 } 292 aVPosition = aVPosition / leaf->getSubEntity(0)->getNumVertices(); 293 294 leaf->setPosition(aVPosition); 295 } 296 297 } -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp
r747 r751 138 138 mOgreMeshSerializer->setEntity(entity); 139 139 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 140 mSampleConfigFile->getEntityClusters MergedMeshName(), false, false);141 142 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntityClusters MergedMeshName());140 mSampleConfigFile->getEntityClustersGroupedMeshName(), false, false); 141 142 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh((Ogre::Mesh*)entity->getMesh().get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntityClustersGroupedMeshName()); 143 143 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntitiesMeshPrefixName() + "Merged.mesh" + ".xml"); 144 144 } … … 205 205 { 206 206 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 207 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudGroupedMaterialName() );207 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudGroupedMaterialName() + Ogre::StringConverter::toString(iSubEntity)); 208 208 } 209 209 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); … … 233 233 234 234 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudSplittedMeshName()); 235 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudSplittedMeshName() + ".xml");235 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(mLeaves->getBillboardCloud()->getEntity()->getMesh()->get(), mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudSplittedMeshName() + ".xml"); 236 236 } 237 237 … … 241 241 { 242 242 BBC::SubEntityPtr subEntity = mLeaves->getBillboardCloud()->getEntity()->getSubEntity(iSubEntity); 243 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloud GroupedMaterialName());243 subEntity->setMaterialName(mSampleConfigFile->getBillboardCloudMergedMaterialName()); 244 244 } 245 245 mOgreMeshSerializer->setEntity(mLeaves->getBillboardCloud()->getEntity()); … … 346 346 numSerializedBillboards = 0; 347 347 348 if (mSampleConfigFile->getEntityClusters MergedClusters())348 if (mSampleConfigFile->getEntityClustersGroupedClusters()) 349 349 { 350 350 BBC::EntityPtr entity; … … 359 359 { 360 360 BBC::EntityPtr entityClusterized = entityCluster->getEntity(); 361 entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClusters MergedMaterialName());361 entityClusterized->getSubEntity(0)->setMaterialName(mSampleConfigFile->getEntityClustersGroupedMaterialName()); 362 362 BBC::SubEntityPtr subEntity = entityClusterized->getSubEntity(0); 363 363 … … 383 383 mOgreMeshSerializer->setEntity(entity); 384 384 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getEntityClustersFolder() + 385 mSampleConfigFile->getEntityClusters MergedMeshName(), false, false);386 387 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClusters MergedMeshName());385 mSampleConfigFile->getEntityClustersGroupedMeshName(), false, false); 386 387 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersGroupedMeshName()); 388 388 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh(), mSampleConfigFile->getEntityClustersFolder() + mSampleConfigFile->getEntityClustersMeshPrefixName() + "Merged.mesh" + ".xml"); 389 389 } … … 408 408 mSampleConfigFile->getEntitySampleMeshName(), false, false); 409 409 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entityLeaf->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitySampleMeshName()); 410 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitySampleMeshName() + ".xml");410 //OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entityLeaf->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getEntitySampleMeshName() + ".xml"); 411 411 } 412 412 … … 419 419 void LBBCManager::generateBillboardCloud() 420 420 { 421 422 421 if (mSampleConfigFile->getBillboardCloudGroupedBillboards()) 423 422 { … … 425 424 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(mSampleConfigFile->getBillboardCloudGroups()); 426 425 427 if (mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasGeneration()) 428 { 429 mBillboardCloudUVMapper->shutdown(); 430 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 431 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureSize()); 432 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureSize()); 433 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasSize()); 434 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorBillboardGroupTextureAtlasSize()); 435 mBillboardCloudUVMapper->initialize(); 436 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups()); 437 438 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 439 //saveBillboardCloudGrouped(); 440 //saveBillboardCloudGroupedXML(); 441 } 426 mBillboardCloudUVMapper->shutdown(); 427 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 428 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureSize()); 429 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureSize()); 430 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize()); 431 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize()); 432 mBillboardCloudUVMapper->initialize(); 433 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), mSampleConfigFile->getBillboardCloudGroups()); 434 435 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 436 saveBillboardCloudGrouped(); 437 saveBillboardCloudGroupedXML(); 442 438 } 443 439 … … 448 444 mLeaves->getBillboardCloud()->initializeBillboardCloudGroups(1); 449 445 450 if (mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasGeneration()) 451 { 452 mBillboardCloudUVMapper->shutdown(); 453 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 454 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize()); 455 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize()); 456 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize()); 457 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize()); 458 mBillboardCloudUVMapper->initialize(); 459 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1); 460 461 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 462 saveBillboardCloudMerged(); 463 saveBillboardCloudMergedXML(); 464 } 446 mBillboardCloudUVMapper->shutdown(); 447 mBillboardCloudUVMapper->setBillboardCloud(mLeaves->getBillboardCloud()); 448 mBillboardCloudUVMapper->setTextureWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize()); 449 mBillboardCloudUVMapper->setTextureHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureSize()); 450 mBillboardCloudUVMapper->setTextureAtlasWidth(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize()); 451 mBillboardCloudUVMapper->setTextureAtlasHeight(mSampleConfigFile->getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasSize()); 452 mBillboardCloudUVMapper->initialize(); 453 mBillboardCloudUVMapper->generateTextureAtlasTextureCoords(false, mSampleConfigFile->getBillboardCloudGroupedBillboards(), 1); 454 455 mLeaves->getBillboardCloud()->generateBillboardCloudGroups(); 456 saveBillboardCloudMerged(); 457 saveBillboardCloudMergedXML(); 465 458 } 466 459 … … 482 475 saveBillboardCloudXML(); 483 476 } 477 478 saveBillboardCloudIndirectSplittedPointMeshName(); 479 } 480 481 void LBBCManager::saveBillboardCloudIndirectSplittedPointMeshName() 482 { 483 BBC::EntityPtr entity; 484 unsigned int numSubEntities = 0; 485 486 entity = BBC::EntityPtr(new BBC::Entity()); 487 entity->removeSubEntity(0); 488 489 for (unsigned int iBillboard = 0; iBillboard < getLeaves()->getBillboardCloud()->getNumBillboards(); iBillboard++) 490 { 491 BBC::BillboardPtr billboard = getLeaves()->getBillboardCloud()->getBillboard(iBillboard); 492 BBC::EntityClusterPtr entityCluster = billboard->getBillboardClusterData()->getEntityCluster(); 493 494 if (entityCluster->getNumEntitiesClusterData() > 0) 495 { 496 entity->createSubEntity(); 497 entity->getSubEntity(numSubEntities)->setMaterialName(mSampleConfigFile->getBillboardCloudIndirectPointMaterialName()); 498 entity->getSubEntity(numSubEntities)->enableNormals(false); 499 entity->getSubEntity(numSubEntities)->enableTextureCoords(false); 500 entity->getSubEntity(numSubEntities)->enableVertexColours(true); 501 502 for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 503 { 504 BBC::UniqueVertex vertex; 505 506 LeafKMeansClusterData *leafKMeansClusterData = (LeafKMeansClusterData*)entityCluster->getEntityClusterData(iLeaf).get(); 507 Leaf *leaf = (Leaf*)leafKMeansClusterData->getEntity().get(); 508 vertex.position = leaf->getPosition(); 509 vertex.colour = Ogre::ColourValue(Ogre::Math::RangeRandom(0.0, 1.0), Ogre::Math::RangeRandom(0.0, 1.0), Ogre::Math::RangeRandom(0.0, 1.0), 1.0).getAsRGBA(); 510 entity->getSubEntity(numSubEntities)->addUniqueVertex(vertex); 511 } 512 513 unsigned int iVertexFace = 0; 514 Ogre::Vector3 faceVertexIndices = Ogre::Vector3::ZERO; 515 516 for (unsigned int iVertex = 0; iVertex < entity->getSubEntity(numSubEntities)->getNumVertices(); iVertex++) 517 { 518 faceVertexIndices[iVertexFace] = iVertex; 519 iVertexFace++; 520 521 if ((iVertex + 1) != entity->getSubEntity(numSubEntities)->getNumVertices()) 522 { 523 if (iVertexFace == 3) 524 { 525 entity->getSubEntity(numSubEntities)->addFaceVerticesIDs(faceVertexIndices); 526 iVertexFace = 0; 527 faceVertexIndices = Ogre::Vector3::ZERO; 528 } 529 } 530 else 531 { 532 entity->getSubEntity(numSubEntities)->addFaceVerticesIDs(faceVertexIndices); 533 } 534 } 535 536 numSubEntities++; 537 } 538 } 539 540 mOgreMeshSerializer->setEntity(entity); 541 mOgreMeshSerializer->exportMesh(mSampleConfigFile->getBillboardCloudFolder() + mSampleConfigFile->getBillboardCloudIndirectPointMeshName(), false, false); 542 OBA::OgreBase::getSingleton().getMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getBillboardCloudIndirectPointMeshName()); 543 OBA::OgreBase::getSingleton().getXMLMeshSerializer()->exportMesh(entity->getMesh()->get(), mSampleConfigFile->getEntityDistributionFolder() + mSampleConfigFile->getBillboardCloudIndirectPointMeshName() + ".xml"); 544 484 545 } 485 546 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCSampleConfigFile.cpp
r747 r751 102 102 } 103 103 104 bool SampleConfigFile::getEntityClusters MergedClusters()105 { 106 return Ogre::StringConverter::parseBool(getSetting("Entity Clusters Merged Clusters"));104 bool SampleConfigFile::getEntityClustersGroupedClusters() 105 { 106 return Ogre::StringConverter::parseBool(getSetting("Entity Clusters Grouped Clusters")); 107 107 } 108 108 … … 132 132 } 133 133 134 Ogre::String SampleConfigFile::getBillboardCloudIndirectPointMeshName() 135 { 136 return getSetting("Billboard Cloud Indirect Point Mesh Name"); 137 } 138 139 Ogre::String SampleConfigFile::getBillboardCloudIndirectPointMaterialName() 140 { 141 return getSetting("Billboard Cloud Indirect Point Material Name"); 142 } 143 134 144 Ogre::String SampleConfigFile::getEntityClustersFolder() 135 145 { … … 137 147 } 138 148 139 Ogre::String SampleConfigFile::getEntityClusters MergedMeshName()140 { 141 return getSetting("Entity Clusters Merged Mesh Name");149 Ogre::String SampleConfigFile::getEntityClustersGroupedMeshName() 150 { 151 return getSetting("Entity Clusters Grouped Mesh Name"); 142 152 } 143 153 … … 147 157 } 148 158 149 Ogre::String SampleConfigFile::getEntityClusters MergedMaterialName()150 { 151 return getSetting("Entity Clusters Merged Material Name");159 Ogre::String SampleConfigFile::getEntityClustersGroupedMaterialName() 160 { 161 return getSetting("Entity Clusters Grouped Material Name"); 152 162 } 153 163 … … 192 202 } 193 203 204 Ogre::String SampleConfigFile::getEntityClustersGroupedTextureUnit0Name() 205 { 206 return getSetting("Entity Clusters Grouped Texture Unit 0 Name"); 207 } 208 209 Ogre::String SampleConfigFile::getEntityClustersSplittedTextureUnit0Name() 210 { 211 return getSetting("Entity Clusters Splitted Texture Unit 0 Name"); 212 } 213 194 214 Ogre::String SampleConfigFile::getBillboardCloudMergedTextureUnit0Name() 195 215 { … … 207 227 } 208 228 209 Ogre::String SampleConfigFile::getBillboardCloudIndirect BillboardGroupTextureAtlasName()210 { 211 return getSetting("Billboard Cloud Indirect Billboard GroupTexture Atlas Name");229 Ogre::String SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureAtlasName() 230 { 231 return getSetting("Billboard Cloud Indirect Grouped Billboards Texture Atlas Name"); 212 232 } 213 233 … … 217 237 } 218 238 219 unsigned int SampleConfigFile::getBillboardCloudDiffuseColor BillboardGroupTextureSize()220 { 221 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Diffuse Color Billboard GroupTexture Size"));239 unsigned int SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureSize() 240 { 241 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Size")); 222 242 } 223 243 … … 227 247 } 228 248 229 unsigned int SampleConfigFile::getBillboardCloudIndirectBillboardGroupTextureAtlasBitRange() 230 { 231 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Billboard Group Texture Atlas Bit Range")); 232 } 233 234 unsigned int SampleConfigFile::getBillboardCloudIndirectBillboardGroupTextureAtlasSize() 235 { 236 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Billboard Group Texture Atlas Size")); 237 } 238 239 unsigned int SampleConfigFile::getBillboardCloudIndirectBillboardGroupTextureSize() 240 { 241 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Billboard Group Texture Size")); 242 } 243 244 unsigned int SampleConfigFile::getBillboardCloudDiffuseColorBillboardGroupTextureAtlasSize() 245 { 246 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Diffuse Color Billboard Group Texture Atlas Size")); 247 } 248 249 bool SampleConfigFile::getBillboardCloudDiffuseColorBillboardGroupTextureAtlasGeneration() 250 { 251 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Diffuse Color Billboard Group Texture Atlas Generation")); 252 } 253 254 bool SampleConfigFile::getBillboardCloudIndirectBillboardGroupTextureAtlasGeneration() 255 { 256 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Indirect Billboard Group Texture Atlas Generation")); 249 unsigned int SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasBitRange() 250 { 251 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Atlas Bit Range")); 252 } 253 254 unsigned int SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureAtlasBitRange() 255 { 256 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Grouped Billboards Texture Atlas Bit Range")); 257 } 258 259 unsigned int SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureAtlasSize() 260 { 261 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Grouped Billboards Texture Atlas Size")); 262 } 263 264 unsigned int SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureSize() 265 { 266 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Indirect Grouped Billboards Texture Size")); 267 } 268 269 unsigned int SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasSize() 270 { 271 return Ogre::StringConverter::parseInt(getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Atlas Size")); 272 } 273 274 bool SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug() 275 { 276 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Atlas Debug")); 277 } 278 279 bool SampleConfigFile::getBillboardCloudDiffuseColorMergedBillboardsTextureAtlasDebug() 280 { 281 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Diffuse Color Merged Billboards Texture Atlas Debug")); 282 } 283 284 bool SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug() 285 { 286 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Indirect Grouped Billboards Texture Atlas Debug")); 287 } 288 289 bool SampleConfigFile::getBillboardCloudIndirectMergedBillboardsTextureAtlasDebug() 290 { 291 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Indirect Merged Billboards Texture Atlas Debug")); 292 } 293 294 bool SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration() 295 { 296 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Atlas Generation")); 297 } 298 299 bool SampleConfigFile::getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration() 300 { 301 return Ogre::StringConverter::parseBool(getSetting("Billboard Cloud Indirect Grouped Billboards Texture Atlas Generation")); 257 302 } 258 303 … … 272 317 } 273 318 319 Ogre::String SampleConfigFile::getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasName() 320 { 321 return getSetting("Billboard Cloud Diffuse Color Grouped Billboards Texture Atlas Name"); 322 } 323 274 324 Ogre::String SampleConfigFile::getBillboardCloudDiffuseColorEntityTextureAtlasName() 275 325 { -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/OBAOgreFrameListener.cpp
r731 r751 156 156 mDefaultOgreFrameListenerMode = getFrameListenerMode(iOgreFrameListenerMode); 157 157 Ogre::Root::getSingleton()._setCurrentSceneManager(mDefaultOgreFrameListenerMode->getSceneManager()); 158 mWindow->removeAllViewports(); 159 mWindow->addViewport(mDefaultOgreFrameListenerMode->getCamera()); 158 mWindow->getViewport(0)->setCamera(mDefaultOgreFrameListenerMode->getCamera()); 160 159 } 161 160 -
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/OBAOgreFrameListenerMode.cpp
r721 r751 381 381 382 382 // Position it at 500 in Z direction 383 mCamera->setPosition(Ogre::Vector3(0 ,0,500));383 mCamera->setPosition(Ogre::Vector3(0.0, 0.0, 500.0)); 384 384 // Look back along -Z 385 mCamera->lookAt(Ogre::Vector3(0 ,0,-300));386 mCamera->setNearClipDistance(5 );385 mCamera->lookAt(Ogre::Vector3(0.0, 0.0, -300.0)); 386 mCamera->setNearClipDistance(5.0); 387 387 } 388 388 … … 390 390 { 391 391 // Create one viewport, entire window 392 Ogre::Viewport* vp = mWindow->addViewport(mCamera,mOgreFrameListenerModeHandle); 393 vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); 394 395 // Alter the camera aspect ratio to match the viewport 396 mCamera->setAspectRatio( 397 Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); 392 if (mWindow->getNumViewports() == 0) 393 { 394 Ogre::Viewport* vp = mWindow->addViewport(mCamera,mOgreFrameListenerModeHandle); 395 vp->setBackgroundColour(Ogre::ColourValue(0.0, 0.0, 0.0)); 396 } 397 // Alter the camera aspect ratio to match the viewport 398 mCamera->setAspectRatio( 399 Ogre::Real(mWindow->getViewport(0)->getActualWidth()) / Ogre::Real(mWindow->getViewport(0)->getActualHeight())); 400 } 401 402 unsigned int OgreFrameListenerMode::getHandle() 403 { 404 return mOgreFrameListenerModeHandle; 398 405 } 399 406
Note: See TracChangeset
for help on using the changeset viewer.