Changeset 778


Ignore:
Timestamp:
04/21/06 19:56:55 (18 years ago)
Author:
igarcia
Message:
 
Location:
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE
Files:
4 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCUtil.h

    r751 r778  
    55 
    66namespace BBC { 
     7 
     8const Ogre::Real EPSILON_INTERSECT = 0.00000001; 
    79 
    810class _BBCExport Util 
     
    3537        } 
    3638 
     39        // Calculate the line segment PaPb that is the shortest route between 
     40        // two lines P1P2 and P3P4. Calculate also the values of mua and mub where 
     41        //   Pa = P1 + mua (P2 - P1) 
     42        //       Pb = P3 + mub (P4 - P3) 
     43        // Return false if no solution exists. 
     44 
     45        static int lineLineIntersect( 
     46                Ogre::Vector3 p1, Ogre::Vector3 p2, Ogre::Vector3 p3, Ogre::Vector3 p4, Ogre::Vector3 *pa, Ogre::Vector3 *pb, 
     47                Ogre::Real *mua, Ogre::Real *mub) 
     48        { 
     49                Ogre::Vector3 p13,p43,p21; 
     50                Ogre::Real d1343,d4321,d1321,d4343,d2121; 
     51                Ogre::Real numer,denom; 
     52 
     53                p13.x = p1.x - p3.x; 
     54                p13.y = p1.y - p3.y; 
     55                p13.z = p1.z - p3.z; 
     56                p43.x = p4.x - p3.x; 
     57                p43.y = p4.y - p3.y; 
     58                p43.z = p4.z - p3.z; 
     59                if (Ogre::Math::Abs(p43.x)  < EPSILON_INTERSECT && Ogre::Math::Abs(p43.y)  < EPSILON_INTERSECT && Ogre::Math::Abs(p43.z)  < EPSILON_INTERSECT) 
     60                { 
     61                        return(false); 
     62                } 
     63                p21.x = p2.x - p1.x; 
     64                p21.y = p2.y - p1.y; 
     65                p21.z = p2.z - p1.z; 
     66                if (Ogre::Math::Abs(p21.x)  < EPSILON_INTERSECT && Ogre::Math::Abs(p21.y)  < EPSILON_INTERSECT && Ogre::Math::Abs(p21.z)  < EPSILON_INTERSECT) 
     67                { 
     68                        return(false); 
     69                } 
     70 
     71                d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z; 
     72                d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z; 
     73                d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z; 
     74                d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z; 
     75                d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z; 
     76 
     77                denom = d2121 * d4343 - d4321 * d4321; 
     78                if (Ogre::Math::Abs(denom) < EPSILON_INTERSECT) 
     79                { 
     80                        return(false); 
     81                } 
     82                numer = d1343 * d4321 - d1321 * d4343; 
     83 
     84                *mua = numer / denom; 
     85                *mub = (d1343 + d4321 * (*mua)) / d4343; 
     86 
     87                pa->x = p1.x + *mua * p21.x; 
     88                pa->y = p1.y + *mua * p21.y; 
     89                pa->z = p1.z + *mua * p21.z; 
     90                pb->x = p3.x + *mub * p43.x; 
     91                pb->y = p3.y + *mub * p43.y; 
     92                pb->z = p3.z + *mub * p43.z; 
     93 
     94                return(true); 
     95        } 
    3796}; 
    3897 
    3998/* 
    40 extern "C" _BBCExport double fround(double n, unsigned d) 
     99extern "C" _BBCExport Ogre::Real fround(Ogre::Real n, unsigned d) 
    41100{  
    42         return floor(n * pow((double)10.,(int) d) + .5) / pow((double)10.,(int) d); 
     101        return floor(n * pow((Ogre::Real)10.,(int) d) + .5) / pow((Ogre::Real)10.,(int) d); 
    43102} 
    44103 
    45 extern "C" _BBCExport int iround(double x) 
     104extern "C" _BBCExport int iround(Ogre::Real x) 
    46105{ 
    47106      return (int)floor(x + 0.5); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/LBBC/LBBC.h

    r745 r778  
    1010#include <LBBCClusterViewMode.h> 
    1111#include <LBBCEntityTextureAtlasViewMode.h> 
    12 #include <LBBCBillboardCloudTextureViewMode.h> 
     12#include <LBBCBillboardCloudDiffuseColorTextureViewMode.h> 
     13#include <LBBCBillboardCloudIndirectTextureViewMode.h> 
    1314#endif 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/scripts/IBRBillboardCloudTreeGenerator.vcproj

    r751 r778  
    213213                                Filter=""> 
    214214                                <File 
    215                                         RelativePath="..\src\LBBCBillboardCloudTextureViewMode.cpp"> 
     215                                        RelativePath="..\src\LBBCBillboardCloudDiffuseColorTextureViewMode.cpp"> 
     216                                </File> 
     217                                <File 
     218                                        RelativePath="..\src\LBBCBillboardCloudIndirectTextureViewMode.cpp"> 
    216219                                </File> 
    217220                                <File 
     
    416419                                </File> 
    417420                                <File 
    418                                         RelativePath="..\include\Lbbc\LBBCBillboardCloudTextureViewMode.h"> 
     421                                        RelativePath="..\include\Lbbc\LBBCBillboardCloudDiffuseColorTextureViewMode.h"> 
     422                                </File> 
     423                                <File 
     424                                        RelativePath="..\include\Lbbc\LBBCBillboardCloudIndirectTextureViewMode.h"> 
    419425                                </File> 
    420426                                <File 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/BBCBillboardCloudUVMapper.cpp

    r751 r778  
    152152        Ogre::Vector2 texCoords01,texCoords02,texCoords03,texCoords04; 
    153153 
     154        // DirectX working version... 
     155        texCoords03[0] = min[0] / mTextureAtlasWidth; 
     156        texCoords03[1] = 1.0 - (min[1] / mTextureAtlasHeight); 
     157 
     158        texCoords04[0] = max[0] / mTextureAtlasWidth; 
     159        texCoords04[1] = 1.0 - (min[1] / mTextureAtlasHeight); 
     160 
     161        texCoords01[0] = max[0] / mTextureAtlasWidth; 
     162        texCoords01[1] = 1.0 - (max[1] / mTextureAtlasHeight); 
     163 
    154164        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); 
     165        texCoords02[1] = 1.0 - (max[1] / mTextureAtlasHeight); 
     166 
     167        //texCoords02[0] = min[0] / mTextureAtlasWidth; 
     168        //texCoords02[1] = 1.0 - (min[1] / mTextureAtlasHeight); 
     169 
     170        //texCoords01[0] = max[0] / mTextureAtlasWidth; 
     171        //texCoords01[1] = 1.0 - (min[1] / mTextureAtlasHeight); 
     172 
     173        //texCoords04[0] = max[0] / mTextureAtlasWidth; 
     174        //texCoords04[1] = 1.0 - (max[1] / mTextureAtlasHeight); 
     175 
     176        //texCoords03[0] = min[0] / mTextureAtlasWidth; 
     177        //texCoords03[1] = 1.0 - (max[1] / mTextureAtlasHeight); 
    165178         
    166179        if (groupedBillboards) 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/IBRBillboardCloudTreeApplication.cpp

    r751 r778  
    147147        mSceneMgr = mFrameListener->getEnabledFrameListenerMode()->getSceneManager();    
    148148 
     149        if (mSampleConfigFile->getBillboardCloudDiffuseColorEntityTextureAtlasGeneration()) 
    149150        { 
    150151                LBBC::EntityTextureAtlasViewMode *textureAtlasFrameListenerMode; 
     
    164165        } 
    165166 
    166         { 
    167                 LBBC::BillboardCloudTextureViewMode *anotherFrameListenerMode; 
    168                 anotherFrameListenerMode = new LBBC::BillboardCloudTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); 
     167        if (mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasGeneration()) 
     168        { 
     169                LBBC::BillboardCloudDiffuseColorTextureViewMode *anotherFrameListenerMode; 
     170                anotherFrameListenerMode = new LBBC::BillboardCloudDiffuseColorTextureViewMode(mWindow,mFrameListener->getNumFrameListenerModes()); 
    169171                anotherFrameListenerMode->chooseSceneManager(); 
    170172                anotherFrameListenerMode->createCamera(); 
     
    177179                anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder()); 
    178180                anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName()); 
    179                 //anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName()); 
    180                 anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudIndirectPointMeshName()); 
     181                anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName()); 
    181182                anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudDiffuseColorGroupedBillboardsTextureAtlasDebug()); 
     183                anotherFrameListenerMode->createScene(); 
     184                mFrameListener->addFrameListenerMode(anotherFrameListenerMode); 
     185        } 
     186 
     187        if (mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasGeneration()) 
     188        { 
     189                LBBC::BillboardCloudIndirectTextureViewMode *anotherFrameListenerMode; 
     190                anotherFrameListenerMode = new LBBC::BillboardCloudIndirectTextureViewMode(mWindow, mFrameListener->getNumFrameListenerModes()); 
     191                anotherFrameListenerMode->chooseSceneManager(); 
     192                anotherFrameListenerMode->createCamera(); 
     193                anotherFrameListenerMode->createViewports(); 
     194                anotherFrameListenerMode->setTextureAtlasSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasSize()); 
     195                anotherFrameListenerMode->setTextureSize(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureSize()); 
     196                anotherFrameListenerMode->setTextureAtlasBitRange(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasBitRange()); 
     197                anotherFrameListenerMode->setTextureAtlasName(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasName()); 
     198                anotherFrameListenerMode->setTextureAtlasFolder(mSampleConfigFile->getBillboardCloudFolder()); 
     199                anotherFrameListenerMode->setBillboardCloudPointClustersName(mSampleConfigFile->getBillboardCloudIndirectPointMeshName()); 
     200                anotherFrameListenerMode->setBillboardCloudSplittedName(mSampleConfigFile->getBillboardCloudSplittedMeshName()); 
     201                anotherFrameListenerMode->setEntityClustersGroupedName(mSampleConfigFile->getEntityClustersGroupedMeshName()); 
     202                anotherFrameListenerMode->setBillboardCloudGroupedTextureAtlasDebug(mSampleConfigFile->getBillboardCloudIndirectGroupedBillboardsTextureAtlasDebug()); 
    182203                anotherFrameListenerMode->createScene(); 
    183204                mFrameListener->addFrameListenerMode(anotherFrameListenerMode); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/LBBCManager.cpp

    r751 r778  
    497497                        entity->getSubEntity(numSubEntities)->setMaterialName(mSampleConfigFile->getBillboardCloudIndirectPointMaterialName()); 
    498498                        entity->getSubEntity(numSubEntities)->enableNormals(false); 
    499                         entity->getSubEntity(numSubEntities)->enableTextureCoords(false); 
     499                        entity->getSubEntity(numSubEntities)->enableTextureCoords(true); 
     500                        entity->getSubEntity(numSubEntities)->addTextureCoordSet(2); 
    500501                        entity->getSubEntity(numSubEntities)->enableVertexColours(true); 
     502 
     503                        Ogre::Vector3 p1, p2, p3, p4, pa, pb; 
     504                        Ogre::Real mua, mub; 
     505                        Ogre::Real height, width; 
     506                        Ogre::Real hDistance, wDistance; 
     507 
     508                        height = Ogre::Vector3(billboard->getBillboardClusterData()->getQuadTopLeftCorner() - billboard->getBillboardClusterData()->getQuadBottomLeftCorner()).length(); 
     509                        width = Ogre::Vector3(billboard->getBillboardClusterData()->getQuadTopLeftCorner() - billboard->getBillboardClusterData()->getQuadTopRightCorner()).length(); 
    501510 
    502511                        for (unsigned int iLeaf = 0; iLeaf < entityCluster->getNumEntitiesClusterData(); iLeaf++) 
     
    507516                                Leaf *leaf = (Leaf*)leafKMeansClusterData->getEntity().get(); 
    508517                                vertex.position = leaf->getPosition(); 
     518 
     519                                hDistance = 0.0; 
     520                                wDistance = 0.0; 
     521 
     522                                p1 = billboard->getBillboardClusterData()->getQuadTopRightCorner(); 
     523                                p2 = billboard->getBillboardClusterData()->getQuadBottomRightCorner(); 
     524                                p3 = leaf->getPosition(); 
     525                                p4 = leaf->getPosition() + billboard->getBillboardClusterData()->getAxisY(); 
     526 
     527                                if (BBC::Util::lineLineIntersect(p1, p2, p3, p4, &pa, &pb, &mua, &mub)) 
     528                                { 
     529                                        hDistance = Ogre::Vector3(pa - p1).length(); 
     530                                } 
     531                                else 
     532                                { 
     533                                        Ogre::LogManager::getSingleton().logMessage("Error with intersection: no solution exists."); 
     534                                } 
     535 
     536                                p1 = billboard->getBillboardClusterData()->getQuadTopLeftCorner(); 
     537                                p2 = billboard->getBillboardClusterData()->getQuadTopRightCorner(); 
     538                                p3 = leaf->getPosition(); 
     539                                p4 = leaf->getPosition() + billboard->getBillboardClusterData()->getAxisX(); 
     540 
     541                                if (BBC::Util::lineLineIntersect(p1, p2, p3, p4, &pa, &pb, &mua, &mub)) 
     542                                { 
     543                                        wDistance = Ogre::Vector3(pa - p2).length(); 
     544                                } 
     545                                else 
     546                                { 
     547                                        Ogre::LogManager::getSingleton().logMessage("Error with intersection: no solution exists."); 
     548                                } 
     549 
     550                                //Ogre::LogManager::getSingleton().logMessage("W:" + Ogre::StringConverter::toString(width) + " UW:" + Ogre::StringConverter::toString(wDistance)); 
     551                                //Ogre::LogManager::getSingleton().logMessage("H:" + Ogre::StringConverter::toString(height) + " UH:" + Ogre::StringConverter::toString(hDistance)); 
     552 
     553                                //vertex.uv[0] = Ogre::Vector3(wDistance / width, hDistance / height, 0.0); 
     554                                vertex.uv[0] = Ogre::Vector3(1.0 - (hDistance / height), 1.0 - (wDistance / width), 0.0); 
    509555                                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();  
    510556                                entity->getSubEntity(numSubEntities)->addUniqueVertex(vertex); 
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/src/OBAOgreFrameListener.cpp

    r751 r778  
    102102    } 
    103103 
    104         if (mInputDevice->isKeyDown(Ogre::KC_TAB) && mTimeUntilNextToggle <= 0) 
     104        //if (mInputDevice->isKeyDown(Ogre::KC_TAB) && mTimeUntilNextToggle <= 0) 
     105        if (mInputDevice->isKeyDown(Ogre::KC_TAB)) 
    105106    {            
    106107                mCurrentOgreFrameListenerMode = (mCurrentOgreFrameListenerMode+1) % this->getNumFrameListenerModes();            
     
    108109                mWindow->setDebugText("P: " + mDefaultOgreFrameListenerMode->getSceneManager()->getName()); 
    109110 
    110                 mTimeUntilNextToggle = 0.25; 
     111                //mTimeUntilNextToggle = 0.25;           
    111112    } 
    112113 
Note: See TracChangeset for help on using the changeset viewer.