| 292 | | osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD; |
| 293 | | // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out. |
| 294 | | pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7)); |
| 295 | | pagedLOD->setFileName(1,pagedLODfile); |
| 296 | | pagedLOD->setRange(1,0,info.minRange); |
| 297 | | pagedLOD->setCenter(info.center); |
| 298 | | pagedLOD->setRadius(info.radius); |
| 299 | | pagedLOD->setPriorityOffset(0,numLods - loc.lod); |
| 300 | | pagedLOD->setPriorityScale(0,1.0f); |
| 301 | | pagedLOD->setNumChildrenThatCannotBeExpired(1); |
| 302 | | pagedLOD->setTileId(loc.x, loc.y, loc.lod); |
| 303 | | |
| 304 | | if(tileType == trpgHeader::TileLocal) |
| 305 | | { |
| 306 | | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| 307 | | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| 308 | | sw[2] = 0.0; |
| 309 | | pagedLOD->setCenter(center - sw); |
| 310 | | osg::Matrix offset; |
| 311 | | offset.setTrans(sw); |
| 312 | | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| 313 | | tform->addChild(pagedLOD.get()); |
| 314 | | subtiles->addChild(tform); |
| 315 | | } |
| 316 | | else |
| 317 | | subtiles->addChild(pagedLOD.get()); |
| 318 | | subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed? |
| | 291 | osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD; |
| | 292 | // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out. |
| | 293 | pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7)); |
| | 294 | pagedLOD->setFileName(1,pagedLODfile); |
| | 295 | pagedLOD->setRange(1,0,info.minRange); |
| | 296 | pagedLOD->setCenter(info.center); |
| | 297 | pagedLOD->setRadius(info.radius); |
| | 298 | pagedLOD->setPriorityOffset(0,numLods - loc.lod); |
| | 299 | pagedLOD->setPriorityScale(0,1.0f); |
| | 300 | pagedLOD->setNumChildrenThatCannotBeExpired(1); |
| | 301 | pagedLOD->setTileId(loc.x, loc.y, loc.lod); |
| | 302 | |
| | 303 | if(tileType == trpgHeader::TileLocal) |
| | 304 | { |
| | 305 | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| | 306 | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| | 307 | sw[2] = 0.0; |
| | 308 | pagedLOD->setCenter(center - sw); |
| | 309 | osg::Matrix offset; |
| | 310 | offset.setTrans(sw); |
| | 311 | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| | 312 | tform->addChild(pagedLOD.get()); |
| | 313 | subtiles->addChild(tform); |
| | 314 | } |
| | 315 | else |
| | 316 | subtiles->addChild(pagedLOD.get()); |
| | 317 | subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed? |
| | 318 | } |
| | 319 | else |
| | 320 | { |
| | 321 | subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); |
| | 322 | if(tileType == trpgHeader::TileLocal) |
| | 323 | { |
| | 324 | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| | 325 | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| | 326 | sw[2] = 0.0; |
| | 327 | osg::Matrix offset; |
| | 328 | offset.setTrans(sw); |
| | 329 | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| | 330 | tform->addChild(tileContent.get()); |
| | 331 | subtiles->addChild(tform); |
| | 332 | } |
| | 333 | else |
| | 334 | subtiles->addChild(tileContent.get()); |
| | 335 | } |
| | 336 | } |
| 322 | | subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); |
| 323 | | if(tileType == trpgHeader::TileLocal) |
| 324 | | { |
| 325 | | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| 326 | | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| 327 | | sw[2] = 0.0; |
| 328 | | osg::Matrix offset; |
| 329 | | offset.setTrans(sw); |
| 330 | | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| 331 | | tform->addChild(tileContent.get()); |
| 332 | | subtiles->addChild(tform); |
| 333 | | } |
| 334 | | else |
| 335 | | subtiles->addChild(tileContent.get()); |
| 336 | | } |
| 337 | | } |
| 338 | | } |
| 339 | | else |
| 340 | | { |
| 341 | | |
| 342 | | int sizeX, sizeY; |
| 343 | | archive->getLODSize(lod+1,sizeX,sizeY); |
| 344 | | |
| 345 | | const trpgHeader* header = archive->GetHeader(); |
| 346 | | trpgHeader::trpgTileType tileType; |
| 347 | | header->GetTileOriginType(tileType); |
| 348 | | |
| 349 | | TXPArchive::TileInfo parentInfo; |
| 350 | | archive->getTileInfo(x,y,lod,parentInfo); |
| 351 | | |
| 352 | | for (int ix = 0; ix < 2; ix++) |
| 353 | | { |
| 354 | | for (int iy = 0; iy < 2; iy++) |
| 355 | | { |
| 356 | | int tileX = x*2+ix; |
| 357 | | int tileY = y*2+iy; |
| 358 | | int tileLOD = lod+1; |
| 359 | | |
| 360 | | TXPArchive::TileInfo info; |
| 361 | | if (!archive->getTileInfo(tileX,tileY,tileLOD,info)) |
| 362 | | continue; |
| 363 | | |
| 364 | | osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc); |
| 365 | | |
| 366 | | tileContent->setName("TileContent"); |
| 367 | | |
| 368 | | if (tileLOD < (numLods-1)) |
| 369 | | { |
| 370 | | char pagedLODfile[1024]; |
| 371 | | sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp", |
| 372 | | archive->getDir(), |
| 373 | | tileLOD, |
| 374 | | tileX, |
| 375 | | tileY, |
| 376 | | archive->getId()); |
| 377 | | |
| 378 | | // there are tile sets which do not maintain the z extents in |
| 379 | | // the tile table. This attempt to address the issue by using |
| 380 | | // the geometry bounding sphere. The downside is that this is |
| 381 | | // not coupled to the generation and may result in runtime cracks |
| 382 | | if (info.center.z() == 0) |
| 383 | | { |
| 384 | | osg::BoundingSphere bSphere = tileContent->getBound(); |
| 385 | | |
| 386 | | info.center.z() = bSphere.center().z(); |
| 387 | | info.radius = bSphere.radius(); |
| 388 | | } |
| 389 | | |
| 390 | | osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD; |
| 391 | | // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out. |
| 392 | | pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7)); |
| 393 | | pagedLOD->setFileName(1,pagedLODfile); |
| 394 | | pagedLOD->setRange(1,0,info.minRange); |
| 395 | | pagedLOD->setCenter(info.center); |
| 396 | | pagedLOD->setRadius(info.radius); |
| 397 | | pagedLOD->setPriorityOffset(0,numLods-lod); |
| 398 | | pagedLOD->setPriorityScale(0,1.0f); |
| 399 | | pagedLOD->setNumChildrenThatCannotBeExpired(1); |
| 400 | | pagedLOD->setTileId(tileX,tileY,tileLOD); |
| 401 | | |
| 402 | | if(tileType == trpgHeader::TileLocal) |
| 403 | | { |
| 404 | | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| 405 | | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| 406 | | sw[2] = 0.0; |
| 407 | | pagedLOD->setCenter(center - sw); |
| 408 | | osg::Matrix offset; |
| 409 | | offset.setTrans(sw); |
| 410 | | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| 411 | | tform->addChild(pagedLOD.get()); |
| 412 | | subtiles->addChild(tform); |
| 413 | | } |
| 414 | | else |
| 415 | | subtiles->addChild(pagedLOD.get()); |
| 416 | | } |
| 417 | | else |
| 418 | | { |
| 419 | | subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD)); |
| 420 | | if(tileType == trpgHeader::TileLocal) |
| 421 | | { |
| 422 | | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| 423 | | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| 424 | | sw[2] = 0.0; |
| 425 | | osg::Matrix offset; |
| 426 | | offset.setTrans(sw); |
| 427 | | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| 428 | | tform->addChild(tileContent.get()); |
| 429 | | subtiles->addChild(tform); |
| 430 | | } |
| 431 | | else |
| 432 | | subtiles->addChild(tileContent.get()); |
| 433 | | } |
| 434 | | |
| 435 | | } |
| 436 | | } |
| | 340 | |
| | 341 | int sizeX, sizeY; |
| | 342 | archive->getLODSize(lod+1,sizeX,sizeY); |
| | 343 | |
| | 344 | const trpgHeader* header = archive->GetHeader(); |
| | 345 | trpgHeader::trpgTileType tileType; |
| | 346 | header->GetTileOriginType(tileType); |
| | 347 | |
| | 348 | TXPArchive::TileInfo parentInfo; |
| | 349 | archive->getTileInfo(x,y,lod,parentInfo); |
| | 350 | |
| | 351 | for (int ix = 0; ix < 2; ix++) |
| | 352 | { |
| | 353 | for (int iy = 0; iy < 2; iy++) |
| | 354 | { |
| | 355 | int tileX = x*2+ix; |
| | 356 | int tileY = y*2+iy; |
| | 357 | int tileLOD = lod+1; |
| | 358 | |
| | 359 | TXPArchive::TileInfo info; |
| | 360 | if (!archive->getTileInfo(tileX,tileY,tileLOD,info)) |
| | 361 | continue; |
| | 362 | |
| | 363 | osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc); |
| | 364 | |
| | 365 | tileContent->setName("TileContent"); |
| | 366 | |
| | 367 | if (tileLOD < (numLods-1)) |
| | 368 | { |
| | 369 | char pagedLODfile[1024]; |
| | 370 | sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp", |
| | 371 | archive->getDir(), |
| | 372 | tileLOD, |
| | 373 | tileX, |
| | 374 | tileY, |
| | 375 | archive->getId()); |
| | 376 | |
| | 377 | // there are tile sets which do not maintain the z extents in |
| | 378 | // the tile table. This attempt to address the issue by using |
| | 379 | // the geometry bounding sphere. The downside is that this is |
| | 380 | // not coupled to the generation and may result in runtime cracks |
| | 381 | if (info.center.z() == 0) |
| | 382 | { |
| | 383 | osg::BoundingSphere bSphere = tileContent->getBound(); |
| | 384 | |
| | 385 | info.center.z() = bSphere.center().z(); |
| | 386 | info.radius = bSphere.radius(); |
| | 387 | } |
| | 388 | |
| | 389 | osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD; |
| | 390 | // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out. |
| | 391 | pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7)); |
| | 392 | pagedLOD->setFileName(1,pagedLODfile); |
| | 393 | pagedLOD->setRange(1,0,info.minRange); |
| | 394 | pagedLOD->setCenter(info.center); |
| | 395 | pagedLOD->setRadius(info.radius); |
| | 396 | pagedLOD->setPriorityOffset(0,numLods-lod); |
| | 397 | pagedLOD->setPriorityScale(0,1.0f); |
| | 398 | pagedLOD->setNumChildrenThatCannotBeExpired(1); |
| | 399 | pagedLOD->setTileId(tileX,tileY,tileLOD); |
| | 400 | |
| | 401 | if(tileType == trpgHeader::TileLocal) |
| | 402 | { |
| | 403 | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| | 404 | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| | 405 | sw[2] = 0.0; |
| | 406 | pagedLOD->setCenter(center - sw); |
| | 407 | osg::Matrix offset; |
| | 408 | offset.setTrans(sw); |
| | 409 | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| | 410 | tform->addChild(pagedLOD.get()); |
| | 411 | subtiles->addChild(tform); |
| | 412 | } |
| | 413 | else |
| | 414 | subtiles->addChild(pagedLOD.get()); |
| | 415 | } |
| | 416 | else |
| | 417 | { |
| | 418 | subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD)); |
| | 419 | if(tileType == trpgHeader::TileLocal) |
| | 420 | { |
| | 421 | osg::Vec3d center(info.center - parentInfo.bbox._min); |
| | 422 | osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min); |
| | 423 | sw[2] = 0.0; |
| | 424 | osg::Matrix offset; |
| | 425 | offset.setTrans(sw); |
| | 426 | osg::MatrixTransform *tform = new osg::MatrixTransform(offset); |
| | 427 | tform->addChild(tileContent.get()); |
| | 428 | subtiles->addChild(tform); |
| | 429 | } |
| | 430 | else |
| | 431 | subtiles->addChild(tileContent.get()); |
| | 432 | } |
| | 433 | |
| | 434 | } |
| | 435 | } |