- Timestamp:
- 09/28/06 19:26:26 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Geom
- Files:
-
- 5 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); -
GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
r1321 r1529 43 43 44 44 45 void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib)45 /*void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib) 46 46 { 47 47 // Copy to Ogre buffers including the degenerated triangles … … 81 81 ibuf->unlock(); 82 82 } 83 } 83 }*/ 84 84 85 85 class FresnelFrameListener : public ExampleFrameListener … … 149 149 { 150 150 myTrees->GoToLod(lodfactor); 151 DumpDataToOgreBuffers(ogreMesh,myTrees);151 // DumpDataToOgreBuffers(ogreMesh,myTrees); 152 152 lodfactorBefore=lodfactor; 153 153 } … … 207 207 }; 208 208 209 class CustomIndexData : public Geometry::IndexData 210 { 211 private: 212 Ogre::Mesh *targetMesh; 213 Ogre::HardwareIndexBufferSharedPtr ibuf; 214 Ogre::RenderOperation mRenderOp; 215 unsigned long* pIdx; 216 public: 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 209 240 class FresnelApplication : public ExampleApplication 210 241 { … … 274 305 OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the foliage","LOD Demo"); 275 306 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)); 277 311 278 312 entity->setNormaliseNormals(true);
Note: See TracChangeset
for help on using the changeset viewer.