Ignore:
Timestamp:
04/19/06 00:27:14 (18 years ago)
Author:
igarcia
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCBillboardCloudTextureViewMode.cpp

    r747 r751  
    1010{        
    1111        mFrame = 0; 
    12         mDebugOverlay->setScale(0.0, 0.0); 
     12        mCurrentBillboardGroup = 0; 
     13        mCurrentBillboard = 0; 
     14        showDebugOverlay(false); 
     15        mDebugBillboardGeneration = false; 
     16        mDebugTextureAtlasGeneration = false; 
    1317} 
    1418 
     
    1822} 
    1923 
     24 
     25void BillboardCloudTextureViewMode::setBillboardCloudGroupedTextureAtlasDebug(bool debugTextureAtlasGeneration) 
     26{ 
     27        mDebugTextureAtlasGeneration = debugTextureAtlasGeneration; 
     28} 
     29 
     30void 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 
     98void 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 
     117void 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 
     124void 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 
     140void 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 
     156void BillboardCloudTextureViewMode::generateTexture() 
     157{ 
     158        configureTexture(); 
     159 
     160        enableEntityClusterCustomOrthogonalCameraMaterial(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities()); 
     161         
     162        mClusterTexture->update();               
     163 
     164        disableEntityClusterCustomOrthogonalCameraMaterial(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities()); 
     165} 
     166 
     167void 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 
     178void 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 
     189bool 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 
     199void 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 
     212void BillboardCloudTextureViewMode::generateTextureAtlas() 
     213{        
     214        configureTextureAtlas(); 
     215 
     216        mTextureAtlas->update();                 
     217        //mTextureAtlas->debug(); 
     218         
     219        mClusterTexture->getRectangle2D()->setVisible(false); 
     220} 
     221 
    20222bool BillboardCloudTextureViewMode::frameStarted(const Ogre::FrameEvent& evt, Ogre::InputReader *inputReader) 
    21223{ 
    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) 
    25230                { 
    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                        } 
    27272                } 
    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 
    47274                { 
    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(); 
    85280 
    86281                        mCurrentTexture = mCurrentTexture % mNumTextures; 
    87                 }                
     282                } 
    88283        } 
    89284 
     
    93288} 
    94289 
     290void BillboardCloudTextureViewMode::configureBillboard() 
     291{ 
     292        mBillboardCloudSplitted->getSubEntity((mCurrentTexture-1) % mEntityClustersGrouped->getNumSubEntities())->setVisible(false); 
     293        mBillboardCloudSplitted->getSubEntity(mCurrentTexture % mEntityClustersGrouped->getNumSubEntities())->setVisible(true); 
     294} 
     295 
    95296void BillboardCloudTextureViewMode::setTextureAtlasSize(unsigned int size) 
    96297{ 
     
    98299} 
    99300 
    100 void BillboardCloudTextureViewMode::setEntityName(Ogre::String entityName) 
    101 { 
    102         mEntityName = entityName; 
     301void BillboardCloudTextureViewMode::setEntityClustersGroupedName(Ogre::String entityClustersGroupedName) 
     302{ 
     303        mEntityClustersGroupedName = entityClustersGroupedName; 
     304} 
     305 
     306void BillboardCloudTextureViewMode::setBillboardCloudSplittedName(Ogre::String billboardCloudSplittedName) 
     307{ 
     308        mBillboardCloudSplittedName = billboardCloudSplittedName; 
    103309} 
    104310 
     
    123329} 
    124330 
     331void BillboardCloudTextureViewMode::setTextureName(Ogre::String textureName) 
     332{ 
     333        mTextureName = textureName; 
     334} 
     335 
    125336void BillboardCloudTextureViewMode::createScene() 
    126337{ 
     
    139350 
    140351        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())); 
    143352        Ogre::Vector2 uvMapMax = mLeaves->getBillboardCloud()->getBillboard(0)->getBillboardClusterData()->getBillboardUVMapMax(0); 
    144353        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); 
    155368 
    156369        mTextureAtlas = IMG::TextureAtlasPtr( new IMG::TextureAtlas() ); 
    157         mTextureAtlas->create("TextureAtlas", mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera); 
     370        mTextureAtlas->create("TextureAtlas", mTextureAtlasSize, mTextureAtlasSize, mSrcPixelFormat, mCamera, avgColour); 
    158371        mTextureAtlas->setRenderTargetListener(&mTextureAtlasListener); 
    159         mTextureAtlas->setTextureAtlasSceneNode(mClusterizedEntitiesMergedSceneNode); 
     372        mTextureAtlas->setTextureAtlasSceneNode(mEntityClustersGroupedSceneNode); 
    160373        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); 
    162374        materialPtr1->getTechnique(0)->getPass(0)->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 10); 
    163375        materialPtr1->getTechnique(0)->getPass(0)->createTextureUnitState("transparent.png"); 
    164376        materialPtr1->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureFiltering(Ogre::FO_NONE, Ogre::FO_NONE, Ogre::FO_NONE);                     
    165377        materialPtr1->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP); 
     378        materialPtr1->getTechnique(0)->getPass(0)->setLightingEnabled(false); 
    166379        mTextureAtlas->setMaterial(materialPtr1.getPointer()); 
    167380        mTextureAtlas->setCorners(-1.0, 1.0, 1.0, -1.0);         
    168381 
    169382        mClusterTexture = IMG::TexturePtr( new IMG::Texture() ); 
    170         mClusterTexture->create("clusterTexture", mTextureSize, mTextureSize, mSrcPixelFormat, mCamera); 
     383        mClusterTexture->create("clusterTexture", mTextureSize, mTextureSize, mSrcPixelFormat, mCamera, avgColour); 
    171384        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        } 
    177394        mClusterTexture->setMaterial(materialPtr.getPointer()); 
    178395 
    179396        mTextureAtlas->addTexture(mClusterTexture); 
    180397         
    181         mClusterTextureListener.setNumTextures(mClusterizedEntities->getNumSubEntities()); 
     398        mClusterTextureListener.setNumTextures(mEntityClustersGrouped->getNumSubEntities()); 
    182399        mClusterTextureListener.setTextureAtlas(mTextureAtlas); 
    183400        mClusterTextureListener.setTexture(mClusterTexture); 
    184         mClusterTextureListener.setEntity(mClusterizedEntities); 
    185  
    186         mNumTextures = mClusterizedEntities->getNumSubEntities(); 
     401        mClusterTextureListener.setEntityClusters(mEntityClustersGrouped); 
     402 
     403        mNumTextures = mEntityClustersGrouped->getNumSubEntities(); 
    187404        mCurrentTexture = 0; 
    188405} 
Note: See TracChangeset for help on using the changeset viewer.