#include <TAPsOpenGL3DModel.hpp>


Public Member Functions | |
| void | Default () |
| virtual void | DrawGL (GLenum drawMode=GL_QUADS) |
| virtual void | DrawVertexNormals () |
| virtual T | GetMaxHalfLength () const |
| virtual void | Initialize () |
| OpenGL3DModel () | |
| bool | SetData (int sizeX, int sizeY, int sizeZ, unsigned char *pr3DRawData) |
| virtual void | ToggleDisplayVertexNormals () |
| virtual | ~OpenGL3DModel () |
Private Attributes | |
| GLint | m_3dt_border |
| GLenum | m_3dt_dataType |
| GLint | m_3dt_internalFormat |
| GLint | m_3dt_level |
| GLenum | m_3dt_pixelFormat |
| GLint | m_3dt_size [3] |
| GLenum | m_3dt_target |
| GLuint | m_gluiName3DTexture |
Definition at line 22 of file TAPsOpenGL3DModel.hpp.
| BEGIN_NAMESPACE_TAPs__OpenGL OpenGL3DModel< T >::OpenGL3DModel | ( | ) | [inline] |
Definition at line 20 of file TAPsOpenGL3DModel.cpp.
00020 : OpenGLModel<T>() 00021 { 00022 Default(); 00023 00024 #ifdef TAPs_DEBUG_MODE 00025 std::cout << "OpenGL3DModel<" << typeid(T).name() << "> constructor\n"; 00026 #endif//TAPs_DEBUG_MODE 00027 }
| OpenGL3DModel< T >::~OpenGL3DModel | ( | ) | [inline, virtual] |
Definition at line 31 of file TAPsOpenGL3DModel.cpp.
00032 { 00033 //--------------------------------------------------------------- 00034 // Delete The 3D Texture 00035 if ( m_gluiName3DTexture > 0 ) { 00036 glDeleteTextures( 1, &m_gluiName3DTexture ); 00037 } 00038 //--------------------------------------------------------------- 00039 00040 #ifdef TAPs_DEBUG_MODE 00041 std::cout << "OpenGL3DModel<" << typeid(T).name() << "> destructor\n"; 00042 #endif//TAPs_DEBUG_MODE 00043 }
| void OpenGL3DModel< T >::Default | ( | ) | [inline] |
Definition at line 47 of file TAPsOpenGL3DModel.cpp.
00048 { 00049 m_gluiName3DTexture = 0; 00050 m_3dt_target = GL_TEXTURE_3D; 00051 m_3dt_level = 0; 00052 m_3dt_internalFormat = GL_RGBA32F_ARB; 00053 m_3dt_size[0] = m_3dt_size[1] = m_3dt_size[2] = 0; 00054 m_3dt_border = 0; 00055 m_3dt_pixelFormat = GL_RGBA; 00056 m_3dt_dataType = GL_FLOAT; 00057 }
| void OpenGL3DModel< T >::DrawGL | ( | GLenum | drawMode = GL_QUADS |
) | [inline, virtual] |
Implements OpenGLSupport.
Definition at line 164 of file TAPsOpenGL3DModel.cpp.
00165 { 00166 //--------------------------------------------------------------- 00167 // Draw The 3D Texture 00168 if ( m_gluiName3DTexture ) { 00169 glPushAttrib( GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT ); 00170 glEnable( GL_LIGHTING ); 00171 //glDisable( GL_LIGHTING ); 00172 //glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE ); 00173 //--------------------------------------- 00174 // Set Color Material 00175 GLfloat vAmbient[4] = { 0.2, 0.2, 0.2, 1.0 }; 00176 GLfloat vDiffuse[4] = { 0.8, 0.8, 0.8, 1.0 }; 00177 GLfloat vSpecular[4] = { 0.2, 0.2, 0.2, 1.0 }; 00178 GLfloat vEmission[4] = { 0.0, 0.0, 0.0, 1.0 }; 00179 GLfloat vShininess[1] = { 128 }; 00180 glMaterialfv( GL_FRONT, GL_AMBIENT, vAmbient ); 00181 glMaterialfv( GL_FRONT, GL_DIFFUSE, vDiffuse ); 00182 glMaterialfv( GL_FRONT, GL_SPECULAR, vSpecular ); 00183 glMaterialfv( GL_FRONT, GL_EMISSION, vEmission ); 00184 glMaterialfv( GL_FRONT, GL_SHININESS, vShininess ); 00185 //--------------------------------------- 00186 //glEnable( GL_COLOR_MATERIAL ); 00187 //glColor3f( 0.5, 0.5, 0.5 ); 00188 glEnable( GL_BLEND ); 00189 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 00190 //glActiveTexture( GL_TEXTURE0 ); 00191 glEnable( GL_TEXTURE_3D ); 00192 //glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 00193 //glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); 00194 glBindTexture( GL_TEXTURE_3D, m_gluiName3DTexture ); 00195 //glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); 00196 //glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); 00197 //glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); 00198 glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP ); 00199 glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP ); 00200 glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP ); 00201 //glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); 00202 //glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); 00203 glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 00204 glTexParameterf( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 00205 00206 Vector3<T> vAABBMinPt = GetBoundingAABBLowPoint(); 00207 Vector3<T> vAABBMaxPt = GetBoundingAABBHighPoint(); 00208 T scale = (vAABBMaxPt[0] - vAABBMinPt[0]) / 3; 00209 for ( int i = 0; i < 3; ++i ) { 00210 vAABBMaxPt[i] /= scale; 00211 vAABBMinPt[i] /= scale; 00212 } 00213 //----------------------------------------------------------- 00214 glBegin( GL_QUADS ); 00215 //----------------------------------------------------------- 00216 // DrawSliceStack_NegativeZ(); // back-to-front is from -z to +z 00217 //if ( iDrawDir == -3 ) { 00218 if ( true ) { 00219 int iSubdivision = 1; 00220 int iAxis = 2; 00221 T zValue = vAABBMinPt[iAxis]; 00222 T numberOfSlices = m_3dt_size[iAxis] * iSubdivision; 00223 T zStep = (vAABBMaxPt[iAxis] - vAABBMinPt[iAxis] ) / (numberOfSlices-1); 00224 T tValue = 0; 00225 T tStep = 1.0 / (numberOfSlices-1); 00226 for ( int i = 0; i < numberOfSlices; ++i ) 00227 { 00228 glTexCoord3f( 0, 0, tValue ); 00229 glNormal3f( 0, 0, 1 ); 00230 glVertex3f( vAABBMinPt[0], vAABBMinPt[1], zValue ); 00231 // 00232 glTexCoord3f( 1, 0, tValue ); 00233 glNormal3f( 0, 0, 1 ); 00234 glVertex3f( vAABBMaxPt[0], vAABBMinPt[1], zValue ); 00235 // 00236 glTexCoord3f( 1, 1, tValue ); 00237 glNormal3f( 0, 0, 1 ); 00238 glVertex3f( vAABBMaxPt[0], vAABBMaxPt[1], zValue ); 00239 // 00240 glTexCoord3f( 0, 1, tValue ); 00241 glNormal3f( 0, 0, 1 ); 00242 glVertex3f( vAABBMinPt[0], vAABBMaxPt[1], zValue ); 00243 // 00244 zValue += zStep; 00245 tValue += tStep; 00246 } 00247 } 00248 glEnd(); 00249 glBindTexture( GL_TEXTURE_3D, 0 ); 00250 //glutSolidTeapot( 1.0 ); 00251 } 00252 //--------------------------------------------------------------- 00253 }
| virtual void OpenGL3DModel< T >::DrawVertexNormals | ( | ) | [inline, virtual] |
| T OpenGL3DModel< T >::GetMaxHalfLength | ( | ) | const [inline, virtual] |
| void OpenGL3DModel< T >::Initialize | ( | ) | [inline, virtual] |
| bool OpenGL3DModel< T >::SetData | ( | int | sizeX, | |
| int | sizeY, | |||
| int | sizeZ, | |||
| unsigned char * | pr3DRawData | |||
| ) | [inline] |
Definition at line 66 of file TAPsOpenGL3DModel.cpp.
00067 { 00068 //--------------------------------------------------------------- 00069 // Delete The 3D Texture 00070 if ( m_gluiName3DTexture > 0 ) { 00071 glDeleteTextures( 1, &m_gluiName3DTexture ); 00072 m_gluiName3DTexture = 0; 00073 } 00074 //------------- 00075 m_3dt_target = GL_TEXTURE_3D; 00076 m_3dt_level = 0; 00077 //m_3dt_internalFormat = GL_RGBA32F_ARB; 00078 m_3dt_internalFormat = GL_RGBA; 00079 //------------- 00080 m_3dt_size[0] = sizeX; 00081 m_3dt_size[1] = sizeY; 00082 m_3dt_size[2] = sizeZ; 00083 //------------- 00084 m_3dt_border = 0; 00085 m_3dt_pixelFormat = GL_RGBA; 00086 m_3dt_dataType = GL_UNSIGNED_BYTE; 00087 //m_3dt_dataType = GL_FLOAT; 00088 //----------------------------------------------------- 00089 int totalSize = sizeX*sizeY*sizeZ; 00090 //----------------------------------------------------- 00091 // Set bounding size 00092 // Min Point 00093 for ( int i = 0; i < 3; ++i ) { 00094 double half = m_3dt_size[i] / 2.0; 00095 m_paBoundingAABB[0][i] = -half; // Min Pt 00096 m_paBoundingAABB[1][i] = half; // Max Pt 00097 } 00098 //----------------------------------------------------- 00099 GLubyte * data = new GLubyte[ totalSize * 4 ]; 00100 //GLfloat * data = new GLfloat[ totalSize * 4 ]; 00101 00102 // DEBUG 00103 //for ( int i = 0; i < totalSize * 4; ++i ) { 00104 // data[i] = 0; 00105 //} 00106 00107 int count = 0; 00108 unsigned char minThreshold = 50; // 0 --> min 00109 unsigned char maxThreshold = 200; // 255 --> max 00110 for ( int i = 0; i < totalSize; ++i ) { 00111 if ( minThreshold <= pr3DRawData[i] && pr3DRawData[i] <= maxThreshold ) { 00112 data[count++] = 135; 00113 data[count++] = 135; 00114 data[count++] = 145; 00115 data[count++] = pr3DRawData[i]; 00116 } 00117 else { 00118 data[count++] = 0; 00119 data[count++] = 0; 00120 data[count++] = 0; 00121 data[count++] = 0; 00122 } 00123 } 00124 //----------------------------------------------------- 00125 glGenTextures( 1, &m_gluiName3DTexture ); 00126 glBindTexture( m_3dt_target, m_gluiName3DTexture ); 00127 //------------------------------------------- 00128 glTexImage3D( 00129 m_3dt_target, // target 00130 m_3dt_level, // level 00131 m_3dt_internalFormat, // internal format 00132 //GL_FLOAT_RGBA32_NV, // internal format (doesn't work!) 00133 //GL_RGBA_FLOAT32_ATI, // internal format (doesn't work!) 00134 m_3dt_size[0], // width 00135 m_3dt_size[1], // height 00136 m_3dt_size[2], // depth 00137 m_3dt_border, // border 00138 m_3dt_pixelFormat, // pixel format 00139 m_3dt_dataType, // data type 00140 data // texels 00141 ); 00142 //------------------------------------------- 00143 glBindTexture( m_3dt_target, 0 ); 00144 TAPs::OpenGL::Fn::CHECK_GL_ERROR(); 00145 //----------------------------------------------------- 00146 delete [] data; 00147 //----------------------------------------------------- 00148 #ifdef TAPS_OPENGL_3D_MODEL_DEBUG 00149 PrintDataInThe3DTexture(); 00150 #endif 00151 //----------------------------------------------------- 00152 return true; 00153 }
| virtual void OpenGL3DModel< T >::ToggleDisplayVertexNormals | ( | ) | [inline, virtual] |
GLint OpenGL3DModel< T >::m_3dt_border [private] |
Definition at line 66 of file TAPsOpenGL3DModel.hpp.
GLenum OpenGL3DModel< T >::m_3dt_dataType [private] |
Definition at line 68 of file TAPsOpenGL3DModel.hpp.
GLint OpenGL3DModel< T >::m_3dt_internalFormat [private] |
Definition at line 64 of file TAPsOpenGL3DModel.hpp.
GLint OpenGL3DModel< T >::m_3dt_level [private] |
Definition at line 63 of file TAPsOpenGL3DModel.hpp.
GLenum OpenGL3DModel< T >::m_3dt_pixelFormat [private] |
Definition at line 67 of file TAPsOpenGL3DModel.hpp.
GLint OpenGL3DModel< T >::m_3dt_size[3] [private] |
Definition at line 65 of file TAPsOpenGL3DModel.hpp.
GLenum OpenGL3DModel< T >::m_3dt_target [private] |
Definition at line 62 of file TAPsOpenGL3DModel.hpp.
GLuint OpenGL3DModel< T >::m_gluiName3DTexture [private] |
Definition at line 51 of file TAPsOpenGL3DModel.hpp.
1.5.6