OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * The Original Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: all of this file. |
| 22 * |
| 23 * Contributor(s): none yet. |
| 24 * |
| 25 * ***** END GPL LICENSE BLOCK ***** |
| 26 */ |
| 27 |
| 28 #ifndef __FREESTYLE_TRIANGLE_REP_H__ |
| 29 #define __FREESTYLE_TRIANGLE_REP_H__ |
| 30 |
| 31 /** \file blender/freestyle/intern/scene_graph/TriangleRep.h |
| 32 * \ingroup freestyle |
| 33 * \brief Class to define the represenation of a triangle |
| 34 * \author Stephane Grabli |
| 35 * \date 16/12/2002 |
| 36 */ |
| 37 |
| 38 //! inherits from class Rep· |
| 39 #include "Rep.h" |
| 40 |
| 41 /*! Base class for all lines objects */ |
| 42 class LIB_SCENE_GRAPH_EXPORT TriangleRep : public Rep |
| 43 { |
| 44 public: |
| 45 /*! Line description style */ |
| 46 enum TRIANGLE_STYLE { |
| 47 FILL, |
| 48 LINES, |
| 49 }; |
| 50 |
| 51 private: |
| 52 TRIANGLE_STYLE _Style; |
| 53 Vec3r _vertices[3]; |
| 54 Vec3r _colors[3]; |
| 55 |
| 56 public: |
| 57 inline TriangleRep() : Rep() |
| 58 { |
| 59 _Style = FILL; |
| 60 } |
| 61 |
| 62 /*! Builds a triangle from 3 vertices |
| 63 * v0 |
| 64 * first vertex |
| 65 * v1 |
| 66 * second vertex |
| 67 * v2 |
| 68 * third vertex |
| 69 */ |
| 70 inline TriangleRep(const Vec3r& v0, const Vec3r& v1, const Vec3r& v2) :
Rep() |
| 71 { |
| 72 _vertices[0] = v0; |
| 73 _vertices[1] = v1; |
| 74 _vertices[2] = v2; |
| 75 _Style = FILL; |
| 76 } |
| 77 |
| 78 inline TriangleRep(const Vec3r& v0, const Vec3r& c0, const Vec3r& v1, co
nst Vec3r& c1, |
| 79 const Vec3r& v2, const Vec3r& c2) |
| 80 : Rep() |
| 81 { |
| 82 _vertices[0] = v0; |
| 83 _vertices[1] = v1; |
| 84 _vertices[2] = v2; |
| 85 _colors[0] = c0; |
| 86 _colors[1] = c1; |
| 87 _colors[2] = c2; |
| 88 _Style = FILL; |
| 89 } |
| 90 |
| 91 virtual ~TriangleRep() {} |
| 92 |
| 93 /*! accessors */ |
| 94 inline const TRIANGLE_STYLE style() const |
| 95 { |
| 96 return _Style; |
| 97 } |
| 98 |
| 99 inline const Vec3r& vertex(int index) const |
| 100 { |
| 101 return _vertices[index]; |
| 102 } |
| 103 |
| 104 inline const Vec3r& color(int index) const |
| 105 { |
| 106 return _colors[index]; |
| 107 } |
| 108 |
| 109 /*! modifiers */ |
| 110 inline void setStyle(const TRIANGLE_STYLE iStyle) |
| 111 { |
| 112 _Style = iStyle; |
| 113 } |
| 114 |
| 115 inline void setVertex(int index, const Vec3r& iVertex) |
| 116 { |
| 117 _vertices[index] = iVertex; |
| 118 } |
| 119 |
| 120 inline void setColor(int index, const Vec3r& iColor) |
| 121 { |
| 122 _colors[index] = iColor; |
| 123 } |
| 124 |
| 125 inline void setVertices(const Vec3r& v0, const Vec3r& v1, const Vec3r& v
2) |
| 126 { |
| 127 _vertices[0] = v0; |
| 128 _vertices[1] = v1; |
| 129 _vertices[2] = v2; |
| 130 } |
| 131 |
| 132 inline void setColors(const Vec3r& c0, const Vec3r& c1, const Vec3r& c2) |
| 133 { |
| 134 _colors[0] = c0; |
| 135 _colors[1] = c1; |
| 136 _colors[2] = c2; |
| 137 } |
| 138 |
| 139 /*! Accept the corresponding visitor */ |
| 140 virtual void accept(SceneVisitor& v) |
| 141 { |
| 142 Rep::accept(v); |
| 143 v.visitTriangleRep(*this); |
| 144 } |
| 145 |
| 146 /*! Computes the triangle bounding box.*/ |
| 147 virtual void ComputeBBox(); |
| 148 }; |
| 149 |
| 150 #endif // __FREESTYLE_TRIANGLE_REP_H__ |
OLD | NEW |