H3D API  2.4.1
TriangleStripSet.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __TRIANGLESTRIPSET_H__
30 #define __TRIANGLESTRIPSET_H__
31 
34 #include <H3D/X3DCoordinateNode.h>
35 #include <H3D/X3DColorNode.h>
36 #include <H3D/CoordBoundField.h>
37 #include <H3D/MFInt32.h>
38 
39 namespace H3D {
40 
73  class H3DAPI_API TriangleStripSet : public X3DComposedGeometryNode {
74  public:
75 
79 
83 
86 
89 
96 
97  class H3DAPI_API AutoNormal:
98  public TypedField< SFNormalNode,
99  Types< SFBool, SFCoordinateNode, MFInt32, SFBool > > {
102  virtual void update();
103 
120  virtual X3DNormalNode *generateNormalsPerVertex(
121  X3DCoordinateNode *_coord,
122  const vector< int > &index,
123  bool _ccw );
124 
125 
142  virtual X3DNormalNode *generateNormalsPerFace(
143  X3DCoordinateNode *_coord,
144  const vector< int > &index,
145  bool _ccw );
146 
147  };
148 
150  TriangleStripSet( Inst< SFNode > _metadata = 0,
151  Inst< SFBound > _bound = 0,
152  Inst< DisplayList > _displayList = 0,
153  Inst< SFColorNode > _color = 0,
154  Inst< SFCoordinateNode > _coord = 0,
155  Inst< SFNormalNode > _normal = 0,
156  Inst< SFTextureCoordinateNode > _texCoord = 0,
157  Inst< SFBool > _ccw = 0,
158  Inst< SFBool > _colorPerVertex = 0,
159  Inst< SFBool > _normalPerVertex = 0,
160  Inst< SFBool > _solid = 0,
161  Inst< MFVertexAttributeNode > _attrib = 0,
162  Inst< AutoNormal > _autoNormal = 0,
163  Inst< MFInt32 > _stripCount = 0,
164  Inst< SFFogCoordinate > _fogCoord = 0 );
165 
166  // Traverse the scenegraph. See X3DGeometryNode::traverseSG
167  // for more info.
168  virtual void traverseSG( TraverseInfo &ti );
169 
171  virtual void render();
172 
174  virtual int nrTriangles() {
175  X3DCoordinateNode *coord_node = coord->getValue();
176  if( coord_node )
177  return coord_node->nrAvailableCoords();
178  else return 0;
179  }
180 
185  H3DUniquePtr< AutoNormal > autoNormal;
186 
196  H3DUniquePtr< MFInt32 > stripCount;
197 
200  };
201 }
202 
203 #endif
Header file for CoordBoundField, specialiced field class.
Contains the DependentSFNode and DependentMFNode template classes.
Contains the MFInt32 field class.
Header file for X3DColorNode, X3D scene-graph node.
Header file for X3DComposedGeometryNode, X3D scene-graph node.
Header file for X3DCoordinateNode, X3D scene-graph node.
The CoordBoundField is specialized update itself from a X3DCoordinateNode.
Definition: CoordBoundField.h:43
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
Specialized field for automatically generating normals from coordinates.
Definition: TriangleStripSet.h:99
Thrown when stripCount value is < 3.
Definition: TriangleStripSet.h:85
Thrown if the number of colors in the color field is less than the number coordinates in the coord fi...
Definition: TriangleStripSet.h:78
Thrown if the number of texture coordinates in the color field is less than the number coordinates in...
Definition: TriangleStripSet.h:82
A TriangleStripSet represents a 3D shape composed of strips of triangles.
Definition: TriangleStripSet.h:73
virtual int nrTriangles()
An upper bound of the number of triangles renderered in this geometry.
Definition: TriangleStripSet.h:174
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: TriangleStripSet.h:199
H3DUniquePtr< AutoNormal > autoNormal
Auto-generated normals that are used if the normal field is NULL.
Definition: TriangleStripSet.h:185
CoordBoundField SFBound
The bound field for TriangleStripSet is a CoordBoundField.
Definition: TriangleStripSet.h:88
H3DUniquePtr< MFInt32 > stripCount
The stripCount field describes how many vertices are to be used in each strip from the coordinate fie...
Definition: TriangleStripSet.h:196
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
This is the base node type for all composed 3D geometry in X3D.
Definition: X3DComposedGeometryNode.h:93
This is the base node type for all coordinate node types in X3D.
Definition: X3DCoordinateNode.h:47
virtual unsigned int nrAvailableCoords()=0
Returns the number of coordinates this coordinate node can render.
This is the base node type for all normal node types in X3D.
Definition: X3DNormalNode.h:45
H3D_VALUE_EXCEPTION(string, InvalidType)
An exception thrown when a field is of the wrong type when it is checked.
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194