- Timestamp:
- 08/31/06 17:11:13 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Geom
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp
r1128 r1306 121 121 original_mesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0); 122 122 123 ibuf = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 124 Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 125 indices_to_render, // number of indexes 126 Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage 127 false); // no shadow buffer 128 129 mRenderOp.indexData->indexBuffer = ibuf; 130 mRenderOp.indexData->indexStart = 0;//offset; 123 ibuf = mRenderOp.indexData->indexBuffer; 124 mRenderOp.indexData->indexStart = 0; 131 125 mRenderOp.indexData->indexCount = indices_to_render; 132 126 … … 135 129 for (int k=0; k<indices_to_render; k++) 136 130 pIdx[k] = lodStripsLib->dataRetrievalInterface->GetIndex(k+offset); 137 131 138 132 ibuf->unlock(); 139 140 133 } 141 134 } … … 200 193 lodfactor=1.0f; 201 194 202 /* if (lodfactor >= 0.0f && lodfactor <= 1.0f)203 {*/204 195 static float lodfactorBefore = -1.0f; 205 196 if (fabsf(lodfactorBefore-lodfactor)>0.05f || … … 210 201 DumpDataToOgreBuffers(ogreMesh,myStrips); 211 202 lodfactorBefore=lodfactor; 212 213 /* if (lodfactor < 0.333f)214 {215 color.r=0.0;216 color.g=(lodfactor)*3.0f;//nlod*1.0/(diflods/3);217 color.b=(0.3f-lodfactor)*3.0f;//(nlod*1.0/(diflods/3));218 }219 else220 {221 if (lodfactor<0.666f)222 {223 color.r=(lodfactor-0.333f)*3.0f;//(nlod-diflods/3)*1.0/(diflods/3);224 color.g=1.0;225 color.b=0.0;226 }227 else228 {229 color.r=1.0;230 color.g=(0.3f-lodfactor)*3.0f;//(nlod-(2*diflods/3))*1.0/(diflods/3);231 color.b=0.0;232 }233 }234 mat[0]->setDiffuse(color);*/235 203 } 236 /* else 237 { 238 if ((distance > dist_max)) 239 { 240 color.r=0.0; 241 color.g=0.0; 242 color.b=1.0; 243 mat[0]->setDiffuse(color); 244 245 } 246 else 247 { 248 if ((distance < dist_min)) 249 { 250 color.r=1.0; 251 color.g=0.0; 252 color.b=0.0; 253 mat[0]->setDiffuse(color); 254 } 255 } 256 } 257 */ 204 258 205 // Move the node 259 206 if(mInputDevice->isKeyDown(Ogre::KC_UP)) … … 452 399 lod_file.append(".lod"); 453 400 454 // myStrips = new LodStripsLibrary(lod_file,entity->getMesh().getPointer());455 456 401 if (!meshloader->GetLodStripsData()) 457 402 OGRE_EXCEPT(1, "The loaded mesh does not contain any LOD info","LOD Demo"); 458 403 459 404 myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh); 405 406 for (unsigned int i=0; i<ogreMesh->getNumSubMeshes(); i++) 407 { 408 Ogre::RenderOperation mRenderOp; 409 ogreMesh->getSubMesh(i)->_getRenderOperation(mRenderOp,0); 410 int indices_to_render = myStrips->GetValidIndexCount(i); 411 412 mRenderOp.indexData->indexBuffer = 413 Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 414 Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 415 indices_to_render, // number of indexes 416 Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage 417 false); 418 } 460 419 461 420 entity->setNormaliseNormals(true); 462 463 421 aboveWaterEnts.push_back(entity); 464 465 // Colour-coded material466 /* mat[0] = MaterialManager::getSingleton().create("test_mat",467 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);468 mat[0]->setCullingMode(CULL_NONE);469 mat[0]->setAmbient(ColourValue(0.5f,0.5f,0.5f));470 mat[0]->setDiffuse(color);471 mat[0]->setLightingEnabled(true);*/472 //entity->setMaterialName("test_mat");473 422 entity->setMaterialName("LODStripsDemo/Ogro"); 474 423 475 476 for (int i=-3; i<7; i++) // 20 477 for (int j=0; j<4; j++) // 20 424 for (int i=-3; i<7; i++) 425 for (int j=0; j<4; j++) 478 426 { 479 427 char newObjName[16]=""; -
GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
r1124 r1306 67 67 } 68 68 69 ibuf = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 70 Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 71 indices_to_render, // number of indexes 72 Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage 73 false); // no shadow buffer 74 75 mRenderOp.indexData->indexBuffer = ibuf; 69 ibuf = mRenderOp.indexData->indexBuffer; 76 70 mRenderOp.indexData->indexStart = 0; 77 71 mRenderOp.indexData->indexCount = indices_to_render; … … 276 270 Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/ML12m.mesh"); 277 271 272 if (!meshloader->GetLodStripsData()) 273 OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the trunk","LOD Demo"); 274 if (!meshloader->GetTreeSimpSeq()) 275 OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the foliage","LOD Demo"); 276 278 277 myTrees = new Geometry::LodTreeLibrary(meshloader->GetLodStripsData(),meshloader->GetTreeSimpSeq(),themesh); 279 278 … … 283 282 { 284 283 bool istrunk = myTrees->GetLeavesSubMesh()!=submesh; 284 int indices_to_render = 0; 285 285 if (istrunk) 286 { 286 287 entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/trunk"); 288 indices_to_render = myTrees->GetValidTrunkIndexCount(submesh); 289 } 287 290 else 291 { 288 292 entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/leaf"); 293 indices_to_render = myTrees->CurrentLOD_Foliage_IndexCount(); 294 } 295 296 Ogre::RenderOperation mRenderOp; 297 ogreMesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0); 298 299 mRenderOp.indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 300 Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 301 indices_to_render, // number of indexes 302 Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage 303 false); // no shadow buffer 289 304 } 290 305
Note: See TracChangeset
for help on using the changeset viewer.