H3D API  2.4.1
ClipPlane.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 __CLIPPLANE_H__
30 #define __CLIPPLANE_H__
31 
32 #include <H3D/X3DChildNode.h>
35 #include <H3D/SFVec4d.h>
36 #include <H3D/MFBool.h>
37 
38 namespace H3D {
39 
73  class H3DAPI_API ClipPlane :
74  public X3DChildNode,
75  public H3DDisplayListObject,
76  public H3DRenderStateObject {
77  public:
78 
80  ClipPlane( Inst< SFNode > _metadata = 0,
81  Inst< SFBool > _enabled = 0,
82  Inst< SFVec4d > _plane = 0,
83  Inst< SFBool > _clipHaptics = 0,
84  Inst< SFBool > _clipGraphics = 0,
85  Inst< MFBool > _clipHapticsDevice = 0 );
86 
88  virtual void enableGraphicsState();
89 
91  virtual void disableGraphicsState();
92 
97  virtual void enableHapticsState( TraverseInfo &ti );
98 
102  virtual void disableHapticsState( TraverseInfo &ti );
103 
105  // line which satisfies the inequation above ( the part of the line which
112  bool truncateLine( const Vec3f &from, const Vec3f &to,
113  Vec3f &result_from, Vec3f &result_to );
114 
115  static bool checkIfFreeClipPlaneIndex() {
116  if( max_nr_clip_planes == -1 )
117  glGetIntegerv( GL_MAX_CLIP_PLANES, &max_nr_clip_planes );
118  return nr_active_clip_planes < max_nr_clip_planes;
119  }
120 
127  H3DUniquePtr< SFBool > enabled;
128 
138  H3DUniquePtr< SFVec4d > plane;
139 
150  H3DUniquePtr< SFBool > clipHaptics;
151 
164  H3DUniquePtr< MFBool > clipHapticsDevice;
165 
173  H3DUniquePtr< SFBool > clipGraphics;
174 
177 
180  protected:
185  vector<bool> haptics_enabled;
188  static GLint max_nr_clip_planes;
189 
190 
191  };
192 }
193 
194 #endif
Header file for H3DDisplayListObject.
Header file for H3DRenderStateObject.
Contains the MFBool field class.
Contains the SFVec4d field class.
Header file for X3DChildNode, X3D scene-graph node.
This node defines a single plane equation that will be used to clip the geometry, i....
Definition: ClipPlane.h:76
H3DUniquePtr< SFBool > clipGraphics
Specifies if the clipping plane should clip the graphics if enabled.
Definition: ClipPlane.h:173
vector< bool > haptics_enabled
Was haptics enabled in the last call to enableHapticsState()?
Definition: ClipPlane.h:185
H3DUniquePtr< SFVec4d > plane
The plane equation that will be used to clip the geometry.
Definition: ClipPlane.h:138
H3DUniquePtr< MFBool > clipHapticsDevice
The clipHapticsDevice field provides per haptics device control for clipping.
Definition: ClipPlane.h:164
static GLint max_nr_clip_planes
The maximum number of clip planes the graphics hardware supports.
Definition: ClipPlane.h:188
static int nr_active_clip_planes
The number of clip planes that are currently rendered.
Definition: ClipPlane.h:179
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ClipPlane.h:176
H3DUniquePtr< SFBool > enabled
Specifies if the clipping plane should be enabled or not.
Definition: ClipPlane.h:127
H3DUniquePtr< SFBool > clipHaptics
Specifies if the clipping plane should clip the haptics if enabled, i.e.
Definition: ClipPlane.h:150
int plane_index
The index of the plane when rendered by OpenGL.
Definition: ClipPlane.h:183
This abstract interface class is the base class for all node types that wants to create an OpenGL dis...
Definition: H3DDisplayListObject.h:54
This abstract class is the base class for node types that want to change the rendering state temporar...
Definition: H3DRenderStateObject.h:45
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
This abstract node type indicates that the concrete nodes which are instantiated based on it may be u...
Definition: X3DChildNode.h:42
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