#include <OSGBrick.h>
Public Member Functions | |
| Brick * | getNext (void) |
| Returns next brick in sorted order. | |
| void | init (Int32 minVoxX, Int32 minVoxY, Int32 minVoxZ, Int32 resX, Int32 resY, Int32 resZ, Real32 xMin, Real32 yMin, Real32 zMin, Real32 xMax, Real32 yMax, Real32 zMax, Int32 overlap=1, BrickSet::Orientation ori=BrickSet::UNDEF) |
| Initialize brick size and geometry. | |
| void | activateTexture (DrawActionBase *action) |
| Activate textures. | |
| void | changeFromTexture (DrawActionBase *action, Brick *old) |
| Change active texture. | |
| void | deactivateTexture (DrawActionBase *action) |
| Deactivate textures. | |
| void | renderSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, TextureManager::TextureMode mode) |
| Render 2D/3D Slices. | |
| void | renderBrick (void) |
| Render brick bounding box. | |
| void | vertToTex (Real32 *vx, Real32 *vy, Real32 *vz, Real32 *tx, Real32 *ty, Real32 *tz) |
| Transform vertex to texture coordinates. | |
| void | vertToTex (Vec3f &vert, Vec3f &tex) |
| Transform vertex to texture coordinates. | |
Private Member Functions | |
| void | render3DSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir) |
| Render 3D Slices. | |
| void | render2DSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir) |
| void | render2DMultiSlices (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, bool btf, const Vec3f &sliceDir) |
| Render Slices 2D with Multi-textures. | |
| void | render2DSliceXY (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &zCoord) |
| void | render2DSliceXZ (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &yCoord) |
| void | render2DSliceYZ (DVRVolume *volume, DrawActionBase *action, DVRShaderPtr shader, DVRClipper *clipper, const Vec3f &sliceDir, const Real32 &xCoord) |
Private Attributes | |
| Vec3f | vertex [8] |
| Line | edges [12] |
| TextureChunkPtr * | texture |
| UInt32 * | texStage |
| Int32 | numTextures |
| Vec3f | center |
| Real32 | radius |
| Vec3f | texTranslate |
| Vec3f | texScale |
| Int32 | voxSize [3] |
| Int32 | minVox [3] |
| Vec3f | m_lowerLeft |
| Vec3f | m_upperRight |
| BrickSet::Orientation | m_ori |
| Real32 | distance |
| Brick * | prev |
| Brick * | next |
| DVRSlice | slice |
| DVRRenderSlice | clippedSlice |
Friends | |
| class | BrickSet |
Definition at line 88 of file OSGBrick.h.
|
|
Definition at line 13 of file OSGBrick.inl. References next. Referenced by osg::DVRVolume::draw(). 00014 { 00015 return next; 00016 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
! Initialize edge/vertex structure Definition at line 600 of file OSGBrick.cpp. References center, edges, FINFO, m_lowerLeft, m_ori, m_upperRight, minVox, radius, texScale, texTranslate, vertex, and voxSize. Referenced by osg::BrickSet::buildBricks2D(), and osg::BrickSet::buildBricks3D(). 00606 { 00607 00608 FINFO(("Brick::init - upper left (%d, %d, %d)\n", 00609 minVoxX, minVoxY, minVoxZ)); 00610 00611 FINFO(("Brick::init (%d, %d, %d): %f %f %f -> %f %f %f \n", 00612 resX, resY, resZ, xmin, ymin, zmin, xmax, ymax, zmax)); 00613 00614 Real32 xrange = xmax - xmin; 00615 Real32 yrange = ymax - ymin; 00616 Real32 zrange = zmax - zmin; 00617 00618 minVox[0] = minVoxX; 00619 minVox[1] = minVoxY; 00620 minVox[2] = minVoxZ; 00621 00622 voxSize[0] = resX; 00623 voxSize[1] = resY; 00624 voxSize[2] = resZ; 00625 00626 m_lowerLeft = Vec3f(xmin, ymin, zmin); 00627 m_upperRight = Vec3f(xmax, ymax, zmax); 00628 00629 m_ori = ori; 00630 00631 Real32 texCoorMin[3], texCoorMax[3]; 00632 00633 texCoorMin[0] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resX); 00634 texCoorMin[1] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resY); 00635 texCoorMin[2] = (2 * Real32(overlap) - 1) / 2.0f / Real32(resZ); 00636 00637 texCoorMax[0] = 1 - texCoorMin[0]; 00638 texCoorMax[1] = 1 - texCoorMin[1]; 00639 texCoorMax[2] = 1 - texCoorMin[2]; 00640 00641 texScale = Vec3f((texCoorMax[0] - texCoorMin[0]) / xrange, 00642 (texCoorMax[1] - texCoorMin[1]) / yrange, 00643 (texCoorMax[2] - texCoorMin[2]) / zrange); 00644 00645 texTranslate = Vec3f(texCoorMin[0] - texScale[0] * xmin, 00646 texCoorMin[1] - texScale[1] * ymin, 00647 texCoorMin[2] - texScale[2] * zmin); 00648 00649 FINFO (("Brick::init - overlap: %d \n", 00650 overlap)); 00651 00652 FINFO (("Brick::init - texScale: %f %f %f \n", 00653 texScale[0], texScale[1], texScale[2])); 00654 00655 FINFO (("Brick::init - texTranslate: %f %f %f \n", 00656 texTranslate[0], texTranslate[1], texTranslate[2])); 00657 00659 00660 // 00661 // e3 00662 // v5 o----------------o v4 00663 // /| /| 00664 // / | / | 00665 // e10 / | e9 / |e7 00666 // / | e1 / | 00667 // v3 o----------------o v2 | 00668 // | | | | 00669 // | |e6 | | 00670 // |e5 | |e4 | 00671 // | | e2 | | 00672 // | o-----------|----o v7 00673 // | / v6 | / 00674 // | / | / 00675 // | /e11 | /e8 00676 // |/ |/ 00677 // y o----------------o 00678 // | z v0 e0 v1 00679 // |/ 00680 // +---x 00681 00682 // ------------- Initialize 8 Vertices ------------- 00683 00684 vertex[0] = Vec3f( xmin, ymin, zmin); 00685 vertex[1] = Vec3f( xmax, ymin, zmin); 00686 vertex[2] = Vec3f( xmax, ymax, zmin); 00687 vertex[3] = Vec3f( xmin, ymax, zmin); 00688 00689 vertex[4] = Vec3f( xmax, ymax, zmax); 00690 vertex[5] = Vec3f( xmin, ymax, zmax); 00691 vertex[6] = Vec3f( xmin, ymin, zmax); 00692 vertex[7] = Vec3f( xmax, ymin, zmax); 00693 00694 center = Vec3f(0.0, 0.0, 0.0); 00695 00696 for(Int32 j = 0; j < 8; j++) 00697 { 00698 center += vertex[j]; 00699 } 00700 00701 center /= 8.0; 00702 radius = (vertex[0] - center).length(); 00703 00704 // -------------- Initialize 12 Edges -------------- 00705 00706 const int eindex[12][2] = 00707 { 00708 {0, 1}, // e0 00709 {2, 3}, // e1 00710 {6, 7}, // e2 00711 {4, 5}, // e3 00712 {1, 2}, // e4 00713 {0, 3}, // e5 00714 {5, 6}, // e6 00715 {4, 7}, // e7 00716 {1, 7}, // e8 00717 {2, 4}, // e9 00718 {3, 5}, // e10 00719 {0, 6} // e11 00720 }; 00721 00722 for(Int32 i = 0; i < 12; i++) 00723 { 00724 edges[i] = Line(Pnt3f(vertex[eindex[i][0]]), 00725 Pnt3f(vertex[eindex[i][1]])); 00726 } 00727 00728 #if 0 00729 TOUT("Init Brick"); 00730 TOUT("Brick (" << x << ", " << y << ", " << z << ")"); 00731 TOUT(VARDUMP(nXMin) << ", " << VARDUMP(nXMax)); 00732 TOUT(VARDUMP(nYMin) << ", " << VARDUMP(nYMax)); 00733 TOUT(VARDUMP(nZMin) << ", " << VARDUMP(nZMax)); 00734 TOUT(VARDUMP(nDataSize)); 00735 #endif 00736 }
|
|
|
Definition at line 740 of file OSGBrick.cpp. References FDEBUG, numTextures, texStage, and texture. Referenced by changeFromTexture(), render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), and render3DSlices(). 00741 { 00742 for(Int32 i = 0; i < numTextures; i++) 00743 { 00744 FDEBUG(("Brick::activateTexture - Brick: %d - Texture %d " 00745 "- Stage: %d - ID: %d\n", 00746 this, i, texStage[i], texture[i]->getGLId())); 00747 00748 texture[i]->activate(action, texStage[i]); 00749 } 00750 }
|
|
||||||||||||
|
Definition at line 754 of file OSGBrick.cpp. References activateTexture(), FDEBUG, numTextures, texStage, and texture. 00755 { 00756 FDEBUG(("Brick::changeFromTexture\n")); 00757 00758 if(old == NULL) 00759 activateTexture(action); 00760 00761 for(Int32 i = 0; i < numTextures; i++) 00762 { 00763 texture[i]->changeFrom(action, &(*(old->texture[i])), texStage[i]); 00764 } 00765 }
|
|
|
Definition at line 769 of file OSGBrick.cpp. References numTextures, texStage, and texture. Referenced by osg::DVRVolume::draw(), render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), and render3DSlices(). 00770 { 00771 for(Int32 i = 0; i < numTextures; i++) 00772 { 00773 texture[i]->deactivate(action, texStage[i]); 00774 } 00775 00776 }
|
|
||||||||||||||||||||||||
|
Definition at line 780 of file OSGBrick.cpp. References FDEBUG, osg::Slicer::getAASlicingDirection(), osg::Slicer::getSlicingDirection(), GL_TEXTURE_3D, GLboolean, osg::Slicer::isBackToFront(), render2DMultiSlices(), render2DSlices(), render3DSlices(), SWARNING, osg::TextureManager::TM_2D, osg::TextureManager::TM_2D_Multi, and osg::TextureManager::TM_3D. 00785 { 00786 switch (textureMode) 00787 { 00788 case TextureManager::TM_2D: 00789 { 00790 GLboolean val; 00791 glGetBooleanv(GL_TEXTURE_3D, &val); 00792 00793 if(val != 0) 00794 { 00795 glDisable(GL_TEXTURE_3D); 00796 SWARNING << "Brick::renderSlices - 3DTextures enabled " 00797 << "-> DISABLING " 00798 << (int) val 00799 << std::endl; 00800 } 00801 00802 Vec3f sliceDir; 00803 00804 Slicer::getAASlicingDirection(action, &sliceDir); 00805 00806 render2DSlices(volume, action, shader, clipper, sliceDir); 00807 00808 break; 00809 } 00810 case TextureManager::TM_2D_Multi: 00811 { 00812 FDEBUG(("Brick::renderSlices - 2D MTex Slabs\n")); 00813 00814 Vec3f sliceDir; 00815 00816 Int32 dir = Slicer::getAASlicingDirection(action, &sliceDir); 00817 00818 render2DMultiSlices(volume, action, shader, clipper, 00819 Slicer::isBackToFront(dir),sliceDir); 00820 break; 00821 } 00822 00823 default: 00824 case TextureManager::TM_3D: 00825 { 00826 FDEBUG(("Brick::renderSlices -3D slices\n")); 00827 00828 Vec3f sliceDir; 00829 00830 Slicer::getSlicingDirection(action, &sliceDir); 00831 00832 render3DSlices(volume, action, shader, clipper, sliceDir); 00833 00834 break; 00835 } 00836 } 00837 }
|
|
|
Definition at line 841 of file OSGBrick.cpp. References FDEBUG, GL_TEXTURE_3D, and vertex. Referenced by osg::DVRVolume::draw(). 00842 { 00843 FDEBUG(("Brick::renderBrick")); 00844 00845 const int eindex[12][2] = 00846 { 00847 {0,1}, 00848 {2,3}, 00849 {6,7}, 00850 {4,5}, 00851 {1,2}, 00852 {0,3}, 00853 {5,6}, 00854 {4,7}, 00855 {1,7}, 00856 {2,4}, 00857 {3,5}, 00858 {0,6} 00859 }; 00860 00861 glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); 00862 glDisable (GL_TEXTURE_3D); 00863 glDisable (GL_TEXTURE_2D); 00864 00865 glColor4f (1.0, 0.0, 0.0, 1.0 ); 00866 00867 glBegin(GL_LINES); 00868 { 00869 for(Int32 i = 0; i < 12; i++) 00870 { 00871 glVertex3fv(vertex[eindex[i][0]].getValues()); 00872 glVertex3fv(vertex[eindex[i][1]].getValues()); 00873 } 00874 } 00875 glEnd(); 00876 00877 glPopAttrib(); 00878 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 882 of file OSGBrick.cpp. References texScale, and texTranslate. 00884 { 00885 *tx = *vx * texScale[0] + texTranslate[0]; 00886 *ty = *vy * texScale[1] + texTranslate[1]; 00887 *tz = *vz * texScale[2] + texTranslate[2]; 00888 }
|
|
||||||||||||
|
Definition at line 892 of file OSGBrick.cpp. References texScale, and texTranslate. 00893 { 00894 tex[0] = vert[0] * texScale[0] + texTranslate[0]; 00895 tex[1] = vert[1] * texScale[1] + texTranslate[1]; 00896 tex[2] = vert[2] * texScale[2] + texTranslate[2]; 00897 };
|
|
||||||||||||||||||||||||
|
Definition at line 901 of file OSGBrick.cpp. References activateTexture(), center, osg::DVRRenderSlice::clear(), clippedSlice, osg::DVRClipper::clipSlice(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(), deactivateTexture(), osg::DVRRenderSlice::directRender, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), DVRVOLUME_PARAMETER, edges, FACE_BACK, FACE_BOTTOM, FACE_FRONT, FACE_LEFT, FACE_RIGHT, FACE_TOP, FDEBUG, osg::DVRVolumeBase::getBaseAlpha(), osg::DVRVolumeBase::getDoTextures(), osg::DVRVolumeBase::getSampling(), osg::PointInterface< ValueTypeT, StorageInterfaceT >::getValues(), osg::Plane::intersect(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::NullFC, osg::DVRRenderSlice::numPerVertexData, osg::DVRClipObjects::Off, osg::Plane::offset(), osg::DVRRenderSlice::orientation, osg::osgpow(), radius, osg::DVRClipper::reset(), osg::DVRSlice::resetSlice(), osg::DVRSlice::setNormal(), osg::DVRSlice::setTextureTransform(), osg::DVRSlice::setVertex(), SINFO, slice, texScale, texTranslate, and osg::DVRRenderSlice::UNDEFINED. Referenced by renderSlices(). 00906 { 00907 Int32 i, j; 00908 00909 DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture); 00910 00911 if(tex == NullFC) 00912 return; 00913 00914 Vec3f res = tex->getResolution(); 00915 Vec3f vox = tex->getSliceThickness(); 00916 00917 Real32 fSampleRate = volume->getSampling(); 00918 Real32 fSliceDistance = vox.length() / 2.0f / fSampleRate; 00919 Real32 fTolerance = fSliceDistance / 100.0f; 00920 Real32 fAlphaCorrect = 1.f - osgpow(1.f - volume->getBaseAlpha(), 00921 1.0f / fSampleRate ); 00922 00923 SINFO << "Sampling rate: " 00924 << fSampleRate 00925 << " Alpha-Correction " 00926 << fAlphaCorrect 00927 << std::endl; 00928 00929 Vec3f diag(res[0]*vox[0], res[1]*vox[1], res[2]*vox[2]); 00930 00931 Real32 fRadius = 0.5f * diag.length(); 00932 00933 const int ecodes[12] = 00934 { 00935 (FACE_FRONT + FACE_BOTTOM), // edge 0 00936 (FACE_FRONT + FACE_TOP ), // edge 1 00937 (FACE_BACK + FACE_BOTTOM), // edge 2 00938 (FACE_BACK + FACE_TOP ), // edge 3 00939 00940 (FACE_FRONT + FACE_RIGHT ), // edge 4 00941 (FACE_FRONT + FACE_LEFT ), // edge 5 00942 (FACE_BACK + FACE_LEFT ), // edge 6 00943 (FACE_BACK + FACE_RIGHT ), // edge 7 00944 00945 (FACE_RIGHT + FACE_BOTTOM), // edge 8 00946 (FACE_RIGHT + FACE_TOP ), // edge 9 00947 (FACE_TOP + FACE_LEFT ), // edge 10 00948 (FACE_BOTTOM + FACE_LEFT ) // edge 11 00949 }; 00950 00951 // get the slicing normal 00952 Vec3f vecViewDir = sliceDir; 00953 00954 Plane planeSlice(vecViewDir, -fRadius); 00955 00956 Int32 numSlices = 1 + (Int32) (2.0f * fRadius/ fSliceDistance); 00957 00958 Vec3f vecIntersections[12]; 00959 Int32 nEdgeCodes[12]; 00960 00961 bool bIntersectionUsed[12]; 00962 00963 Vec3f vecIntersectionsSorted[12]; 00964 Vec3f vecIntersection; 00965 00966 Int32 nSlice, numIntersections, nEdgeCode, numUsedIntersections; 00967 00968 Vec3f v, texscale, textrans; 00969 00970 texscale = texScale; 00971 textrans = texTranslate; 00972 00973 // set the reference plane for clipping 00974 DVRClipObjectsPtr clipObjects = DVRVOLUME_PARAMETER(volume, 00975 DVRClipObjects); 00976 00977 bool doClipping = false; 00978 00979 if(clipObjects != NullFC) 00980 { 00981 if(clipObjects->count() > 0 && 00982 clipObjects->getClipMode() != DVRClipObjects::Off) 00983 { 00984 doClipping = true; 00985 clipper->reset(volume); 00986 } 00987 } 00988 00989 slice.setTextureTransform(texScale,texTranslate); 00990 00991 for(nSlice = 0; nSlice < numSlices; nSlice++) 00992 { 00993 00994 // calculate intersection with each edge 00995 numIntersections = 0; 00996 00997 for(i = 0; i < 12; i++) 00998 { 00999 if(planeSlice.intersect(edges[i],vecIntersection)) 01000 { 01001 01002 if((vecIntersection-center).length() <= radius) 01003 { 01004 vecIntersections[numIntersections] = vecIntersection; 01005 nEdgeCodes[numIntersections] = ecodes[i]; 01006 bIntersectionUsed[numIntersections] = false; 01007 01008 numIntersections++; 01009 } 01010 } 01011 } 01012 01013 // eleminate double vertices 01014 // -------------------------------------------- 01015 01016 if (numIntersections > 2) 01017 { 01018 for(i = 0; i < numIntersections-1; i++) 01019 { 01020 for(j = i+1; j < numIntersections; j++) 01021 { 01022 if((vecIntersections[i]-vecIntersections[j]).length() < 01023 fTolerance) 01024 { 01025 // merge the two intersections 01026 nEdgeCodes[i] |= nEdgeCodes[j]; 01027 // remove j 01028 if(j < numIntersections-1) 01029 { 01030 vecIntersections[j] = 01031 vecIntersections[numIntersections-1]; 01032 nEdgeCodes[j] = nEdgeCodes[numIntersections-1]; 01033 01034 // vertex j has changed, so examine the 01035 // vertex j again 01036 j--; 01037 } 01038 01039 numIntersections--; 01040 } 01041 } 01042 } 01043 } 01044 01045 assert(numIntersections <= 6); 01046 01047 if(numIntersections > 2) 01048 { 01049 01050 //find correct sequence; 01051 vecIntersectionsSorted[0] = vecIntersections[0]; 01052 bIntersectionUsed[0] = true; 01053 numUsedIntersections = 1; 01054 01055 nEdgeCode = nEdgeCodes[0]; 01056 01057 // HACK need to fix the endless loop! 01058 UInt32 count = 0; 01059 while(numUsedIntersections != numIntersections && ++count <= numIntersections) 01060 { 01061 for(Int32 i = 1; i < numIntersections; i++) 01062 { 01063 if ((bIntersectionUsed[i] == false ) && 01064 (nEdgeCodes[i] & nEdgeCode) ) 01065 { 01066 vecIntersectionsSorted[numUsedIntersections] = 01067 vecIntersections[i]; 01068 01069 nEdgeCode = nEdgeCodes[i]; 01070 bIntersectionUsed[i] = true; 01071 01072 numUsedIntersections++; 01073 } 01074 } 01075 } 01076 01077 if(doClipping) 01078 { 01079 // check slice orientation 01080 Vec3f sliceNormal = 01081 (vecIntersectionsSorted[1] - 01082 vecIntersectionsSorted[0]).cross( 01083 vecIntersectionsSorted[2]-vecIntersectionsSorted[1]); 01084 01085 bool sliceCCW = sliceNormal.dot(sliceDir) > 0.0; 01086 01087 slice.resetSlice(); 01088 01089 if(sliceCCW) 01090 { 01091 for(Int32 i = 0; i < numIntersections; i++) 01092 { 01093 slice.setVertex(vecIntersectionsSorted[i]); 01094 } 01095 } 01096 else 01097 { 01098 for(Int32 i = numIntersections-1; i >=0 ; i--) 01099 { 01100 slice.setVertex(vecIntersectionsSorted[i]); 01101 } 01102 } 01103 01104 slice.setNormal(sliceDir); 01105 01106 // number of additional per vertex attributes 01107 // (not position + first texture coordinates) 01108 01109 clippedSlice.numPerVertexData = 0; 01110 01111 // we use 3D textures 01112 clippedSlice.orientation = DVRRenderSlice::UNDEFINED; 01113 01114 // contours only 01115 if(clipObjects->getDoContours()) 01116 { 01117 deactivateTexture(action); 01118 clipper->clipSlice(volume, 01119 slice, 01120 sliceDir, 01121 fSliceDistance * nSlice, 01122 clippedSlice); 01123 activateTexture(action); 01124 } 01125 else if (shader->hasRenderCallback()) 01126 { 01127 // shader managed slice rendering 01128 01129 clippedSlice.directRender = false; 01130 01131 clipper->clipSlice(volume, slice, 01132 sliceDir, 01133 fSliceDistance * nSlice, 01134 clippedSlice); 01135 01136 shader->renderSlice(volume, action, &clippedSlice); 01137 } 01138 else if (volume->getDoTextures()) 01139 { 01140 // textured slices 01141 01142 clippedSlice.directRender = true; 01143 01144 clipper->clipSlice(volume, 01145 slice, 01146 sliceDir, 01147 fSliceDistance * nSlice, 01148 clippedSlice); 01149 } 01150 else 01151 { 01152 // untextured slices only 01153 01154 glColor4f(1.0, 1.0, 1.0, 1.0); 01155 01156 clippedSlice.directRender = true; 01157 01158 clipper->clipSlice(volume, 01159 slice, 01160 sliceDir, 01161 fSliceDistance * nSlice, 01162 clippedSlice); 01163 } 01164 clippedSlice.clear(); 01165 } 01166 else 01167 { 01168 // clipping disabled 01169 01170 if(shader->hasRenderCallback()) 01171 { 01172 01173 // copy all data into a single field and 01174 // call rendercallback 01175 01176 Real32 data[12 * 6]; // numIntersections is bounded by 12 01177 UInt32 index = 0; 01178 01179 for(Int32 i = 0; i < numIntersections; i++) 01180 { 01181 v = vecIntersectionsSorted[i]; 01182 01183 data[index++] = v[0]; 01184 data[index++] = v[1]; 01185 data[index++] = v[2]; 01186 01187 data[index++] = v[0] * texscale[0] + textrans[0]; 01188 data[index++] = v[1] * texscale[1] + textrans[1]; 01189 data[index++] = v[2] * texscale[2] + textrans[2]; 01190 } 01191 01192 shader->renderSlice(volume, 01193 action, 01194 data, 01195 numIntersections, 01196 6); 01197 } 01198 else if (volume->getDoTextures()) 01199 { 01200 // textured slices 01201 01202 glBegin(GL_TRIANGLE_FAN); 01203 01204 for(i = 0; i < numIntersections; i++) 01205 { 01206 v = vecIntersectionsSorted[i]; 01207 01208 glColor4f(1.0, 1.0, 1.0, fAlphaCorrect); 01209 01210 glTexCoord3f((v[0] * texscale[0] + textrans[0]), 01211 (v[1] * texscale[1] + textrans[1]) , 01212 (v[2] * texscale[2] + textrans[2])); 01213 glVertex3fv(v.getValues()); 01214 01215 FDEBUG( 01216 ("Brick::render3DSlices V: %f %f %f T: %f %f %f\n", 01217 v[0], v[1], v[2], 01218 (v[0] * texscale[0] + textrans[0]), 01219 (v[1] * texscale[1] + textrans[1]), 01220 (v[2] * texscale[2] + textrans[2]))); 01221 } 01222 01223 glEnd(); 01224 01225 } 01226 else 01227 { 01228 // untextured slices only 01229 01230 glColor4f(1.0, 1.0, 1.0, 1.0); 01231 01232 glBegin(GL_LINE_LOOP); 01233 { 01234 for(i = 0; i < numIntersections; i++) 01235 { 01236 v = vecIntersectionsSorted[i]; 01237 01238 glVertex3fv(v.getValues()); 01239 } 01240 } 01241 glEnd(); 01242 } 01243 } 01244 } 01245 01246 // next plane 01247 planeSlice.offset(fSliceDistance); 01248 } 01249 }
|
|
||||||||||||||||||||||||
|
Definition at line 1874 of file OSGBrick.cpp. References center, clippedSlice, m_ori, osg::DVRRenderSlice::numPerVertexData, osg::DVRRenderSlice::orientation, render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), osg::DVRSlice::setTextureTransform(), slice, texScale, texTranslate, osg::DVRRenderSlice::XY, osg::BrickSet::XY, osg::DVRRenderSlice::XZ, osg::BrickSet::XZ, osg::DVRRenderSlice::YZ, and osg::BrickSet::YZ. Referenced by renderSlices(). 01879 { 01880 // number of additional per vertex attributes 01881 // (not position + first texture coordinates) 01882 01883 clippedSlice.numPerVertexData = 0; 01884 01885 slice.setTextureTransform(texScale,texTranslate); 01886 01887 switch(m_ori) 01888 { 01889 case BrickSet::XY: 01890 clippedSlice.orientation = DVRRenderSlice::XY; 01891 render2DSliceXY(volume, 01892 action, 01893 shader, 01894 clipper, 01895 sliceDir, 01896 center[2]); 01897 break; 01898 01899 case BrickSet::XZ: 01900 clippedSlice.orientation = DVRRenderSlice::XZ; 01901 render2DSliceXZ(volume, 01902 action, 01903 shader, 01904 clipper, 01905 sliceDir, 01906 center[1]); 01907 break; 01908 01909 case BrickSet::YZ: 01910 clippedSlice.orientation = DVRRenderSlice::YZ; 01911 render2DSliceYZ(volume, 01912 action, 01913 shader, 01914 clipper, 01915 sliceDir, 01916 center[0]); 01917 break; 01918 01919 default: 01920 break; 01921 } 01922 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1926 of file OSGBrick.cpp. References clippedSlice, DVRVOLUME_PARAMETER, FDEBUG, osg::DVRVolumeBase::getSampling(), m_lowerLeft, m_ori, m_upperRight, osg::NullFC, osg::DVRRenderSlice::numPerVertexData, osg::DVRRenderSlice::orientation, render2DSliceXY(), render2DSliceXZ(), render2DSliceYZ(), osg::DVRSlice::setTextureTransform(), SINFO, slice, texScale, texTranslate, osg::DVRRenderSlice::XY, osg::BrickSet::XY, osg::DVRRenderSlice::XZ, osg::BrickSet::XZ, osg::DVRRenderSlice::YZ, and osg::BrickSet::YZ. Referenced by renderSlices(). 01932 { 01933 DVRVolumeTexturePtr tex = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture); 01934 01935 if(tex == NullFC) 01936 return; 01937 01938 Vec3f res = tex->getResolution(); 01939 Vec3f vox = tex->getSliceThickness(); 01940 01941 Real32 fSampleRate = volume->getSampling(); 01942 01943 Int32 dim = 2 - m_ori; // dimension perpenticular to slice planes 01944 01945 Real32 numSlices = res[dim] * fSampleRate; 01946 01947 // ancor for the slices 01948 Real32 anchor = (-res[dim] / 2.0f + 0.5f) * vox[dim]; 01949 Real32 dist = vox[dim] / fSampleRate; 01950 01951 if(btf) 01952 { 01953 SINFO << "Brick::render2DMultiSlices - BTF" << std::endl; 01954 01955 anchor = -anchor; 01956 dist = -dist; 01957 } 01958 01959 FDEBUG(("Brick::render2DMultiSlices - ori: %d", m_ori)); 01960 FDEBUG(("Brick::render2DMultiSlices - numSlices: %d", numSlices)); 01961 01962 // number of additional per vertex attributes 01963 // (not position + first texture coordinates) 01964 01965 clippedSlice.numPerVertexData = 0; 01966 01967 Vec3f multiTexScale = texScale; 01968 Vec3f multiTexTranslate = texTranslate; 01969 01970 switch(m_ori) 01971 { 01972 case BrickSet::XY: 01973 01974 clippedSlice.orientation = DVRRenderSlice::XY; 01975 01976 // "reuse" texScale/translate for setting the interpolation 01977 // factor whem clipping is performed 01978 multiTexScale[2] = 0.0; 01979 01980 for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++) 01981 { 01982 if((anchor >= m_lowerLeft[2]) && (anchor < m_upperRight[2])) 01983 { 01984 FDEBUG(("Slice %d: %f\n", nSlice, anchor)); 01985 01986 multiTexTranslate[2] = anchor - m_lowerLeft[2]; 01987 01988 slice.setTextureTransform(multiTexScale,multiTexTranslate); 01989 01990 render2DSliceXY(volume, 01991 action, 01992 shader, 01993 clipper, 01994 sliceDir, 01995 anchor); 01996 } 01997 01998 // next slice 01999 anchor += dist; 02000 } 02001 break; 02002 02003 case BrickSet::XZ: 02004 02005 clippedSlice.orientation = DVRRenderSlice::XZ; 02006 02007 multiTexScale[1] = 0.0; 02008 02009 for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++) 02010 { 02011 if((anchor >= m_lowerLeft[1]) && (anchor < m_upperRight[1])) 02012 { 02013 FDEBUG(("Slice %d: %f\n", nSlice, anchor)); 02014 // "reuse" texScale/translate for setting the 02015 // interpolation factor whem clipping is performed 02016 02017 multiTexTranslate[1] = anchor - m_lowerLeft[1]; 02018 02019 slice.setTextureTransform(multiTexScale,multiTexTranslate); 02020 02021 render2DSliceXZ(volume, 02022 action, 02023 shader, 02024 clipper, 02025 sliceDir, 02026 anchor); 02027 } 02028 // next slice 02029 anchor += dist; 02030 } 02031 break; 02032 02033 case BrickSet::YZ: 02034 02035 clippedSlice.orientation = DVRRenderSlice::YZ; 02036 02037 multiTexScale[0] = 0.0; 02038 02039 for(UInt32 nSlice = 0; nSlice < numSlices; nSlice++) 02040 { 02041 if((anchor >= m_lowerLeft[0]) && (anchor < m_upperRight[0])) 02042 { 02043 FDEBUG(("Slice %d: %f\n", nSlice, anchor)); 02044 // "reuse" texScale/translate for setting the 02045 // interpolation factor whem clipping is performed 02046 02047 multiTexTranslate[0] = anchor - m_lowerLeft[0]; 02048 02049 slice.setTextureTransform(multiTexScale,multiTexTranslate); 02050 02051 render2DSliceYZ(volume, 02052 action, 02053 shader, 02054 clipper, 02055 sliceDir, 02056 anchor); 02057 } 02058 02059 // next slice 02060 anchor += dist; 02061 } 02062 break; 02063 02064 default: 02065 break; 02066 } 02067 }
|
|
||||||||||||||||||||||||||||