Commit 00754423 authored by Max Lyon's avatar Max Lyon
Browse files

Added (single) texture support for OpenVolumeMesh

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17042 383ad7c9-94d9-4d36-a494-682f7c89f535
parent eb111db2
......@@ -513,7 +513,11 @@ void TextureNode::enter(GLState& _state , const DrawModes::DrawMode& _drawmode)
DrawModes::SOLID_ENV_MAPPED |
DrawModes::SOLID_2DTEXTURED_FACE |
DrawModes::SOLID_2DTEXTURED_FACE_SHADED |
DrawModes::SOLID_SHADER))
DrawModes::SOLID_SHADER |
//OpenVolumeMesh DrawModes
DrawModes::getDrawMode("Faces (textured)") |
DrawModes::getDrawMode("Faces (textured and shaded)") ))
{
ACG::GLState::enable( GL_TEXTURE_2D );
......@@ -533,7 +537,7 @@ void TextureNode::enter(GLState& _state , const DrawModes::DrawMode& _drawmode)
if ( !textures_.empty() ) {
ACG::GLState::bindTexture( GL_TEXTURE_2D, textures_[activeTexture_].id );
}
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, tex_mode_ );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, tex_mode_ );
}
}
......@@ -548,7 +552,11 @@ void TextureNode::leave(GLState& /* _state */ , const DrawModes::DrawMode& _draw
DrawModes::SOLID_ENV_MAPPED |
DrawModes::SOLID_2DTEXTURED_FACE |
DrawModes::SOLID_2DTEXTURED_FACE_SHADED |
DrawModes::SOLID_SHADER))
DrawModes::SOLID_SHADER |
//OpenVolumeMesh DrawModes
DrawModes::getDrawMode("Faces (textured)") |
DrawModes::getDrawMode("Faces (textured and shaded)") ))
{
ACG::GLState::bindTexture( GL_TEXTURE_2D, 0 );
ACG::GLState::disable( GL_TEXTURE_2D );
......
......@@ -34,9 +34,9 @@
/*===========================================================================*\
* *
* $Revision: 13867 $ *
* $LastChangedBy: kremer $ *
* $Date: 2012-02-23 09:15:26 +0100 (Thu, 23 Feb 2012) $ *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
......@@ -53,6 +53,7 @@
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
#include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
#include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
/*! \class VolumeMeshBufferManager
* \brief This class creates buffers that can be used to render open volume meshs.
......@@ -114,8 +115,7 @@ public:
enum TexCoordMode
{
TCM_NONE,
TCM_VERTEX_1D,
TCM_VERTEX_2D
TCM_SINGLE_2D
};
class Plane {
......@@ -135,8 +135,9 @@ public:
};
VolumeMeshBufferManager(const VolumeMesh &mesh_, OpenVolumeMesh::StatusAttrib& statusAttrib_,
OpenVolumeMesh::ColorAttrib<ACG::Vec4f>& colorAttrib_,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_);
OpenVolumeMesh::ColorAttrib<ACG::Vec4f>& colorAttrib_,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_,
OpenVolumeMesh::TexCoordAttrib<ACG::Vec2f>& texcoordAttrib_);
virtual ~VolumeMeshBufferManager(){ free(); }
......@@ -156,6 +157,9 @@ public:
/// Returns the normal's offset within the buffer
unsigned char getNormalOffset() { return mNormalOffset; }
/// Returns the texcoord's offset within the buffer
unsigned char getTexCoordOffset() { return mTexCoordOffset; }
/// Returns a VertexDeclaration for the vertices stored in the buffer
const ACG::VertexDeclaration* getVertexDeclaration() { return &mVertexDeclaration; }
......@@ -180,6 +184,9 @@ public:
/// Invalidates normals
void invalidateNormals();
/// Invalidates texture coordinates
void invalidateTexCoords();
/// Deletes the buffers on the GPU
void free();
......@@ -198,7 +205,7 @@ public:
/// Disables colors
//void disableColors() { mColorMode = CM_NONE; }
void disableColors() { mColorMode = CM_NO_COLORS; }
/// Enables per cell colors
void enablePerCellColors() { mColorMode = CM_CELL; }
......@@ -271,6 +278,14 @@ public:
/// Enables vertex primitives that are drawn on the cells
void enableVertexOnCellPrimitives() { mPrimitiveMode = PM_VERTICES_ON_CELLS; }
/// Disables textures
void disableTextures() { mTexCoordMode = TCM_NONE; }
/// Enables textures
void enableTextureSingle() { mTexCoordMode = TCM_SINGLE_2D; }
/// Checks whether only selected primitives should be added to the buffer
bool selectionOnly() { return mSkipUnselected; }
......@@ -342,6 +357,9 @@ private:
/// Adds a normal to the buffer
void addNormalToBuffer(ACG::Vec3d _normal, unsigned char *_buffer, unsigned int _offset);
/// Adds a texture coordnate to the buffer
void addTexCoordToBuffer(ACG::Vec2f _texCoord, unsigned char* _buffer, unsigned int _offset);
/// Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer
void calculateVertexDeclaration();
......@@ -356,6 +374,9 @@ private:
/// Adds all colors to the buffer
void buildColorBuffer(unsigned char* _buffer);
/// Adds texture coordinates to the buffer
void buildTexCoordBuffer(unsigned char* _buffer);
/// Adds all picking colors to the buffer
void buildPickColorBuffer(ACG::GLState &_state, unsigned int _offset, unsigned char* _buffer);
......@@ -389,6 +410,9 @@ private:
/// Checks whether colors need to be rebuild
bool colorsNeedRebuild();
/// Checks whether texture coordinates need to be rebuild
bool texCoordsNeedRebuild();
/// Checks whether normals need to be rebuild
bool normalsNeedRebuild();
......@@ -399,6 +423,7 @@ private:
OpenVolumeMesh::StatusAttrib& mStatusAttrib;
OpenVolumeMesh::ColorAttrib<ACG::Vec4f>& mColorAttrib;
OpenVolumeMesh::NormalAttrib<VolumeMesh>& mNormalAttrib;
OpenVolumeMesh::TexCoordAttrib<ACG::Vec2f>& mTexcoordAttrib;
int mNumOfVertices;
int mCurrentNumOfVertices;
......@@ -419,6 +444,7 @@ private:
bool mGeometryChanged;
bool mNormalsChanged;
bool mColorsChanged;
bool mTexCoordsChanged;
//draw modes
VolumeMeshDrawModesContainer mDrawModes;
......@@ -455,14 +481,11 @@ private:
std::vector<bool> mCellInsideness;
bool mCellInsidenessValid;
bool mMultiTexturing;
TexCoordMode mTexCoordMode;
TexCoordMode mCurrentTexCoordMode;
unsigned char mTexCoordOffset;
unsigned char mCurrentTexCoordOffset;
};
//=============================================================================
......
......@@ -34,9 +34,9 @@
/*===========================================================================*\
* *
* $Revision: 13867 $ *
* $LastChangedBy: kremer $ *
* $Date: 2012-02-23 09:15:26 +0100 (Thu, 23 Feb 2012) $ *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
......@@ -46,17 +46,20 @@
template <class VolumeMesh>
VolumeMeshBufferManager<VolumeMesh>::VolumeMeshBufferManager(const VolumeMesh &mesh_, OpenVolumeMesh::StatusAttrib& statusAttrib_,
OpenVolumeMesh::ColorAttrib<ACG::Vec4f>& colorAttrib_,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_)
OpenVolumeMesh::ColorAttrib<ACG::Vec4f>& colorAttrib_,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_,
OpenVolumeMesh::TexCoordAttrib<ACG::Vec2f>& texcoordAttrib_)
:
mDefaultColor(ACG::Vec4f(0.0,0.0,0.0,1.0)),
mMesh(mesh_),
mStatusAttrib(statusAttrib_),
mColorAttrib(colorAttrib_),
mNormalAttrib(normalAttrib_),
mTexcoordAttrib(texcoordAttrib_),
mNumOfVertices(-1),
mCurrentNumOfVertices(-1),
mVertexSize(0),
mVertexDeclaration(),
mColorOffset(-1),
mNormalOffset(-1),
mScale(0.8),
......@@ -66,6 +69,7 @@ VolumeMeshBufferManager<VolumeMesh>::VolumeMeshBufferManager(const VolumeMesh &m
mGeometryChanged(true),
mNormalsChanged(true),
mColorsChanged(true),
mTexCoordsChanged(true),
mDrawModes(),
mPrimitiveMode(PM_NONE),
mNormalMode(NM_NONE),
......@@ -88,7 +92,6 @@ VolumeMeshBufferManager<VolumeMesh>::VolumeMeshBufferManager(const VolumeMesh &m
mCurrentColorOffset(0),
mCogsValid(false),
mCellInsidenessValid(),
mMultiTexturing(false),
mTexCoordMode(TCM_NONE),
mCurrentTexCoordMode(TCM_NONE),
mTexCoordOffset(0),
......@@ -215,6 +218,24 @@ void VolumeMeshBufferManager<VolumeMesh>::addNormalToBuffer(ACG::Vec3d _normal,
addFloatToBuffer(_normal[2], buffer);
}
/**
* @brief Adds a texture coordnate to the buffer
*
* This method should be called after the size of a vertex and the normal offset within a vertex
* was calculated using calculateVertexDeclaration()
*
* @param _texCoord The texture coordinate that should be inserted
* @param _buffer A pointer to the start of the buffer
* @param _offset The offset (in number of vertices) to the place the texture coordinate should inserted
*/
template <class VolumeMesh>
void VolumeMeshBufferManager<VolumeMesh>::addTexCoordToBuffer(ACG::Vec2f _texCoord, unsigned char* _buffer, unsigned int _offset)
{
unsigned char* buffer = _buffer + _offset*mVertexSize + mTexCoordOffset;
addFloatToBuffer(_texCoord[0], buffer);
addFloatToBuffer(_texCoord[1], buffer);
}
/**
* @brief Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer
......@@ -256,9 +277,7 @@ void VolumeMeshBufferManager<VolumeMesh>::calculateVertexDeclaration()
{
mTexCoordOffset = currentOffset;
unsigned char numOfCoords = 0;
if (mTexCoordMode == TCM_VERTEX_1D)
numOfCoords = 1;
else if (mTexCoordMode == TCM_VERTEX_2D)
if (mTexCoordMode == TCM_SINGLE_2D)
numOfCoords = 2;
mVertexDeclaration.addElement(GL_FLOAT, numOfCoords, ACG::VERTEX_USAGE_TEXCOORD, reinterpret_cast<GLuint*>(currentOffset));
currentOffset += numOfCoords * sizeof(float);
......@@ -323,13 +342,13 @@ void VolumeMeshBufferManager<VolumeMesh>::setOptionsFromDrawMode(ACG::SceneGraph
mDrawModes.halffacesColoredPerVertex | mDrawModes.edgesColoredPerEdge |
mDrawModes.verticesColored))
enablePerVertexColors();
/*else
disableColors();*/
else
disableColors();
//normals
if (_drawMode & (mDrawModes.cellsFlatShaded | mDrawModes.halffacesFlatShaded))
enablePerHalffaceNormals();
else if (_drawMode & (mDrawModes.facesFlatShaded))
else if (_drawMode & (mDrawModes.facesFlatShaded | mDrawModes.facesTexturedShaded))
enablePerFaceNormals();
else if (_drawMode & (mDrawModes.cellsSmoothShaded | mDrawModes.facesSmoothShaded | mDrawModes.halffacesSmoothShaded |
mDrawModes.cellsPhongShaded | mDrawModes.facesPhongShaded | mDrawModes.halffacesPhongShaded))
......@@ -352,6 +371,14 @@ void VolumeMeshBufferManager<VolumeMesh>::setOptionsFromDrawMode(ACG::SceneGraph
else
mSkipRegularEdges = true;
// textures
if (_drawMode & (mDrawModes.facesTextured | mDrawModes.facesTexturedShaded))
mTexCoordMode = TCM_SINGLE_2D;
else
mTexCoordMode = TCM_NONE;
// primiive mode
if (_drawMode & (mDrawModes.cellBasedDrawModes))
mPrimitiveMode = PM_CELLS;
else if (_drawMode & (mDrawModes.facesOnCells))
......@@ -374,6 +401,8 @@ void VolumeMeshBufferManager<VolumeMesh>::setOptionsFromDrawMode(ACG::SceneGraph
mPrimitiveMode = PM_VERTICES;
else
mPrimitiveMode = PM_NONE;
}
......@@ -969,6 +998,22 @@ bool VolumeMeshBufferManager<VolumeMesh>::colorsNeedRebuild()
(mShowIrregularOuterValence2Edges != mCurrentShowIrregularOuterValence2Edges);
}
/**
* @brief Checks whether texture coordinates need to be rebuild
*
* @return True iff colors need to be rebuild
*/
template <class VolumeMesh>
bool VolumeMeshBufferManager<VolumeMesh>::texCoordsNeedRebuild()
{
return (mTexCoordsChanged) ||
(mVertexSize != mCurrentVertexSize) ||
(mNumOfVertices != mCurrentNumOfVertices) ||
(mPrimitiveMode != mCurrentPrimitiveMode) ||
(mTexCoordOffset!= mCurrentTexCoordOffset)||
(mTexCoordMode != mTexCoordMode);
}
/**
* @brief Checks whether normals need to be rebuild
*
......@@ -1601,6 +1646,65 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe
}
/**
* @brief Adds texture coordinates to the buffer
*
* @param _buffer Pointer to the start of the buffer
*/
template <class VolumeMesh>
void VolumeMeshBufferManager<VolumeMesh>::buildTexCoordBuffer(unsigned char* _buffer)
{
unsigned int pos = 0;
if (mTexCoordMode == TCM_NONE)
return;
if (mPrimitiveMode == PM_FACES)
{
std::vector<ACG::Vec2f> texCoords;
OpenVolumeMesh::FaceIter f_begin(mMesh.faces_begin()), f_end(mMesh.faces_end());
for (OpenVolumeMesh::FaceIter f_it = f_begin; f_it != f_end; ++f_it)
{
if (mBoundaryOnly && !mMesh.is_boundary(*f_it)) continue;
if (!is_inside(*f_it)) continue;
texCoords.clear();
for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = mMesh.hfv_iter(mMesh.halfface_handle(*f_it,0)); hfv_it; ++hfv_it)
texCoords.push_back(mTexcoordAttrib[*hfv_it]);
for (unsigned int i = 0; i < (texCoords.size()-2); i++)
{
addTexCoordToBuffer(texCoords[0], _buffer, pos++);
addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
}
}
}
else if (mPrimitiveMode == PM_HALFFACES)
{
std::vector<ACG::Vec2f> texCoords;
OpenVolumeMesh::HalfFaceIter hf_begin(mMesh.halffaces_begin()), hf_end(mMesh.halffaces_end());
for (OpenVolumeMesh::HalfFaceIter hf_it = hf_begin; hf_it != hf_end; ++hf_it)
{
if (mBoundaryOnly && !mMesh.is_boundary(*hf_it)) continue;
if (!is_inside(*hf_it)) continue;
texCoords.clear();
for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = mMesh.hfv_iter(*hf_it); hfv_it; ++hfv_it)
texCoords.push_back(mTexcoordAttrib[*hfv_it]);
for (unsigned int i = 0; i < (texCoords.size()-2); i++)
{
addTexCoordToBuffer(texCoords[0], _buffer, pos++);
addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
}
}
}
}
/**
* @brief Adds all picking colors to the buffer
*
......@@ -1760,6 +1864,8 @@ GLuint VolumeMeshBufferManager<VolumeMesh>::getBuffer()
buildNormalBuffer(buffer);
if (colorsNeedRebuild())
buildColorBuffer(buffer);
if (texCoordsNeedRebuild())
buildTexCoordBuffer(buffer);
glUnmapBuffer(GL_ARRAY_BUFFER);
......@@ -1775,10 +1881,11 @@ GLuint VolumeMeshBufferManager<VolumeMesh>::getBuffer()
}
saveOptions();
mInvalidated = false;
mGeometryChanged = false;
mColorsChanged = false;
mNormalsChanged = false;
mInvalidated = false;
mGeometryChanged = false;
mColorsChanged = false;
mNormalsChanged = false;
mTexCoordsChanged = false;
}
......@@ -1843,9 +1950,10 @@ GLuint VolumeMeshBufferManager<VolumeMesh>::getPickBuffer(ACG::GLState &_state,
mCurrentPickOffset = _offset;
saveOptions();
mInvalidated = false;
mGeometryChanged = false;
mColorsChanged = false;
mInvalidated = false;
mGeometryChanged = false;
mColorsChanged = false;
mTexCoordsChanged = false;
}
......@@ -1873,6 +1981,7 @@ void VolumeMeshBufferManager<VolumeMesh>::invalidateGeometry()
mNumOfVertices = -1;
mGeometryChanged = true;
mColorsChanged = true;
mTexCoordsChanged = true;
mNormalsChanged = true;
mCogsValid = false;
mCellInsidenessValid = false;
......@@ -1898,6 +2007,16 @@ void VolumeMeshBufferManager<VolumeMesh>::invalidateNormals()
mNormalsChanged = true;
}
/**
* @brief Invalidates texture coordinates
*/
template <class VolumeMesh>
void VolumeMeshBufferManager<VolumeMesh>::invalidateTexCoords()
{
mInvalidated = true;
mTexCoordsChanged = true;
}
/**
* @brief Deletes the buffers on the GPU
*
......
......@@ -34,9 +34,9 @@
/*===========================================================================*\
* *
* $Revision: 13867 $ *
* $LastChangedBy: kremer $ *
* $Date: 2012-02-23 09:15:26 +0100 (Thu, 23 Feb 2012) $ *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
......@@ -68,6 +68,8 @@ public:
facesPhongShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (phong shaded)")),
facesColoredPerFace(ACG::SceneGraph::DrawModes::addDrawMode("Faces (colored per face)")),
facesColoredPerVertex(ACG::SceneGraph::DrawModes::addDrawMode("Faces (colored per vertex)")),
facesTextured(ACG::SceneGraph::DrawModes::addDrawMode("Faces (textured)")),
facesTexturedShaded(ACG::SceneGraph::DrawModes::addDrawMode("Faces (textured and shaded)")),
facesOnCells(ACG::SceneGraph::DrawModes::addDrawMode("Faces (on cells)")),
hiddenLineBackgroundFaces(ACG::SceneGraph::DrawModes::addDrawMode("Hidden line (background colored faces)")),
......@@ -95,7 +97,8 @@ public:
cellBasedDrawModes(cellsFlatShaded | cellsSmoothShaded | cellsPhongShaded | cellsColoredPerCell | cellsColoredPerFace
| cellsColoredPerHalfface | cellsColoredPerVertex | cellsTransparent),
faceBasedDrawModes(facesFlatShaded | facesSmoothShaded | facesPhongShaded | facesColoredPerFace | facesColoredPerVertex | hiddenLineBackgroundFaces),
faceBasedDrawModes(facesFlatShaded | facesSmoothShaded | facesPhongShaded | facesColoredPerFace |
facesColoredPerVertex | facesTextured | facesTexturedShaded | hiddenLineBackgroundFaces),
halffaceBasedDrawModes(halffacesFlatShaded | halffacesSmoothShaded | halffacesPhongShaded | halffacesColoredPerHalfface
| halffacesColoredPerVertex),
edgeBasedDrawModes(edgesWireframe | edgesHiddenLine | edgesColoredPerEdge | irregularInnerEdges | irregularOuterEdges | edgesOnCells),
......@@ -119,6 +122,8 @@ public:
ACG::SceneGraph::DrawModes::DrawMode facesPhongShaded;
ACG::SceneGraph::DrawModes::DrawMode facesColoredPerFace;
ACG::SceneGraph::DrawModes::DrawMode facesColoredPerVertex;
ACG::SceneGraph::DrawModes::DrawMode facesTextured;
ACG::SceneGraph::DrawModes::DrawMode facesTexturedShaded;
ACG::SceneGraph::DrawModes::DrawMode facesOnCells;
ACG::SceneGraph::DrawModes::DrawMode hiddenLineBackgroundFaces;
......@@ -183,6 +188,8 @@ public:
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerFace & _drawMode) return facesColoredPerFace;
if (facesColoredPerVertex & _drawMode) return facesColoredPerVertex;
if (facesTextured & _drawMode) return facesTextured;
if (facesTexturedShaded & _drawMode) return facesTexturedShaded;
if (halffacesFlatShaded & _drawMode) return halffacesFlatShaded;
if (halffacesSmoothShaded & _drawMode) return halffacesSmoothShaded;
......
......@@ -54,6 +54,7 @@
#include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
#include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
#include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
#include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
#include "VolumeMeshBufferManager.hh"
#include "VolumeMeshDrawModesContainer.hh"
......@@ -101,6 +102,7 @@ public:
OpenVolumeMesh::StatusAttrib& _statusAttrib,
OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
OpenVolumeMesh::TexCoordAttrib<Vec2f> &_texcoordAttrib,
const MaterialNode* _matNode, BaseNode* _parent = 0,
std::string _name = "<VolumeMeshNode>");
......@@ -157,6 +159,9 @@ public:
// Set whether to update the color in next render pass
void set_color_changed(bool _color_changed);
// Set whether to update the texture in next render pass
void set_texture_changed(bool _texture_changed);
// Set whether to update the selectopm in next render pass
void set_selection_changed(bool _selection_changed);
......@@ -227,6 +232,7 @@ private:
OpenVolumeMesh::StatusAttrib& statusAttrib_;
OpenVolumeMesh::ColorAttrib<Vec4f>& colorAttrib_;
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_;
OpenVolumeMesh::TexCoordAttrib<Vec2f>& texcoordAttrib_;
const MaterialNode* materialNode_;
......
......@@ -72,6 +72,7 @@ VolumeMeshNodeT<VolumeMeshT>::VolumeMeshNodeT(const VolumeMesh& _mesh,
OpenVolumeMesh::StatusAttrib& _statusAttrib,
OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
OpenVolumeMesh::TexCoordAttrib<Vec2f>& _texcoordAttrib,
const MaterialNode* _matNode, BaseNode* _parent,
std::string _name) :
BaseNode(_parent, _name),
......@@ -83,22 +84,23 @@ VolumeMeshNodeT<VolumeMeshT>::VolumeMeshNodeT(const VolumeMesh& _mesh,
statusAttrib_(_statusAttrib),
colorAttrib_(_colorAttrib),
normalAttrib_(_normalAttrib),
texcoordAttrib_(_texcoordAttrib),
materialNode_(_matNode),
cellsBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
facesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
edgesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
verticesBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
cellsBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
facesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
edgesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
verticesBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
cellSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
faceSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
edgeSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
vertexSelectionBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
cellSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
faceSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
edgeSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
vertexSelectionBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
cellPickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
facePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
edgePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
vertexPickBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib),
cellPickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
facePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
edgePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
vertexPickBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
drawModes_(),
lastDrawMode_ (DrawModes::NONE),
......@@ -170,6 +172,10 @@ DrawModes::DrawMode VolumeMeshNodeT<VolumeMeshT>::availableDrawModes() const {
result |= drawModes_.facesColoredPerVertex;
if (colorAttrib_.face_colors_available())
result |= drawModes_.facesColoredPerFace;
if (texcoordAttrib_.vertex_texcoords_available())
result |= drawModes_.facesTextured;
if (texcoordAttrib_.vertex_texcoords_available() && normalAttrib_.vertex_normals_available())
result |= drawModes_.facesTexturedShaded;
}
if (mesh_.n_halffaces() > 0)
......@@ -334,6 +340,35 @@ void VolumeMeshNodeT<VolumeMeshT>::drawFaces(GLState& _state, const DrawModes::D
GLState::disable(GL_LIGHTING);
GLState::shadeModel(GL_SMOOTH);
}
else if (_drawMode & (drawModes_.facesTexturedShaded) )
{
glClientActiveTexture(GL_TEXTURE0);
ACG::GLState::texcoordPointer(2, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getTexCoordOffset()));
ACG::GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
GLState::enable(GL_LIGHTING