H3D API  2.4.1
ShadowSphere.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 commercia l license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __SHADOWSPHERE_H__
30 #define __SHADOWSPHERE_H__
31 
33 #include <H3D/DirectionalLight.h>
34 #include <H3D/PointLight.h>
35 #include <H3D/SFInt32.h>
36 
37 namespace H3D {
38 
53  class H3DAPI_API ShadowSphere : public H3DShadowObjectNode {
54  public:
55 
57  ShadowSphere( Inst< SFNode > _metadata = 0,
58  Inst< SFFloat > _radius = 0,
59  Inst< SFVec3f > _position = 0,
60  Inst< SFInt32 > _detailLevel = 0 );
61 
62  virtual void update();
63 
69  H3DUniquePtr< SFFloat > radius;
70 
76  H3DUniquePtr< SFVec3f > position;
77 
85  H3DUniquePtr< SFInt32 > detailLevel;
86 
89 
90  virtual void computeShadowVolumeInformationCPU( const LightDataStruct& light_data, Matrix4f accumulated_fwd, bool render_caps, std::vector< Vec4d >& coord );
91 
92  virtual void renderShadowGPU( const LightDataStruct& light_data, Matrix4f accumulated_fwd, bool render_caps );
93 
94  protected:
95 
96  void buildGeometryData( bool is_dir_light, int detail_level, H3DFloat radius, bool render_caps,
97  Vec3f light_dir, Vec3f light_pos, std::vector<Vec4d>& coord, Matrix4f local_to_global = Matrix4f(), bool coords_in_global = false );
98 
99  // copies of fields that are updated in traverse and are used in computation of shadow volumes
100  // these are thread safe copies
101  Matrix4f transform_matrix_ts;
102  bool is_enabled_ts;
103 
104  H3DFloat radius_ts;
105  H3DInt32 detail_level_ts;
106  Vec3f position_ts;
107 
108  void addConvexPolygon( const vector< H3DInt32 > polygon_indices,size_t start_i, size_t end_i, vector<int> &indices );
109 
110  void addTriangle( unsigned int a, unsigned int b, unsigned int c, vector<int> &indices );
111  };
112 }
113 #endif
Header file for DirectionalLight, X3D scene-graph node.
Header file for H3DShadowObjectNode.
Header file for PointLight, X3D scene-graph node.
Contains the SFInt32 field class.
The H3DShadowObjectNode is the base class for all shadow objects for use in the ShadowCaster node.
Definition: H3DShadowObjectNode.h:49
The ShadowSphere object specifies a sphere casting a shadow for use in the ShadowCaster node.
Definition: ShadowSphere.h:53
H3DUniquePtr< SFFloat > radius
The radius of the sphere.
Definition: ShadowSphere.h:69
H3DUniquePtr< SFVec3f > position
The position of the sphere.
Definition: ShadowSphere.h:76
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: ShadowSphere.h:88
H3DUniquePtr< SFInt32 > detailLevel
The detailLevel field specifies the nr of faces to use for the sides of the shadow cone/cylinder that...
Definition: ShadowSphere.h:85
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