H3D API  2.4.1
Extrusion.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 __EXTRUSION_H__
30 #define __EXTRUSION_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/SFInt32.h>
34 #include <H3D/SFFloat.h>
35 #include <H3D/MFRotation.h>
36 #include <H3D/MFVec2f.h>
38 #include <H3D/Normal.h>
39 
40 namespace H3D {
41 
55  class H3DAPI_API Extrusion : public X3DGeometryNode {
56  public:
57 
60  typedef DependentSFNode< Normal,
62  Field,
65 
71  class H3DAPI_API SFBound: public TypedField< X3DGeometryNode::SFBound,
72  Types< MFVec3f > >{
73  virtual void update();
74  };
75 
83  class H3DAPI_API VertexVector:
84  public TypedField< MFVec3f,
85  Types< MFVec2f,
86  MFRotation,
87  MFVec2f,
88  MFVec3f > > {
89  virtual void update();
90  };
91 #ifdef __BORLANDC__
92  friend class VertexVector;
93 #endif
94 
104  class H3DAPI_API AutoNormal:
105  public TypedField< SFNormalNode,
106  Types< VertexVector,
107  SFFloat,
108  SFBool,
109  SFBool > > {
110  virtual void update();
111 
115  virtual Normal *generateNormalsPerVertex(
116  const vector < Vec3f > &vertex_vector,
117  const vector < Vec2f > &cross_section,
118  vector < Vec3f > &yAxis,
119  bool ccw_value,
120  H3DInt32 nr_of_cross_section_points,
121  H3DInt32 spine_size,
122  bool closedSpine,
123  H3DFloat crease_angle,
124  bool begin_cap,
125  bool end_cap );
126 
131  virtual Normal *generateNormalsPerVertex(
132  const vector < Vec3f > &vertex_vector,
133  const vector < Vec2f > &cross_section,
134  vector < Vec3f > &yAxis,
135  bool ccw_value,
136  H3DInt32 nr_of_cross_section_points,
137  H3DInt32 spine_size,
138  bool closedSpine,
139  bool begin_cap,
140  bool end_cap );
141 
144  virtual Normal *generateNormalsPerFace(
145  const vector < Vec3f > &vertex_vector,
146  const vector < Vec2f > &cross_section,
147  vector < Vec3f > &yAxis,
148  bool ccw_value,
149  H3DInt32 nr_of_cross_section_points,
150  H3DInt32 spine_size,
151  bool closedCrossSection,
152  bool begin_cap,
153  bool end_cap );
154  };
155 
156 
158  virtual void render();
159 
161  virtual int nrTriangles() {
162  return( crossSection->size() * 2 +
163  crossSection->size() * spine->size() * 2 );
164  }
165 
166  // Traverse the scenegraph. See X3DGeometryNode::traverseSG
167  // for more info.
168  virtual void traverseSG( TraverseInfo &ti );
169 
171  Extrusion( Inst< SFNode > _metadata = 0,
172  Inst< SFBound > _bound = 0,
173  Inst< DisplayList > _displayList = 0,
174  Inst< SFBool > _beginCap = 0,
175  Inst< SFBool > _ccw = 0,
176  Inst< SFBool > _convex = 0,
177  Inst< SFFloat > _creaseAngle = 0,
178  Inst< MFVec2f > _crossSection = 0,
179  Inst< SFBool > _endCap = 0,
180  Inst< MFRotation > _orientation = 0,
181  Inst< MFVec2f > _scale = 0,
182  Inst< SFBool > _solid = 0,
183  Inst< MFVec3f > _spine = 0 );
184 
199  H3DUniquePtr< SFBool > beginCap;
200 
201 
219  H3DUniquePtr< SFBool > ccw;
220 
231  H3DUniquePtr< SFBool > convex;
232 
245  H3DUniquePtr< SFFloat > creaseAngle;
246 
256  H3DUniquePtr< MFVec2f > crossSection;
257 
272  H3DUniquePtr< SFBool > endCap;
273 
297  H3DUniquePtr< MFRotation > orientation;
298 
310  H3DUniquePtr< MFVec2f > scale;
311 
323  H3DUniquePtr< SFBool > solid;
324 
332  H3DUniquePtr< MFVec3f > spine;
333 
336  H3DUniquePtr< VertexVector > vertexVector;
337 
340  H3DUniquePtr< AutoNormal > autoNormal;
341 
344  protected:
345  // Texture coordinates for u, v direction of the body.
346  vector< H3DFloat > u_tex_coord;
347  vector< H3DFloat > v_tex_coord;
348  // Texture coordinates for the caps.
349  vector< Vec3f > caps_tex_coord;
350  };
351 }
352 
353 #endif
Contains the DependentSFNode and DependentMFNode template classes.
Contains the MFRotation field class.
Contains the MFVec2f field class.
Header file for Normal, X3D scene-graph node.
Contains the SFFloat field class.
Contains the SFInt32 field class.
Header file for X3DGeometryNode, X3D scene-graph node.
DependentSFNode are modified TypedSFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:294
Specialized field for automatically generating normals from coordinates.
Definition: Extrusion.h:109
SFBound is specialized update itself from the fields of the Extrusion.
Definition: Extrusion.h:72
Specialized field vertex coordinates from the fields affecting this, the resulting vertexVector will ...
Definition: Extrusion.h:88
The Extrusion node specifies geometric shapes based on a two dimensional cross-section extruded along...
Definition: Extrusion.h:55
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: Extrusion.h:343
H3DUniquePtr< SFBool > convex
The convex field indicates whether all polygons in the shape are convex (TRUE).
Definition: Extrusion.h:231
H3DUniquePtr< SFBool > ccw
The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-giv...
Definition: Extrusion.h:219
H3DUniquePtr< MFVec2f > crossSection
A 2D crossSection piecewise linear curve (described as a series of connected vertices).
Definition: Extrusion.h:256
H3DUniquePtr< MFVec3f > spine
A 3D spine piecewise linear curve (also described as a series of connected vertices).
Definition: Extrusion.h:332
H3DUniquePtr< SFBool > endCap
When the beginCap or endCap fields are specified as TRUE, planar cap surfaces will be generated regar...
Definition: Extrusion.h:272
H3DUniquePtr< SFFloat > creaseAngle
The creaseAngle field affects how default normals are generated.
Definition: Extrusion.h:245
H3DUniquePtr< SFBool > solid
The solid field determines whether one or both sides of each polygon shall be displayed.
Definition: Extrusion.h:323
H3DUniquePtr< AutoNormal > autoNormal
Auto-generated normals.
Definition: Extrusion.h:340
H3DUniquePtr< VertexVector > vertexVector
The vector of vertices constructing the extrusion-shape Only accessable in C++.
Definition: Extrusion.h:336
virtual int nrTriangles()
An upper bound on the number of triangles.
Definition: Extrusion.h:161
H3DUniquePtr< MFRotation > orientation
A list of 3D orientation parameters used to orient the crossSection.
Definition: Extrusion.h:297
H3DUniquePtr< SFBool > beginCap
When the beginCap or endCap fields are specified as TRUE, planar cap surfaces will be generated regar...
Definition: Extrusion.h:199
H3DUniquePtr< MFVec2f > scale
A list of 2D scale parameters used to scale the crossSection.
Definition: Extrusion.h:310
DependentSFNode< Normal, FieldRef< X3DGeometricPropertyNode, Field, &X3DNormalNode::propertyChanged > > SFNormalNode
The SFNormalNode is dependent on the propertyChanged field of the contained Normal.
Definition: Extrusion.h:64
Class used for specifying a field member of a node in a DependentSFNode or DependentMFNode specificat...
Definition: DependentNodeFields.h:48
The Field class.
Definition: Field.h:46
This node defines a set of 3D surface normal vectors to be used in the vector field of some geometry ...
Definition: Normal.h:57
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
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 geometric property node types defined in X3D.
Definition: X3DGeometricPropertyNode.h:43
H3DUniquePtr< Field > propertyChanged
Field that indicated whether the properties have changed.
Definition: X3DGeometricPropertyNode.h:53
This is the base node type for all geometry in X3D.
Definition: X3DGeometryNode.h:61
int H3DInt32
float H3DFloat
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