MeVisLab Toolbox Reference
SoCast.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 /*
4  *
5  _______________________________________________________________________
6  ____________ W W W . A W A K E I D E A S . C O M ______________
7  |
8  |
9  | Description:
10  | ...
11  |
12  | Author(s) : Felix Ritter
13  |
14  ____________ W W W . A W A K E I D E A S . C O M ______________
15  _______________________________________________________________________
16  */
17 
18 #ifndef _SoCast_H
19 #define _SoCast_H
20 
21 #include "SoShadowSystem.h"
23 
24 class SoGLRenderAction;
25 class SoGetBoundingBoxAction;
26 class SoState;
27 class SoColorPacker;
28 
30 
31 template <class Type>
32 inline Type SbDeg2Rad( Type val ) {
33  return (Type)(val * M_PI / 180.0);
34 }
35 template <class Type>
36 inline Type SbRad2Deg( Type val ) {
37  return (Type)(val * 180.0 / M_PI);
38 }
39 
40 // abstract node
41 class SOSHADOW_CLASS_SPEC SoCast : public SoSeparator
42 {
43  typedef SoSeparator inherited;
44 
45  SO_NODE_ABSTRACT_HEADER(SoCast);
46 
47  private:
48  SoColorPacker *_colorPacker;
49 
50  protected:
51  SbVec4f _curlightPos;
53 
54  protected:
56  SoCast();
57  virtual ~SoCast();
58 
60  SbPlane cameraToPlane(SoState *state, SbGroundplane &area);
61 
63  SbBox3f getPlaneBoundingBox(SoState *state, SbBool usePlaneElement= FALSE);
64 
70  virtual void normalRenderSetup(SoGLRenderAction *) {}
71 
77  virtual void castRenderSetup(SoGLRenderAction *);
78 
83  virtual SbMatrix getCastMatrix(SoState *);
84 
89  void adjustCurrentCameraClippingPlanes(SoState *state);
90 
91  public:
93  enum LightMode {
94  FREE,
96  CAMERA
97  };
98 
100  SoSFVec4f lightPos;
101 
103  SoSFEnum lightMode;
104 
106 
109  SoSFPlane projectionPlane;
110 
112 
115  SoSFFloat planeAngle;
116 
118  SoSFColor castColor;
119 
121  SoSFBool castRender;
122 
124 
127  const SbVec4f &getCurLightDir() const { return _curlightPos; }
128 
129  void animatePlaneAngleAssignment(float newAngle);
130 
131  SoEXTENDER public:
132  void getBoundingBox(SoGetBoundingBoxAction *action) override;
133 
134  void GLRenderBelowPath(SoGLRenderAction *action) override;
135  void GLRenderInPath(SoGLRenderAction *action) override;
136 
137  virtual void commonGLRender(SoGLRenderAction *action);
138 
142  const SbVec3f &getNearestPlaneVertex() { return _curPlaneArea[0]; }
143  const SbVec3f &getFarestPlaneVertex() { return _curPlaneArea[3]; }
144 
145  virtual const SbVec3f &getFarestSceneVertex() { return _curPlaneArea[3]; }
146 
147  SoINTERNAL public:
148  static void initClass();
149 };
150 
152 
153 #endif // SoCast
#define __MEVIS_IV_END_NAMESPACE
Definition: OIVConfig.h:40
#define __MEVIS_IV_BEGIN_NAMESPACE
Definition: OIVConfig.h:39
__MEVIS_IV_BEGIN_NAMESPACE Type SbDeg2Rad(Type val)
Definition: SoCast.h:32
Type SbRad2Deg(Type val)
Definition: SoCast.h:36
#define SOSHADOW_CLASS_SPEC
Define a class export specifier needed to make the class exportable in dll's.
Definition: SoCast.h:42
virtual SbMatrix getCastMatrix(SoState *)
SoCast()
Protected constructor.
SbBox3f getPlaneBoundingBox(SoState *state, SbBool usePlaneElement=FALSE)
Calculates bounding box for plane.
virtual const SbVec3f & getFarestSceneVertex()
Definition: SoCast.h:145
static void initClass()
SoSFEnum lightMode
... . Default is (FREE).
Definition: SoCast.h:103
SoSFBool castRender
Enable/disable cast render pass. Default is (TRUE).
Definition: SoCast.h:121
SbGroundplane _curPlaneArea
Definition: SoCast.h:52
SoSFVec4f lightPos
Direction of the light. Default is (-1,-1,-1,0).
Definition: SoCast.h:100
void GLRenderBelowPath(SoGLRenderAction *action) override
const SbVec3f & getNearestPlaneVertex()
Definition: SoCast.h:142
SoSFFloat planeAngle
Rotation around camera side vector. Default is (SbDeg2Rad<float>(40)).
Definition: SoCast.h:115
virtual void commonGLRender(SoGLRenderAction *action)
const SbVec4f & getCurLightDir() const
Return the vector used to setup the current cast matrix.
Definition: SoCast.h:127
void GLRenderInPath(SoGLRenderAction *action) override
const SbVec3f & getFarestPlaneVertex()
Definition: SoCast.h:143
virtual void castRenderSetup(SoGLRenderAction *)
SbVec4f _curlightPos
Definition: SoCast.h:51
SbPlane cameraToPlane(SoState *state, SbGroundplane &area)
Calculates plane and plane vertices from viewing state.
virtual void normalRenderSetup(SoGLRenderAction *)
Definition: SoCast.h:70
SoSFPlane projectionPlane
Plane to cast projected model onto. Default is ((0, 1, 0), 0).
Definition: SoCast.h:109
void getBoundingBox(SoGetBoundingBoxAction *action) override
SoSFColor castColor
Color used to draw projected shapes. Default is (0.65, 0.62, 0.51).
Definition: SoCast.h:118
void adjustCurrentCameraClippingPlanes(SoState *state)
virtual ~SoCast()
void animatePlaneAngleAssignment(float newAngle)
LightMode
How to cast regarding the light.
Definition: SoCast.h:93
@ FREE
The field "lightPos" is used.
Definition: SoCast.h:94
@ PLANE
Light is perpendicular to the shadow plane.
Definition: SoCast.h:95