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

Demos upgraded to the new programming interface

File:
1 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); 
Note: See TracChangeset for help on using the changeset viewer.