H3D API  2.4.1
H3DShadowObjectNode.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 __H3DSHADOWOBJECTNODE_H__
30 #define __H3DSHADOWOBJECTNODE_H__
31 
32 #include <H3D/X3DNode.h>
33 #include <H3D/X3DLightNode.h>
34 #include <H3D/MatrixTransform.h>
35 
36 namespace H3D {
37 
49  class H3DAPI_API H3DShadowObjectNode : public X3DNode {
50  public:
51 
52  // Struct to transfer light data in a thread safe manner
53  struct LightDataStruct {
54 
56  LightDataStruct( X3DLightNode* light );
57 
58  Vec3f getLightPosition() const { return light_pos; }
59  Vec3f getLightDirection() const { return light_dir; }
60  bool isDirectionalLight() const { return is_direction_light; }
61  bool isPointLight() const { return is_point_light; }
62 
63  protected:
64  Vec3f light_pos;
65  Vec3f light_dir;
66  bool is_direction_light;
67  bool is_point_light;
68  };
69 
71 
73  H3DShadowObjectNode( Inst< SFNode > _metadata = 0,
74  Inst< SFTransformNode > _transform = 0,
75  Inst< SFBool > _enabled = 0 );
76 
83  virtual void computeShadowVolumeInformationCPU( const LightDataStruct& light_data, Matrix4f accumulated_fwd, bool render_caps, std::vector< Vec4d >& coord ) = 0;
84 
87  virtual void update() {};
88 
93  virtual void renderShadowGPU( const LightDataStruct& light_data, Matrix4f accumulated_fwd, bool render_caps ) = 0;
97  virtual string defaultXMLContainerField() {
98  return "object";
99  }
100 
105  H3DUniquePtr< SFTransformNode > transform;
106 
111  H3DUniquePtr< SFBool > enabled;
112 
115  };
116 }
117 
118 #endif
Header file for MatrixTransform, X3D scene-graph node.
Header file for X3DLightNode, X3D scene-graph node.
Header file for X3DNode, X3D scene-graph node.
The H3DShadowObjectNode is the base class for all shadow objects for use in the ShadowCaster node.
Definition: H3DShadowObjectNode.h:49
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: H3DShadowObjectNode.h:97
H3DUniquePtr< SFTransformNode > transform
The transform field specifies a transformation of the shadow volume object.
Definition: H3DShadowObjectNode.h:105
virtual void computeShadowVolumeInformationCPU(const LightDataStruct &light_data, Matrix4f accumulated_fwd, bool render_caps, std::vector< Vec4d > &coord)=0
Override to compute the shadow volume information of this object for light used in shadow caster sing...
H3DUniquePtr< SFBool > enabled
Used to turn on/off shadow of this shadow object.
Definition: H3DShadowObjectNode.h:111
virtual void update()
Override to update data called in render
Definition: H3DShadowObjectNode.h:87
virtual void renderShadowGPU(const LightDataStruct &light_data, Matrix4f accumulated_fwd, bool render_caps)=0
Override to do implement shadows using a geometry shader.
static H3DNodeDatabase database
The H3DNodeDatabase for the node.
Definition: H3DShadowObjectNode.h:114
Template to make sure that the Node that is set in a SFNode is of a specified Node type.
Definition: SFNode.h:97
The X3DLightNode abstract node type is the base type from which all node types that serve as light so...
Definition: X3DLightNode.h:70
This abstract node type is the base type for all nodes in the X3D system.
Definition: X3DNode.h:65
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