osg::Slicer Struct Reference

#include <OSGSlicer.h>

List of all members.

Public Types

enum  SliceDir {
  SD_X_FRONT_TO_BACK, SD_X_BACK_TO_FRONT, SD_Y_FRONT_TO_BACK, SD_Y_BACK_TO_FRONT,
  SD_Z_FRONT_TO_BACK, SD_Z_BACK_TO_FRONT
}

Static Public Member Functions

static Int32 getAASlicingDirection (DrawActionBase *da, Vec3f *pViewDir)
static Int32 getSlicingDirection (DrawActionBase *da, Vec3f *pViewDir)
static void rotateToLocal (DrawActionBase *da, Vec3f &in, Vec3f &out)
static bool isBackToFront (Int32 sliceDir)

Detailed Description

Definition at line 24 of file OSGSlicer.h.


Member Enumeration Documentation

Enumerator:
SD_X_FRONT_TO_BACK 
SD_X_BACK_TO_FRONT 
SD_Y_FRONT_TO_BACK 
SD_Y_BACK_TO_FRONT 
SD_Z_FRONT_TO_BACK 
SD_Z_BACK_TO_FRONT 

Definition at line 26 of file OSGSlicer.h.


Member Function Documentation

Int32 Slicer::getAASlicingDirection ( DrawActionBase da,
Vec3f pViewDir 
) [static]

Definition at line 26 of file OSGSlicer.cpp.

References getSlicingDirection(), SD_X_BACK_TO_FRONT, SD_X_FRONT_TO_BACK, SD_Y_BACK_TO_FRONT, SD_Y_FRONT_TO_BACK, SD_Z_BACK_TO_FRONT, and SD_Z_FRONT_TO_BACK.

Referenced by osg::DVRVolume::initializeClipObjects(), and osg::Brick::renderSlices().

00027 {
00028     Int32 dir           = getSlicingDirection(da, NULL);
00029     Vec3f finalSliceDir;
00030 
00031     switch (dir) 
00032     {
00033         case SD_Z_FRONT_TO_BACK:
00034             finalSliceDir = Vec3f(0, 0, 1);
00035             break;
00036 
00037         case SD_Z_BACK_TO_FRONT:
00038             finalSliceDir = Vec3f(0, 0, -1);
00039             break;
00040 
00041         case SD_Y_BACK_TO_FRONT:
00042             finalSliceDir = Vec3f(0, -1, 0);
00043             break;
00044 
00045         case SD_Y_FRONT_TO_BACK:
00046             finalSliceDir = Vec3f(0, 1, 0);
00047             break;
00048 
00049         case SD_X_BACK_TO_FRONT:
00050             finalSliceDir = Vec3f(-1, 0, 0);
00051             break;
00052 
00053         case SD_X_FRONT_TO_BACK:
00054             finalSliceDir = Vec3f(1, 0, 0);
00055             break;
00056 
00057         default:
00058             finalSliceDir = Vec3f(0, 0, 1);
00059             break;
00060     }
00061 
00062     if (pViewDir != NULL)
00063         *pViewDir = finalSliceDir;
00064 
00065     return dir;
00066 }

Int32 Slicer::getSlicingDirection ( DrawActionBase da,
Vec3f pViewDir 
) [static]

Definition at line 69 of file OSGSlicer.cpp.

References osg::Action::getActNode(), osg::DrawActionBase::getCameraToWorld(), osg::TransformationMatrix< ValueTypeT >::getTransform(), osg::QuaternionBase< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::QuaternionBase< ValueTypeT >::multVec(), SD_X_BACK_TO_FRONT, SD_X_FRONT_TO_BACK, SD_Y_BACK_TO_FRONT, SD_Y_FRONT_TO_BACK, SD_Z_BACK_TO_FRONT, and SD_Z_FRONT_TO_BACK.

Referenced by osg::DVRIsoShader::activate_FragmentProgramShading(), getAASlicingDirection(), osg::DVRVolume::initializeClipObjects(), osg::Brick::renderSlices(), osg::DVRIsoShader::setupCombinerParametersSpecular(), and osg::TextureManager::sortBricks().

00070 {
00071     static const Vec3f      zAxis(0.0, 0.0, 1.0);
00072     static       Quaternion dummyRot;   // static over all SoVolume instances
00073     static       Vec3f      vecToCam;   // only temporally, does not matter
00074     static       Vec3f      volTranslation;
00075     static       Vec3f      volScale;
00076     static       Vec3f      dummyVec;
00077     static       Quaternion volRotationInv;
00078     static       Quaternion camRotationInv;   
00079                  Vec3f      finalSliceDir;
00080    
00081     // Get viewing matrix
00082     Matrix   viewMat = da->getCameraToWorld();
00083 
00084     viewMat.invert();
00085     viewMat.getTransform(vecToCam, camRotationInv, dummyVec, dummyRot);
00086     camRotationInv.invert();
00087 
00088     // Get model matrix
00089     Matrix   modelMat = da->getActNode()->getToWorld();
00090 
00091     modelMat.getTransform(volTranslation, volRotationInv, volScale, dummyRot); 
00092     volRotationInv.invert();
00093 
00094     // Get viewing vector pointing to camera
00095     camRotationInv.multVec(zAxis, vecToCam);
00096     volRotationInv.multVec(vecToCam, finalSliceDir);
00097 
00098     Real64 x = finalSliceDir[0];
00099     Real64 y = finalSliceDir[1];
00100     Real64 z = finalSliceDir[2];
00101     Real64 X = (x > 0) ? x: -x;
00102     Real64 Y = (y > 0) ? y: -y;
00103     Real64 Z = (z > 0) ? z: -z;
00104    
00105     Int32 nfinalSliceDir;
00106 
00107     if((Z > Y) && (Z > X))  // Z is the largest component
00108     {
00109         if (z > 0) 
00110         { 
00111             nfinalSliceDir = SD_Z_FRONT_TO_BACK;
00112         } 
00113         else 
00114         {
00115             nfinalSliceDir = SD_Z_BACK_TO_FRONT;
00116         }
00117     } 
00118     else
00119     {
00120         if(Y > X) 
00121         {
00122             if(y < 0) 
00123             {
00124                 nfinalSliceDir = SD_Y_BACK_TO_FRONT;
00125             } 
00126             else 
00127             {
00128                 nfinalSliceDir = SD_Y_FRONT_TO_BACK;
00129             }
00130         } 
00131         else 
00132         {
00133             if(x < 0) 
00134             {
00135                 nfinalSliceDir = SD_X_BACK_TO_FRONT;
00136             } 
00137             else 
00138             {
00139                 nfinalSliceDir = SD_X_FRONT_TO_BACK;
00140             }
00141         }
00142     }
00143 
00144     if(pViewDir != NULL) 
00145     {
00146         *pViewDir = finalSliceDir;
00147     }
00148 
00149     return nfinalSliceDir;
00150 }

void Slicer::rotateToLocal ( DrawActionBase da,
Vec3f in,
Vec3f out 
) [static]

Definition at line 153 of file OSGSlicer.cpp.

References osg::Action::getActNode(), osg::DrawActionBase::getCameraToWorld(), osg::TransformationMatrix< ValueTypeT >::getTransform(), osg::QuaternionBase< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::invert(), and osg::QuaternionBase< ValueTypeT >::multVec().

Referenced by osg::DVRIsoShader::activate_FragmentProgramShading(), osg::DVRIsoShader::deactivate_ColorMatrixShading(), osg::DVRIsoShader::setupCombinerParametersDiffuse(), and osg::DVRIsoShader::setupCombinerParametersSpecular().

00154 {
00155     static Quaternion   dummyRot;
00156     static Vec3f        tempVec;
00157     static Vec3f        volTranslation;
00158     static Vec3f        camTranslation;
00159     static Vec3f        volScale;
00160     static Vec3f        camScale;
00161     static Quaternion   volRotationInv;
00162     static Quaternion   camRotationInv; 
00163    
00164     // Get viewing matrix
00165     Matrix viewMat = da->getCameraToWorld();
00166 
00167     viewMat.invert();
00168     viewMat.getTransform(camTranslation, camRotationInv, camScale, dummyRot);
00169     camRotationInv.invert();
00170    
00171     // Get model matrix
00172     Matrix modelMat = da->getActNode()->getToWorld();
00173 
00174     modelMat.getTransform(volTranslation, volRotationInv, volScale, dummyRot); 
00175     volRotationInv.invert();
00176    
00177     // Rotate vector invers to view camera and model matrix
00178     camRotationInv.multVec(in,      tempVec);
00179     volRotationInv.multVec(tempVec, out    );
00180 }

static bool osg::Slicer::isBackToFront ( Int32  sliceDir  )  [static]

The documentation for this struct was generated from the following files:

Generated on 8 Feb 2010 for OpenSG by  doxygen 1.6.1