#include <OSGBrick.h>
Public Types | |
| enum | Orientation { XY = 0, XZ = 1, YZ = 2, UNDEF = 3 } |
Public Member Functions | |
| BrickSet (void) | |
| ~BrickSet (void) | |
| Brick * | sortBricks3D (const Matrix &modelMat, const Vec3f &eyePoint) |
| Return sorted brick list. | |
| Brick * | sortBricks2D (bool backToFront) |
| Return sorted brick list. | |
| void | buildBrickTextures (ChunkMaterialPtr &material, TextureSet &textures, TextureManager::TextureMode mode) |
| Build textures for bricks. | |
| void | reloadBrickTextures (DrawActionBase *action, UInt32 texStage) |
| Reload brick textures. | |
| void | clearBrickTextures (ChunkMaterialPtr &material) |
| Clear brick textures. | |
| void | buildBricks3D (DVRVolume *volume, Vec3f brickSubdivision, Int32 overlap=1, Orientation ori=UNDEF) |
| Build 3D bricks. | |
| void | buildBricks2D (DVRVolume *volume, Orientation ori) |
| Build 2D bricks. | |
Static Public Member Functions | |
| static TextureChunkPtr | makeTexture (UInt32 internalFormat, UInt32 externalFormat, ImagePtr image) |
| Create texture chunk for image. | |
Public Attributes | |
| Brick * | m_pBricks |
| int | m_nNumBricks |
| Orientation | m_nOrientation |
Definition at line 31 of file OSGBrick.h.
|
|
Definition at line 35 of file OSGBrick.h. 00036 { 00037 XY = 0, 00038 XZ = 1, 00039 YZ = 2, 00040 UNDEF = 3 // especially for 3D textures 00041 };
|
|
|
Definition at line 5 of file OSGBrick.inl. 00005 : 00006 m_pBricks(0), 00007 m_nNumBricks(0), 00008 m_nOrientation(UNDEF) 00009 { 00010 }
|
|
|
Definition at line 22 of file OSGBrick.cpp. References m_pBricks. 00023 { 00024 delete [] m_pBricks; 00025 }
|
|
||||||||||||
|
Definition at line 491 of file OSGBrick.cpp. References osg::Brick::center, osg::Brick::distance, m_nNumBricks, m_pBricks, osg::TransformationMatrix< ValueTypeT >::multMatrixPnt(), osg::Brick::next, and osg::Brick::prev. Referenced by osg::TextureManager::sortBricks(). 00492 { 00493 00494 Brick *BrickList = m_pBricks; 00495 00496 Int32 nBrick; 00497 Real32 distance; 00498 Brick *previous, *current, *incoming; 00499 00500 Vec3f transformedCenter; 00501 00502 m_pBricks[0].prev = NULL; 00503 m_pBricks[0].next = NULL; 00504 00505 modelMat.multMatrixPnt(m_pBricks[0].center,transformedCenter); 00506 00507 m_pBricks[0].distance = (eyePoint - transformedCenter).length(); 00508 00509 00510 for(nBrick = 1; nBrick < m_nNumBricks; nBrick++) 00511 { 00512 incoming = &(m_pBricks[nBrick]); 00513 00514 modelMat.multMatrixPnt(incoming->center,transformedCenter); 00515 00516 distance = (eyePoint - transformedCenter).length(); 00517 00518 incoming->distance = distance; 00519 incoming->next = NULL; 00520 incoming->prev = NULL; 00521 00522 current = BrickList; 00523 previous = NULL; 00524 00525 while((current != NULL) && (current->distance > distance)) 00526 { 00527 previous = current; 00528 current = current->next; 00529 } 00530 00531 // insert 00532 if (current == NULL) 00533 { 00534 // insert at the end of the list; 00535 previous->next = incoming; 00536 incoming->prev = previous; 00537 00538 } 00539 else 00540 { 00541 incoming->next = current; 00542 incoming->prev = current->prev; 00543 current->prev = incoming; 00544 00545 if (incoming->prev == NULL) 00546 { 00547 BrickList = incoming; 00548 } 00549 else 00550 { 00551 incoming->prev->next = incoming; 00552 } 00553 } 00554 } 00555 00556 return BrickList; 00557 }
|
|
|
Definition at line 561 of file OSGBrick.cpp. References m_nNumBricks, m_pBricks, osg::Brick::next, and osg::Brick::prev. Referenced by osg::TextureManager::sortBricks(). 00562 { 00563 Brick *brickList = m_pBricks; 00564 00565 if(brickList) 00566 { 00567 if(backToFront) 00568 { 00569 for(int i = m_nNumBricks - 1; i >= 0; i--) 00570 { 00571 m_pBricks[i].prev = &(m_pBricks[i + 1]); 00572 m_pBricks[i].next = &(m_pBricks[i - 1]); 00573 } 00574 00575 m_pBricks[0].next = NULL; 00576 m_pBricks[m_nNumBricks - 1].prev = NULL; 00577 00578 brickList = &(m_pBricks[m_nNumBricks - 1]); 00579 } 00580 else 00581 { 00582 for (int i = 0; i < m_nNumBricks; i++) 00583 { 00584 m_pBricks[i].prev = &(m_pBricks[i - 1]); 00585 m_pBricks[i].next = &(m_pBricks[i + 1]); 00586 } 00587 00588 m_pBricks[0].prev = NULL; 00589 m_pBricks[m_nNumBricks - 1].next = NULL; 00590 00591 brickList = &(m_pBricks[0]); 00592 } 00593 } 00594 00595 return brickList; 00596 }
|
|
||||||||||||||||
|
Definition at line 313 of file OSGBrick.cpp. References osg::beginEditCP(), osg::ImageBase::create(), osg::endEditCP(), m_nNumBricks, m_pBricks, makeTexture(), osg::Brick::minVox, osg::Brick::numTextures, osg::Brick::texStage, osg::Brick::texture, osg::TextureManager::TM_2D, osg::TextureManager::TM_2D_Multi, osg::TextureManager::TM_3D, and osg::Brick::voxSize. Referenced by osg::TextureManager::buildTextures(). 00316 { 00317 // overall number of textures 00318 UInt32 numTextures = textures.size(); 00319 00320 if(mode == TextureManager::TM_2D_Multi) 00321 numTextures *= 2; 00322 00323 beginEditCP(material); 00324 { 00325 // build all texture chunks 00326 for(Int32 index = 0; index < m_nNumBricks; index++) 00327 { 00328 Int32 &resX = m_pBricks[index].voxSize[0]; 00329 Int32 &resY = m_pBricks[index].voxSize[1]; 00330 Int32 &resZ = m_pBricks[index].voxSize[2]; 00331 00332 Int32 &nXMin = m_pBricks[index].minVox[0]; 00333 Int32 &nYMin = m_pBricks[index].minVox[1]; 00334 Int32 &nZMin = m_pBricks[index].minVox[2]; 00335 00336 int texCounter = 0; 00337 00338 m_pBricks[index].texture = new TextureChunkPtr[numTextures]; 00339 m_pBricks[index].texStage = new UInt32[numTextures]; 00340 m_pBricks[index].numTextures = numTextures; 00341 00342 // create texture chunks 00343 for(UInt32 tch = 0; tch < textures.size(); tch++) 00344 { 00345 ImagePtr img = Image::create(); 00346 00347 switch (mode) 00348 { 00349 case TextureManager::TM_2D_Multi: // 2D multi textures 00350 { 00351 // first texture 00352 textures[tch]->_image->slice(resX == 2 ? nXMin : -1, 00353 resY == 2 ? nYMin : -1, 00354 resZ == 2 ? nZMin : -1, 00355 img); 00356 if (index == 0) 00357 { 00358 m_pBricks[index].texture[texCounter] = 00359 makeTexture(textures[tch]->_internalFormat, 00360 textures[tch]->_externalFormat, 00361 img ); 00362 } 00363 else 00364 { 00365 // each but first brick can reuse texture 00366 // chunks of previous brick 00367 00368 m_pBricks[index].texture[texCounter] = 00369 m_pBricks[index-1].texture[texCounter+1]; 00370 } 00371 00372 m_pBricks[index].texStage[texCounter] = 00373 textures[tch]->_textureStage0; 00374 00375 material->addChunk( 00376 m_pBricks[index].texture[texCounter]); 00377 00378 texCounter++; 00379 00380 // second texture 00381 img = Image::create(); 00382 00383 textures[tch]->_image->slice( 00384 resX == 2 ? nXMin + 1 : -1, 00385 resY == 2 ? nYMin + 1 : -1, 00386 resZ == 2 ? nZMin + 1 : -1, 00387 img ); 00388 00389 m_pBricks[index].texture[texCounter] = 00390 makeTexture(textures[tch]->_internalFormat, 00391 textures[tch]->_externalFormat, 00392 img ); 00393 00394 m_pBricks[index].texStage[texCounter] = 00395 textures[tch]->_textureStage1; 00396 00397 material->addChunk( 00398 m_pBricks[index].texture[texCounter]); 00399 00400 texCounter++; 00401 00402 break; 00403 } 00404 00405 case TextureManager::TM_2D: // 2D ordinary textures 00406 { 00407 textures[tch]->_image->slice(resX == 1 ? nXMin : -1, 00408 resY == 1 ? nYMin : -1, 00409 resZ == 1 ? nZMin : -1, 00410 img); 00411 00412 m_pBricks[index].texture[texCounter] = 00413 makeTexture(textures[tch]->_internalFormat, 00414 textures[tch]->_externalFormat, 00415 img ); 00416 00417 m_pBricks[index].texStage[texCounter] = 00418 textures[tch]->_textureStage0; 00419 00420 material->addChunk( 00421 m_pBricks[index].texture[texCounter]); 00422 00423 texCounter++; 00424 00425 break; 00426 } 00427 00428 case TextureManager::TM_3D: // 3D ordinary textures 00429 default: 00430 { 00431 textures[tch]->_image->subImage(nXMin, nYMin, nZMin, 00432 resX, resY, resZ, 00433 img ); 00434 00435 m_pBricks[index].texture[texCounter] = 00436 makeTexture(textures[tch]->_internalFormat, 00437 textures[tch]->_externalFormat, 00438 img ); 00439 00440 m_pBricks[index].texStage[texCounter] = 00441 textures[texCounter]->_textureStage0; 00442 00443 material->addChunk( 00444 m_pBricks[index].texture[texCounter]); 00445 00446 texCounter++; 00447 00448 break; 00449 } 00450 } 00451 00452 } // for all registered textures 00453 00454 } // for all bricks 00455 } 00456 endEditCP(material); 00457 }
|
|
||||||||||||
|
Definition at line 461 of file OSGBrick.cpp. References osg::DrawActionBase::getWindow(), m_nNumBricks, m_pBricks, osg::Brick::numTextures, osg::Window::refreshGLObject(), and osg::Brick::texStage. Referenced by osg::TextureManager::reloadTexture(). 00462 { 00463 for(Int32 i = 0; i < m_nNumBricks; i++) 00464 { 00465 for(Int32 j = 0; j < m_pBricks[i].numTextures; j++) 00466 { 00467 if(m_pBricks[i].texStage[j] == texStage) 00468 { 00469 action->getWindow()->refreshGLObject( 00470 m_pBricks[i].texture[j]->getGLId()); 00471 } 00472 } 00473 } 00474 }
|
|
|
Definition at line 478 of file OSGBrick.cpp. References m_nNumBricks, m_pBricks, and osg::Brick::numTextures. Referenced by osg::TextureManager::clearTextures(). 00479 { 00480 for(Int32 i = 0; i < m_nNumBricks; i++) 00481 { 00482 for(Int32 j = 0; j < m_pBricks[i].numTextures; j++) 00483 { 00484 material->subChunk(m_pBricks[i].texture[j]); 00485 } 00486 } 00487 }
|
|
||||||||||||||||||||
|
Definition at line 27 of file OSGBrick.cpp. References DVRVOLUME_PARAMETER, FDEBUG, osg::Brick::init(), m_nNumBricks, m_nOrientation, m_pBricks, osg::NullFC, SFATAL, SINFO, and SWARNING. Referenced by osg::TextureManager::buildTextures(). 00031 { 00032 FDEBUG(("BrickSet::buildBricks3D %d %d %d\n", 00033 brickSize[0], 00034 brickSize[1], 00035 brickSize[2])); 00036 00037 SINFO << "BrickSet::buildBricks3D (size)" 00038 << brickSize[0] << ", " 00039 << brickSize[1] << "," 00040 << brickSize[2] << std::endl; 00041 00042 m_nOrientation = ori; 00043 00044 DVRVolumeTexturePtr vT = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture); 00045 00046 if(vT == NullFC) 00047 { 00048 SWARNING << "BrickSet::buildTextures3D - No Volume" << std::endl; 00049 return; 00050 } 00051 00052 if((brickSize[0] <= overlap) || 00053 (brickSize[1] <= overlap) || 00054 (brickSize[2] <= overlap) ) 00055 { 00056 SFATAL << "BrickSet::buildBricks3D - brickSize too small: " 00057 << brickSize[0] << "," 00058 << brickSize[1] << "," 00059 << brickSize[2] << std::endl; 00060 00061 return; 00062 } 00063 00064 Vec3f vox = vT->getSliceThickness(); 00065 Vec3f res = vT->getResolution(); 00066 Int32 resX = (Int32) res[0]; 00067 Int32 resY = (Int32) res[1]; 00068 Int32 resZ = (Int32) res[2]; 00069 00070 Int32 nNumBricksX = Int32((resX - overlap) / (brickSize[0] - overlap)); 00071 Int32 nNumBricksY = Int32((resY - overlap) / (brickSize[1] - overlap)); 00072 Int32 nNumBricksZ = Int32((resZ - overlap) / (brickSize[2] - overlap)); 00073 00074 SINFO << "BrickSet::buildBricks3D (num)" 00075 << nNumBricksX << ", " 00076 << nNumBricksY << "," 00077 << nNumBricksZ << std::endl; 00078 00079 m_nNumBricks = nNumBricksX * nNumBricksY * nNumBricksZ; 00080 00081 m_pBricks = new Brick[m_nNumBricks]; 00082 00083 Int32 nBrickSizeX = Int32(brickSize[0]); 00084 Int32 nBrickSizeY = Int32(brickSize[1]); 00085 Int32 nBrickSizeZ = Int32(brickSize[2]); 00086 00087 Int32 nXMin = 0; 00088 Int32 nYMin = 0; 00089 Int32 nZMin = 0; 00090 00091 Real32 xmin = (overlap - 1 + 0.5f - resX / 2) * vox[0]; 00092 Real32 ymin = (overlap - 1 + 0.5f - resY / 2) * vox[1]; 00093 Real32 zmin = (overlap - 1 + 0.5f - resZ / 2) * vox[2]; 00094 00095 Real32 xmax = 0, ymax = 0, zmax = 0; 00096 00097 Int32 index = 0; 00098 00099 for(Int32 z = 0; z < nNumBricksZ; z++) 00100 { 00101 nYMin = 0; 00102 ymin = (overlap - 1 + 0.5f - resY / 2) * vox[1]; 00103 00104 for(Int32 y = 0; y < nNumBricksY; y++) 00105 { 00106 nXMin = 0; 00107 xmin = (overlap - 1 + 0.5f - resX / 2) * vox[0]; 00108 00109 for(Int32 x = 0; x < nNumBricksX; x++) 00110 { 00111 xmax = xmin + (nBrickSizeX - (2 * (overlap - 1) + 1)) * vox[0]; 00112 ymax = ymin + (nBrickSizeY - (2 * (overlap - 1) + 1)) * vox[1]; 00113 zmax = zmin + (nBrickSizeZ - (2 * (overlap - 1) + 1)) * vox[2]; 00114 00115 m_pBricks[index].init(nXMin, nYMin, nZMin, 00116 nBrickSizeX, nBrickSizeY, nBrickSizeZ, 00117 xmin, ymin, zmin, 00118 xmax, ymax, zmax, 00119 overlap, 00120 ori ); 00121 00122 index++; 00123 00124 nXMin += nBrickSizeX - (2 * overlap - 1); 00125 xmin = xmax; 00126 } 00127 00128 nYMin += nBrickSizeY - (2 * overlap - 1); 00129 ymin = ymax; 00130 } 00131 00132 nZMin += nBrickSizeZ - (2 * overlap - 1); 00133 zmin = zmax; 00134 } 00135 }
|
|
||||||||||||
|
Definition at line 138 of file OSGBrick.cpp. References DVRVOLUME_PARAMETER, osg::Brick::init(), m_nNumBricks, m_nOrientation, m_pBricks, osg::NullFC, SFATAL, UNDEF, XY, XZ, and YZ. Referenced by osg::TextureManager::buildTextures(). 00139 { 00140 m_nOrientation = ori; 00141 00142 DVRVolumeTexturePtr vT = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture); 00143 00144 if(vT == NullFC) 00145 return; 00146 00147 Vec3f vox = vT->getSliceThickness(); 00148 Vec3f res = vT->getResolution(); 00149 00150 Int32 resX = 0, resY= 0, resZ= 0; 00151 Real32 xmin = 0, ymin = 0, zmin = 0; 00152 Real32 xmax = 0, ymax = 0, zmax = 0; 00153 Real32 xinc = 0, yinc = 0, zinc = 0; 00154 00155 switch(ori) 00156 { 00157 case XY: 00158 { 00159 // XY stack of textures 00160 resX = (Int32) res[0]; 00161 resY = (Int32) res[1]; 00162 resZ = 1; 00163 00164 xinc = 0; 00165 yinc = 0; 00166 zinc = 1; 00167 00168 // "geometrical" size of the brick 00169 xmin = (-(res[0] - 1) / 2) * vox[0]; 00170 ymin = (-(res[1] - 1) / 2) * vox[1]; 00171 zmin = (-(res[2] ) / 2) * vox[2]; 00172 00173 xmax = -xmin; 00174 ymax = -ymin; 00175 zmax = zmin + zinc * vox[2]; 00176 00177 m_nNumBricks = (int) res[2]; 00178 m_pBricks = new Brick[m_nNumBricks]; 00179 00180 break; 00181 } 00182 00183 case XZ: 00184 { 00185 // XZ stack of textures 00186 resX = (Int32) res[0]; 00187 resY = 1; 00188 resZ = (Int32) res[2]; 00189 00190 xinc = 0; 00191 yinc = 1; 00192 zinc = 0; 00193 00194 // "geometrical" size of the brick 00195 xmin = (-(res[0] - 1) / 2) * vox[0]; 00196 ymin = (-(res[1] ) / 2) * vox[1]; 00197 zmin = (-(res[2] - 1) / 2) * vox[2]; 00198 00199 xmax = -xmin; 00200 ymax = ymin + yinc * vox[1]; 00201 zmax = -zmin; 00202 00203 m_nNumBricks = (int) res[1]; 00204 m_pBricks = new Brick[m_nNumBricks]; 00205 00206 break; 00207 } 00208 00209 case YZ: 00210 { 00211 // YZ stack of textures 00212 resX = 1; 00213 resY = (Int32) res[1]; 00214 resZ = (Int32) res[2]; 00215 00216 xinc = 1; 00217 yinc = 0; 00218 zinc = 0; 00219 00220 // "geometrical" size of the brick 00221 xmin = (-(res[0] ) / 2) * vox[0]; 00222 ymin = (-(res[1] - 1) / 2) * vox[1]; 00223 zmin = (-(res[2] - 1) / 2) * vox[2]; 00224 00225 xmax = xmin + xinc * vox[0]; 00226 ymax = -ymin; 00227 zmax = -zmin; 00228 00229 m_nNumBricks = (int) res[0]; 00230 m_pBricks = new Brick[m_nNumBricks]; 00231 00232 break; 00233 } 00234 00235 case UNDEF: 00236 { 00237 SFATAL << "BrickSet::buildBricks2D called with unspecified " 00238 << "orientation" 00239 << std::endl; 00240 break; 00241 } 00242 } 00243 00244 for(Int32 index = 0; index < m_nNumBricks; index++) 00245 { 00246 m_pBricks[index].init(resX == 1 ? index : 0, 00247 resY == 1 ? index : 0, 00248 resZ == 1 ? index : 0, 00249 resX, resY, resZ, 00250 xmin, ymin, zmin, 00251 xmax, ymax, zmax, 00252 1, 00253 ori); 00254 00255 xmin += xinc * vox[0]; 00256 xmax += xinc * vox[0]; 00257 00258 ymin += yinc * vox[1]; 00259 ymax += yinc * vox[1]; 00260 00261 zmin += zinc * vox[2]; 00262 zmax += zinc * vox[2]; 00263 } 00264 }
|
|
||||||||||||||||
|
! FIXME: this is required by the PreIntegration shader but ! may not be supported on all OpenSG platforms - so we must ! add a way that the shader can specify the wrapping Definition at line 268 of file OSGBrick.cpp. References osg::beginEditCP(), osg::TextureChunkBase::create(), osg::endEditCP(), and FDEBUG. Referenced by buildBrickTextures(). 00271 { 00272 TextureChunkPtr chunk = TextureChunk::create(); 00273 00274 beginEditCP(chunk); 00275 { 00276 chunk->setImage (img ); 00277 chunk->setInternalFormat(internalFormat); 00278 chunk->setExternalFormat(externalFormat); 00279 00280 FDEBUG(("TextureManager - makeTexture: intern %d - extern %d\n", 00281 internalFormat, externalFormat)); 00282 00286 #if defined GL_ARB_texture_border_clamp 00287 chunk->setWrapS(GL_CLAMP_TO_BORDER); 00288 chunk->setWrapT(GL_CLAMP_TO_BORDER); 00289 chunk->setWrapR(GL_CLAMP_TO_BORDER); 00290 #else 00291 // chunk->setWrapS(GL_CLAMP_TO_EDGE); 00292 // chunk->setWrapT(GL_CLAMP_TO_EDGE); 00293 // chunk->setWrapR(GL_CLAMP_TO_EDGE); 00294 00295 chunk->setWrapS(GL_CLAMP); 00296 chunk->setWrapT(GL_CLAMP); 00297 chunk->setWrapR(GL_CLAMP); 00298 #endif 00299 00300 chunk->setMinFilter(GL_LINEAR); 00301 chunk->setMagFilter(GL_LINEAR); 00302 00303 // chunk->setEnvMode(GL_REPLACE); 00304 chunk->setEnvMode(GL_MODULATE); 00305 } 00306 endEditCP(chunk); 00307 00308 return chunk; 00309 }
|
|
|
Definition at line 43 of file OSGBrick.h. Referenced by buildBricks2D(), buildBricks3D(), buildBrickTextures(), clearBrickTextures(), osg::TextureManager::clearTextures(), reloadBrickTextures(), sortBricks2D(), sortBricks3D(), and ~BrickSet(). |
|
|
Definition at line 44 of file OSGBrick.h. Referenced by buildBricks2D(), buildBricks3D(), buildBrickTextures(), clearBrickTextures(), osg::TextureManager::clearTextures(), reloadBrickTextures(), sortBricks2D(), and sortBricks3D(). |
|
|
Definition at line 45 of file OSGBrick.h. Referenced by buildBricks2D(), and buildBricks3D(). |
1.4.3