H3D API  2.4.1
X3DCoordinateNode.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 __X3DCOORDINATENODE_H__
30 #define __X3DCOORDINATENODE_H__
31 
34 #include <H3D/SFBool.h>
35 
36 namespace H3D {
37 
45  class H3DAPI_API X3DCoordinateNode :
48  public:
49  // Iterator for X3DCoordinateNode, iterates through point field
50  // value of X3DCoordinateNode
52  X3DCoordinateNode( Inst< SFNode> _metadata = 0);
53 
54  // Gets the coordinate of a given index.
55  virtual Vec3f getCoord( int index ) = 0;
56 
59  virtual void render( int /*index*/ ) {}
60 
63  virtual void renderArray() {}
64 
66  virtual void disableArray() {}
67 
71  virtual string defaultXMLContainerField() {
72  return "coord";
73  }
74 
76  virtual unsigned int nrAvailableCoords() = 0;
77 
79  virtual void setAttributeData ( ){};
80 
82  virtual void renderVBO ( ){};
83 
85  virtual void disableVBO ( ){};
86 
87  class Iterator {
88  private:
89  X3DCoordinateNode *coord;
90  int index;
91 
92  public:
93  Iterator( X3DCoordinateNode* c ) : coord( c ) {
94  index = 0;
95  }
96 
97  Iterator() : coord( NULL ) {
98  index = -1;
99  }
100 
101  inline Vec3f operator*() {
102  return coord->getCoord( index );
103  }
104 
105  inline Iterator& operator++() {
106  if ( ++index == static_cast<int>(coord->nrAvailableCoords()) )
107  index = -1;
108  return *this;
109  }
110 
111  inline Iterator operator++( int ) {
112  Iterator temp = *this;
113  ++(*this);
114  return temp;
115  }
116 
117  inline bool operator==( const Iterator &i ) {
118  return this->index == i.index;
119  }
120 
121  inline bool operator!=( const Iterator &i ) {
122  return this->index != i.index;
123  }
124  };
125 
126  Iterator pointBegin() {
127  return Iterator( this );
128  }
129 
130  Iterator pointEnd() {
131  return Iterator();
132  }
133 
134  };
135 }
136 
137 #endif
Contains the GLVertexAttributeObject class.
Contains the SFBool field class.
Header file for X3DGeometricPropertyNode, X3D scene-graph node.
This abstract interface is inherited by all nodes that could be used as vertex attributes in a glsl s...
Definition: GLVertexAttributeObject.h:54
This is the base node type for all coordinate node types in X3D.
Definition: X3DCoordinateNode.h:47
virtual void disableArray()
Disable the array state enabled in renderArray().
Definition: X3DCoordinateNode.h:66
virtual void renderArray()
Perform the OpenGL commands to render all vertices as a vertex array.
Definition: X3DCoordinateNode.h:63
virtual void render(int)
Perform the OpenGL commands to render a vertex given the index of the vertex.
Definition: X3DCoordinateNode.h:59
virtual unsigned int nrAvailableCoords()=0
Returns the number of coordinates this coordinate node can render.
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: X3DCoordinateNode.h:71
virtual void disableVBO()
VBO disabling implementation.
Definition: X3DCoordinateNode.h:85
virtual void setAttributeData()
Implement the method to specify data and releated information.
Definition: X3DCoordinateNode.h:79
virtual void renderVBO()
VBO rendering implementation.
Definition: X3DCoordinateNode.h:82
This is the base node type for all geometric property node types defined in X3D.
Definition: X3DGeometricPropertyNode.h:43
DualQuaternion operator*(const DualQuaternion &q1, const DualQuaternion &q2)
bool operator==(const DualQuaternion &q1, const DualQuaternion &q2)
bool operator!=(const T &a, const U &b)
H3D API namespace.
Definition: Anchor.h:38