diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-08 23:16:40 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-08 23:16:40 +0400 |
commit | 64e4a3ec9aed6c8abe095e2cd1fe1552f7cde51c (patch) | |
tree | 6c77358bd447b6c2d215324ef48fc12d1f5ae5ca /source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h | |
parent | cf2e1e2857cfc5b3c2848c7fc6c9d919ac72fabb (diff) | |
parent | 106974a9d2d5caa5188322507980e3d57d2e3517 (diff) |
soc-2008-mxcurioni: merged changes to revision 14747, cosmetic changes for source/blender/freestyle
Diffstat (limited to 'source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h')
-rwxr-xr-x | source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h new file mode 100755 index 00000000000..fe033f2ea0b --- /dev/null +++ b/source/blender/freestyle/intern/winged_edge/WingedEdgeBuilder.h @@ -0,0 +1,160 @@ +// +// Filename : WingedEdgeBuilder.h +// Author(s) : Stephane Grabli +// Purpose : Class to render a WingedEdge data structure +// from a polyhedral data structure organized in +// nodes of a scene graph +// Date of creation : 28/05/03 +// +/////////////////////////////////////////////////////////////////////////////// + + +// +// Copyright (C) : Please refer to the COPYRIGHT file distributed +// with this source distribution. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef WINGED_EDGE_BUILDER_H +# define WINGED_EDGE_BUILDER_H + +# include "../system/FreestyleConfig.h" +# include "../scene_graph/SceneVisitor.h" +# include "WEdge.h" +# include "../scene_graph/IndexedFaceSet.h" +# include "../scene_graph/NodeTransform.h" + +class LIB_WINGED_EDGE_EXPORT WingedEdgeBuilder : public SceneVisitor +{ + public: + + inline WingedEdgeBuilder() : SceneVisitor() { + _current_wshape = NULL; + _current_material = NULL; + _current_matrix = NULL; + _winged_edge = new WingedEdge; // Not deleted by the destructor + } + + virtual ~WingedEdgeBuilder() { + for (vector<Matrix44r*>::iterator it = _matrices_stack.begin(); + it != _matrices_stack.end(); + it++) + delete *it; + _matrices_stack.clear(); + } + + VISIT_DECL(IndexedFaceSet) + VISIT_DECL(NodeShape) + VISIT_DECL(NodeTransform) + + virtual void visitNodeTransformAfter(NodeTransform&); + + // + // Accessors + // + ///////////////////////////////////////////////////////////////////////////// + + inline WingedEdge* getWingedEdge() { + return _winged_edge; + } + + inline WShape* getCurrentWShape() { + return _current_wshape; + } + + inline Material* getCurrentMaterial() { + return _current_material; + } + + inline Matrix44r* getCurrentMatrix() { + return _current_matrix; + } + + // + // Modifiers + // + ///////////////////////////////////////////////////////////////////////////// + + inline void setCurrentWShape(WShape* wshape) { + _current_wshape = wshape; + } + + inline void setCurrentMaterial(Material* mat) { + _current_material = mat; + } + + // inline void setCurrentMatrix(Matrix44r* matrix) { + // _current_matrix = matrix; + // } + + protected: + + virtual void buildWShape(WShape& shape, IndexedFaceSet& ifs); + virtual void buildWVertices(WShape& shape, + const real *vertices, + unsigned vsize); + + private: + + void buildTriangleStrip(const real *vertices, + const real *normals, + vector<Material>& iMaterials, + const real *texCoords, + const unsigned *vindices, + const unsigned *nindices, + const unsigned *mindices, + const unsigned *tindices, + const unsigned nvertices); + + void buildTriangleFan(const real *vertices, + const real *normals, + vector<Material>& iMaterials, + const real *texCoords, + const unsigned *vindices, + const unsigned *nindices, + const unsigned *mindices, + const unsigned *tindices, + const unsigned nvertices); + + void buildTriangles(const real *vertices, + const real *normals, + vector<Material>& iMaterials, + const real *texCoords, + const unsigned *vindices, + const unsigned *nindices, + const unsigned *mindices, + const unsigned *tindices, + const unsigned nvertices); + + void transformVertices(const real *vertices, + unsigned vsize, + const Matrix44r& transform, + real *res); + + void transformNormals(const real *normals, + unsigned nsize, + const Matrix44r& transform, + real *res); + + WShape* _current_wshape; + Material* _current_material; + WingedEdge* _winged_edge; + Matrix44r* _current_matrix; + vector<Matrix44r*> _matrices_stack; +}; + +#endif // WINGED_EDGE_BUILDER_H |