Changeset 1529


Ignore:
Timestamp:
09/28/06 19:26:26 (18 years ago)
Author:
gumbau
Message:

Demos upgraded to the new programming interface

Location:
GTP/trunk/App/Demos/Geom
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp

    r1321 r1529  
    105105}; 
    106106 
    107 void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodStripsLibrary *lodStripsLib) 
    108 { 
    109         // Copy to Ogre buffers including the degenerated triangles 
    110  
    111         Ogre::HardwareIndexBufferSharedPtr      ibuf; 
    112         Ogre::IndexData *indexes; 
     107class CustomIndexData : public Geometry::IndexData 
     108{ 
     109private: 
     110        Ogre::Mesh *targetMesh; 
     111        Ogre::HardwareIndexBufferSharedPtr ibuf; 
    113112        Ogre::RenderOperation mRenderOp; 
    114  
    115         for (int submesh=0; submesh < original_mesh->getNumSubMeshes(); submesh++) 
    116         { 
    117                 int indices_to_render = lodStripsLib->GetValidIndexCount(submesh); 
    118                 int offset = lodStripsLib->GetValidOffset(submesh); 
    119  
    120                 original_mesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0); 
    121  
     113        unsigned long* pIdx; 
     114public: 
     115        CustomIndexData(Ogre::Mesh *ogremesh):Geometry::IndexData(){ 
     116                targetMesh=ogremesh; 
     117                pIdx=NULL; 
     118        } 
     119        virtual ~CustomIndexData(void){} 
     120 
     121        virtual void Begin(unsigned int submeshid, unsigned int indexcount){ 
     122                targetMesh->getSubMesh(submeshid)->_getRenderOperation(mRenderOp,0); 
    122123                ibuf = mRenderOp.indexData->indexBuffer; 
    123                 mRenderOp.indexData->indexStart = 0; 
    124                 mRenderOp.indexData->indexCount = indices_to_render; 
    125  
    126                 unsigned long* pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); 
    127  
    128                 for (int k=0; k<indices_to_render; k++) 
    129                         pIdx[k] = lodStripsLib->dataRetrievalInterface->GetIndex(k+offset); 
    130  
     124                mRenderOp.indexData->indexCount = indexcount; 
     125                pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); 
     126        } 
     127        virtual void SetIndex(unsigned int i, unsigned int index){ 
     128                pIdx[i] = index; //lodStripsLib->dataRetrievalInterface->GetIndex(k+offset); 
     129        } 
     130        virtual void End(){ 
    131131                ibuf->unlock(); 
    132132        } 
    133 } 
     133        virtual unsigned int GetIndex(unsigned int) const { return 0; } // HAY QUE ELIMINAR ESTA FUNCION 
     134 
     135        virtual void BorrowIndexData(const Geometry::IndexData *){} 
     136 
     137}; 
    134138 
    135139class FresnelFrameListener : public ExampleFrameListener 
     
    198202                { 
    199203                        myStrips->GoToLod(lodfactor); 
    200                         DumpDataToOgreBuffers(ogreMesh,myStrips); 
     204//                      DumpDataToOgreBuffers(ogreMesh,myStrips); 
    201205                        lodfactorBefore=lodfactor; 
    202206                } 
     
    401405            OGRE_EXCEPT(1, "The loaded mesh does not contain any LOD info","LOD Demo"); 
    402406 
    403                 myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh); 
     407                myStrips = new Geometry::LodStripsLibrary(      meshloader->GetLodStripsData(), 
     408                                                                                                        themesh, 
     409                                                                                                        new CustomIndexData(ogreMesh)   ); 
    404410                 
    405411                entity->setNormaliseNormals(true); 
  • GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp

    r1321 r1529  
    4343 
    4444 
    45 void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib) 
     45/*void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib) 
    4646{ 
    4747        // Copy to Ogre buffers including the degenerated triangles 
     
    8181                ibuf->unlock(); 
    8282        } 
    83 } 
     83}*/ 
    8484 
    8585class FresnelFrameListener : public ExampleFrameListener 
     
    149149                { 
    150150                        myTrees->GoToLod(lodfactor); 
    151                         DumpDataToOgreBuffers(ogreMesh,myTrees); 
     151//                      DumpDataToOgreBuffers(ogreMesh,myTrees); 
    152152                        lodfactorBefore=lodfactor; 
    153153                } 
     
    207207}; 
    208208 
     209class CustomIndexData : public Geometry::IndexData 
     210{ 
     211private: 
     212        Ogre::Mesh *targetMesh; 
     213        Ogre::HardwareIndexBufferSharedPtr ibuf; 
     214        Ogre::RenderOperation mRenderOp; 
     215        unsigned long* pIdx; 
     216public: 
     217        CustomIndexData(Ogre::Mesh *ogremesh):Geometry::IndexData(){ 
     218                targetMesh=ogremesh; 
     219                pIdx=NULL; 
     220        } 
     221        virtual ~CustomIndexData(void){} 
     222 
     223        virtual void Begin(unsigned int submeshid, unsigned int indexcount){ 
     224                targetMesh->getSubMesh(submeshid)->_getRenderOperation(mRenderOp,0); 
     225                ibuf = mRenderOp.indexData->indexBuffer; 
     226                mRenderOp.indexData->indexCount = indexcount; 
     227                pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); 
     228        } 
     229        virtual void SetIndex(unsigned int i, unsigned int index){ 
     230                pIdx[i] = index; //lodStripsLib->dataRetrievalInterface->GetIndex(k+offset); 
     231        } 
     232        virtual void End(){ 
     233                ibuf->unlock(); 
     234        } 
     235 
     236        virtual void BorrowIndexData(const Geometry::IndexData *){} 
     237}; 
     238 
     239 
    209240class FresnelApplication : public ExampleApplication 
    210241{ 
     
    274305            OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the foliage","LOD Demo"); 
    275306 
    276                 myTrees = new Geometry::LodTreeLibrary(meshloader->GetLodStripsData(),meshloader->GetTreeSimpSeq(),themesh); 
     307                myTrees = new Geometry::LodTreeLibrary( meshloader->GetLodStripsData(), 
     308                                                                                                meshloader->GetTreeSimpSeq(), 
     309                                                                                                themesh, 
     310                                                                                                new CustomIndexData(ogreMesh)); 
    277311 
    278312                entity->setNormaliseNormals(true); 
Note: See TracChangeset for help on using the changeset viewer.