Changeset 1529 for GTP/trunk/App/Demos/Geom/Demo_LodStrips
- Timestamp:
- 09/28/06 19:26:26 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Geom/Demo_LodStrips
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp
r1321 r1529 105 105 }; 106 106 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; 107 class CustomIndexData : public Geometry::IndexData 108 { 109 private: 110 Ogre::Mesh *targetMesh; 111 Ogre::HardwareIndexBufferSharedPtr ibuf; 113 112 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; 114 public: 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); 122 123 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(){ 131 131 ibuf->unlock(); 132 132 } 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 }; 134 138 135 139 class FresnelFrameListener : public ExampleFrameListener … … 198 202 { 199 203 myStrips->GoToLod(lodfactor); 200 DumpDataToOgreBuffers(ogreMesh,myStrips);204 // DumpDataToOgreBuffers(ogreMesh,myStrips); 201 205 lodfactorBefore=lodfactor; 202 206 } … … 401 405 OGRE_EXCEPT(1, "The loaded mesh does not contain any LOD info","LOD Demo"); 402 406 403 myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh); 407 myStrips = new Geometry::LodStripsLibrary( meshloader->GetLodStripsData(), 408 themesh, 409 new CustomIndexData(ogreMesh) ); 404 410 405 411 entity->setNormaliseNormals(true);
Note: See TracChangeset
for help on using the changeset viewer.