H3D API  2.4.1
ElevationGrid.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 __ELEVATIONGRID_H__
30 #define __ELEVATIONGRID_H__
31 
32 #include <H3D/X3DGeometryNode.h>
33 #include <H3D/X3DCoordinateNode.h>
35 #include <H3D/X3DColorNode.h>
36 #include <H3D/X3DNormalNode.h>
39 #include <H3D/SFInt32.h>
40 #include <H3D/SFFloat.h>
41 #include <H3D/FogCoordinate.h>
42 
43 namespace H3D {
44 
120  class H3DAPI_API ElevationGrid : public X3DGeometryNode {
121  public:
124  typedef DependentSFNode< X3DColorNode,
126  Field,
129 
134  Field,
137 
140  typedef DependentSFNode<
143  Field,
146 
149  typedef DependentMFNode<
152  Field,
155 
158  typedef DependentSFNode<
161  Field,
164 
181  class H3DAPI_API AutoNormal:
182  public TypedField< SFNormalNode,
183  Types< SFBool,
184  SFInt32,
185  SFInt32,
186  SFFloat,
187  SFFloat,
188  MFFloat,
189  SFBool,
190  SFFloat > > {
191  virtual void update();
192 
196  virtual X3DNormalNode *generateNormalsPerVertex(
197  H3DInt32 x_dim,
198  H3DInt32 z_dim,
199  H3DFloat x_spacing,
200  H3DFloat z_spacing,
201  const vector< H3DFloat > &height,
202  bool ccw,
203  H3DFloat crease_angle );
204 
209  virtual X3DNormalNode *generateNormalsPerVertex(
210  H3DInt32 x_dim,
211  H3DInt32 z_dim,
212  H3DFloat x_spacing,
213  H3DFloat z_spacing,
214  const vector< H3DFloat > &height,
215  bool ccw );
216 
219  virtual X3DNormalNode *generateNormalsPerFace(
220  H3DInt32 x_dim,
221  H3DInt32 z_dim,
222  H3DFloat x_spacing,
223  H3DFloat z_spacing,
224  const vector< H3DFloat > &height,
225  bool ccw );
226 
227  };
228 
238  class H3DAPI_API SFBound: public TypedField< X3DGeometryNode::SFBound,
239  Types< SFInt32, SFInt32,
240  SFFloat, SFFloat, MFFloat > >{
241  virtual void update();
242  };
243 
252  class H3DAPI_API DisplayList: public X3DGeometryNode::DisplayList {
253  protected:
255  virtual void callList( bool build_list );
256  };
257 
264  virtual void startTexGen( TextureCoordinateGenerator *tex_coord_gen );
265 
267  virtual void stopTexGen( TextureCoordinateGenerator *tex_coord_gen );
268 
270  virtual void render();
271 
273  virtual int nrTriangles() {
274  H3DInt32 x_dim = xDimension->getValue();
275  H3DInt32 z_dim = zDimension->getValue();
276  if( x_dim < 2 || z_dim < 2 ) return 0;
277  else return (x_dim - 1) * (z_dim - 1 ) * 2;
278  }
279 
280  // Traverse the scenegraph. See X3DGeometryNode::traverseSG
281  // for more info.
282  virtual void traverseSG( TraverseInfo &ti );
283 
285  ElevationGrid( Inst< SFNode > _metadata = 0,
286  Inst< SFBound > _bound = 0,
287  Inst< DisplayList > _displayList = 0,
288  Inst< SFColorNode > _color = 0,
289  Inst< SFNormalNode > _normal = 0,
290  Inst< SFTextureCoordinateNode > _texCoord = 0,
291  Inst< SFBool > _ccw = 0,
292  Inst< SFBool > _colorPerVertex = 0,
293  Inst< SFBool > _normalPerVertex = 0,
294  Inst< SFBool > _solid = 0,
295  Inst< MFVertexAttributeNode > _attrib = 0,
296  Inst< AutoNormal > _autoNormal = 0,
297  Inst< SFFloat > _creaseAngle = 0,
298  Inst< SFInt32 > _xDimension = 0,
299  Inst< SFInt32 > _zDimension = 0,
300  Inst< SFFloat > _xSpacing = 0,
301  Inst< SFFloat > _zSpacing = 0,
302  Inst< MFFloat > _height = 0,
303  Inst< SFFogCoordinate > _fogCoord = 0 );
304 
305  ~ElevationGrid();
306 
315  H3DUniquePtr< SFColorNode > color;
316 
327  H3DUniquePtr< SFNormalNode > normal;
328 
335  H3DUniquePtr< SFTextureCoordinateNode > texCoord;
336 
354  H3DUniquePtr< SFBool > ccw;
355 
363  H3DUniquePtr< SFBool > colorPerVertex;
364 
372  H3DUniquePtr< SFBool > normalPerVertex;
373 
385  H3DUniquePtr< SFBool > solid;
386 
394  H3DUniquePtr< MFVertexAttributeNode > attrib;
395 
408  H3DUniquePtr< SFFloat > creaseAngle;
409 
417  H3DUniquePtr< SFInt32 > xDimension;
418 
426  H3DUniquePtr< SFInt32 > zDimension;
427 
435  H3DUniquePtr< SFFloat > xSpacing;
436 
444  H3DUniquePtr< SFFloat > zSpacing;
445 
453  H3DUniquePtr< MFFloat > height;
454 
457  H3DUniquePtr< AutoNormal > autoNormal;
458 
465  H3DUniquePtr< SFFogCoordinate > fogCoord;
466 
467 
470  protected:
473  H3DUniquePtr< Field > vboFieldsUpToDate;
474  // The index for the vertex buffer object
475  GLuint *vbo_id;
476  };
477 }
478 
479 #endif
Contains the DependentSFNode and DependentMFNode template classes.
Header file for FogCoordinate.
Contains the SFFloat field class.
Contains the SFInt32 field class.
Header file for TextureCoordinateGenerator, X3D scene-graph node.
Header file for X3DColorNode, X3D scene-graph node.
Header file for X3DCoordinateNode, X3D scene-graph node.
Header file for X3DGeometryNode, X3D scene-graph node.
Header file for X3DNormalNode, X3D scene-graph node.
Header file for X3DVertexAttributeNode.
DependentMFNode are modified TypedMFNode fields where the field dirty status is dependent on fields i...
Definition: DependentNodeFields.h:336
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: ElevationGrid.h:190
Display list is extended in order to set front sidedness of triangles outside the display list.
Definition: ElevationGrid.h:252
SFBound is specialized update itself from the fields of the ElevationGrid.
Definition: ElevationGrid.h:240
The ElevationGrid node specifies a uniform rectangular grid of varying height in the Y=0 plane of the...
Definition: ElevationGrid.h:120
H3DUniquePtr< SFBool > ccw
The ccw field defines the ordering of the vertex coordinates of the geometry with respect to user-giv...
Definition: ElevationGrid.h:354
H3DUniquePtr< MFVertexAttributeNode > attrib
If the attrib field is not empty it shall contain a list of X3DVertexAttributeNode instances with per...
Definition: ElevationGrid.h:394
H3DUniquePtr< SFInt32 > xDimension
The number of elements in the grid height array in the x direction.
Definition: ElevationGrid.h:417
H3DUniquePtr< SFColorNode > color
Contains an X3DColorNode whose colors are applied to the ElevationGrid.
Definition: ElevationGrid.h:315
H3DUniquePtr< SFFloat > xSpacing
The distance between vertices in the x direction.
Definition: ElevationGrid.h:435
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ElevationGrid.h:469
H3DUniquePtr< MFFloat > height
The height field is an xDimension by zDimension array of scalar values representing the height above ...
Definition: ElevationGrid.h:453
DependentMFNode< X3DVertexAttributeNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DVertexAttributeNode::propertyChanged > > MFVertexAttributeNode
The MFVertexAttributeNode is dependent on the propertyChanged field of the contained X3DVertexAttribu...
Definition: ElevationGrid.h:154
H3DUniquePtr< AutoNormal > autoNormal
Auto-generated normals that are used if the normal field is NULL.
Definition: ElevationGrid.h:457
H3DUniquePtr< SFFloat > creaseAngle
The creaseAngle field affects how default normals are generated.
Definition: ElevationGrid.h:408
H3DUniquePtr< SFBool > solid
The solid field determines whether one or both sides of each polygon shall be displayed.
Definition: ElevationGrid.h:385
H3DUniquePtr< SFBool > normalPerVertex
If TRUE the normals in the normal field is applied per vertex, otherwise it is applied per face.
Definition: ElevationGrid.h:372
DependentSFNode< X3DColorNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DColorNode::propertyChanged > > SFColorNode
The SFColorNode is dependent on the propertyChanged field of the contained X3DColorNode.
Definition: ElevationGrid.h:128
H3DUniquePtr< SFNormalNode > normal
Contains an X3DNormalNode which colors are applied to the ElevationGrid.
Definition: ElevationGrid.h:327
H3DUniquePtr< SFInt32 > zDimension
The number of elements in the grid height array in the z direction.
Definition: ElevationGrid.h:426
H3DUniquePtr< SFFogCoordinate > fogCoord
If the fogCoord field is not empty, it shall contain a list of per-vertex depth values for calculatin...
Definition: ElevationGrid.h:465
H3DUniquePtr< SFBool > colorPerVertex
If TRUE the colors in the color field is applied per vertex, otherwise it is applied per face.
Definition: ElevationGrid.h:363
H3DUniquePtr< SFTextureCoordinateNode > texCoord
Contains an X3DTextureCoordinateNode which colors are applied to the ElevationGrid.
Definition: ElevationGrid.h:335
H3DUniquePtr< Field > vboFieldsUpToDate
Internal field used to know if vertex buffer object can be created.
Definition: ElevationGrid.h:473
virtual int nrTriangles()
The number of triangles renderered in this geometry.
Definition: ElevationGrid.h:273
DependentSFNode< X3DTextureCoordinateNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DTextureCoordinateNode::propertyChanged > > SFTextureCoordinateNode
The SFTextureCoordinteNode is dependent on the propertyChanged field of the contained X3DTextureCoord...
Definition: ElevationGrid.h:145
H3DUniquePtr< SFFloat > zSpacing
The distance between vertices in the z direction.
Definition: ElevationGrid.h:444
DependentSFNode< X3DNormalNode, FieldRef< X3DGeometricPropertyNode, Field, &X3DNormalNode::propertyChanged > > SFNormalNode
The SFNormalNode is dependent on the propertyChanged field of the contained X3DNormalNode.
Definition: ElevationGrid.h:136
DependentSFNode< FogCoordinate, FieldRef< X3DGeometricPropertyNode, Field, &FogCoordinate::propertyChanged > > SFFogCoordinate
The SFFogCoordinate is dependent on the propertyChanged field of the contained FogCoordinate.
Definition: ElevationGrid.h:163
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 explicit fog depths on a per-vertex basis.
Definition: FogCoordinate.h:65
TextureCoordinateGenerator supports the automatic generation of texture coodinates for geometric shap...
Definition: TextureCoordinateGenerator.h:92
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 color specifications in X3D.
Definition: X3DColorNode.h:44
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
Display list is extended in order to set front sidedness of triangles outside the display list.
Definition: X3DGeometryNode.h:76
This is the base node type for all geometry in X3D.
Definition: X3DGeometryNode.h:61
This is the base node type for all normal node types in X3D.
Definition: X3DNormalNode.h:45
This abstract node type is the base type for all node types which specify texture coordinates.
Definition: X3DTextureCoordinateNode.h:55
This abstract node type is the base type for all node types that specify per-vertex attribute informa...
Definition: X3DVertexAttributeNode.h:47
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