/// This file is part of the X3DToolKit library /// Copyright (C) 2002-2004 Yannick Le Goc (legoc@imag.fr) /// http://artis.imag.fr/Members/Yannick.Legoc/X3D/ /// This library is free software; you can redistribute it and/or /// modify it under the terms of the GNU Lesser General Public /// License as published by the Free Software Foundation; either /// version 2.1 of the License, or (at your option) any later version. /// This library is distributed in the hope that it will be useful, /// but WITHOUT ANY WARRANTY; without even the implied warranty of /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// Lesser General Public License for more details. /// You should have received a copy of the GNU Lesser General Public /// License along with this library; if not, write to the Free Software /// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef X3DTK_GL_INDEXEDFACESET_H #define X3DTK_GL_INDEXEDFACESET_H #include "GL_X3DComposedGeometryNode.h" #include #include namespace X3DTK { namespace GL { /*! \brief Class declared in providing the GL implementation * of X3D::IndexedFaceSet. * * \ingroup GLSceneGraph */ class IndexedFaceSet : public X3DComposedGeometryNode { public: /// Constructor. IndexedFaceSet(); /// Destructor. virtual ~IndexedFaceSet(); /// Sets the N3F_V3F vertexArray. void setN3F_V3F_vertexArray(const std::vector &N3F_V3FvertexArray); /// Sets the C4F_N3F_V3F vertexArray. void setC4F_N3F_V3F_vertexArray(const std::vector &C4F_N3F_V3FvertexArray); /// Sets the T2F_N3F_V3F vertexArray. void setT2F_N3F_V3F_vertexArray(const std::vector &T2F_N3F_V3F_vertexArray); /// Sets the T2F_C4F_N3F_V3F vertexArray. void setT2F_C4F_N3F_V3F_vertexArray(const std::vector &T2F_C4F_N3F_V3F_vertexArray); /// Sets the indexFaceArray. void setIndexArray(const MFInt32 &indexArray); /// Gets the N3F_V3F vertexArray. inline std::vector &N3F_V3F_vertexArray() {return _N3F_V3F_vertexArray;}; /// Gets the C4F_N3F_V3F vertexArray. inline std::vector &C4F_N3F_V3F_vertexArray() {return _C4F_N3F_V3F_vertexArray;}; /// Gets the T2F_N3F_V3F vertexArray. inline std::vector &T2F_N3F_V3F_vertexArray() {return _T2F_N3F_V3F_vertexArray;}; /// Gets the T2F_C4F_N3F_V3F vertexArray. inline std::vector &T2F_C4F_N3F_V3F_vertexArray() {return _T2F_C4F_N3F_V3F_vertexArray;}; /// Gets the indexFaceArray. inline MFInt32 &indexArray() {return _indexArray;}; /// Gets the X3DToGLIndex. inline const std::vector &getX3DToGLIndex() const {return _X3DtoGLIndex;}; /// Computes the normals. virtual void computeNormals(); /// Updates the attributes of the node. virtual void update(); /// Renders the node in an openGL context. virtual void draw() const; private: /// N3F_V3F vertexArray. std::vector _N3F_V3F_vertexArray; /// C4F_N3F_V3F vertexArray. std::vector _C4F_N3F_V3F_vertexArray; /// T2F_N3F_V3F vertexArray. std::vector _T2F_N3F_V3F_vertexArray; /// T2F_C4F_N3F_V3F vertexArray. std::vector _T2F_C4F_N3F_V3F_vertexArray; /// indexFaceArray. MFInt32 _indexArray; /// Relation between X3D vertex array and GL vertex array. std::vector _X3DtoGLIndex; /// temporary list of index. std::list > _N3F_V3F_tesselatedFace; /// temporary list of index. std::list > _C4F_N3F_V3F_tesselatedFace; /// temporary list of index. std::list > _T2F_N3F_V3F_tesselatedFace; /// temporary list of index. std::list > _T2F_C4F_N3F_V3F_tesselatedFace; /// Empties the arrays. void emptyArrays(); /// Computes the vertex Array with no color and no texCoord. void computeNoColorNoTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Computes the vertex Array with color and no texCoord. void computeColorRGBANoTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Computes the vertex Array with color and no texCoord. void computeColorNoTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Computes the vertex Array with no color and texCoord. void computeNoColorTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Computes the vertex Array with color and texCoord. void computeColorRGBATexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Computes the vertex Array with color and texCoord. void computeColorTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray, const MFInt32 &coordIndex); /// Tesselate the face. void tesselateNoColorNoTexCoord(const std::list > &N3F_V3F_face); /// Tesselate the face. void tesselateColorNoTexCoord(const std::list > &C4F_N3F_V3F_face); /// Tesselate the face. void tesselateNoColorTexCoord(const std::list > &T2F_N3F_V3F_face); /// Tesselate the face. void tesselateColorTexCoord(const std::list > &T2F_C4F_N3F_V3F_face); /// Computes the normals. void computeNoColorNoTexCoordNormals(); /// Computes the normals. void computeColorNoTexCoordNormals(); /// Computes the normals. void computeNoColorTexCoordNormals(); /// Computes the normals. void computeColorTexCoordNormals(); }; } } #endif