Panda3D
polylightEffect.h
1 // Filename: polylightEffect.h
2 // Created by: sshodhan (01Jun04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef POLYLIGHTEFFECT_H
16 #define POLYLIGHTEFFECT_H
17 
18 #include "pandabase.h"
19 
20 
21 #include "renderEffect.h"
22 #include "luse.h"
23 #include "nodePath.h"
24 #include "polylightNode.h"
25 #include "pmap.h"
26 #include "pnotify.h"
27 #include "sceneSetup.h"
28 
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : PolylightEffect
32 // Description : A PolylightEffect can be used on a node to define a
33 // LightGroup for that node. A LightGroup contains
34 // PolylightNodes which are essentially nodes that add
35 // color to the polygons of a model based on distance.
36 // PolylightNode is a cheap way to get lighting effects
37 // specially for night scenes
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_PGRAPH PolylightEffect : public RenderEffect {
40 PUBLISHED:
41  enum ContribType {
42  CT_proximal,
43  CT_all,
44  };
45 
47 
48 protected:
49  INLINE PolylightEffect();
50  INLINE PolylightEffect(const PolylightEffect &copy);
51 
52 PUBLISHED:
53  static CPT(RenderEffect) make();
54  static CPT(RenderEffect) make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center);
55  static CPT(RenderEffect) make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center, const LightGroup &lights);
56  CPT(RenderEffect) add_light(const NodePath &newlight) const;
57  CPT(RenderEffect) remove_light(const NodePath &newlight) const;
58  CPT(RenderEffect) set_weight(PN_stdfloat w) const;
59  CPT(RenderEffect) set_contrib(ContribType c) const;
60  CPT(RenderEffect) set_effect_center(const LPoint3 &ec) const;
61  INLINE PN_stdfloat get_weight() const;
62  INLINE ContribType get_contrib() const;
63  INLINE LPoint3 get_effect_center()const;
64 
65  bool has_light(const NodePath &light) const;
66 
67 public:
68  virtual bool has_cull_callback() const;
69  virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
70  CPT(TransformState) &node_transform,
71  CPT(RenderState) &node_state) const;
72 
73  CPT(RenderAttrib) do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const TransformState *node_transform) const;
74  //CPT(RenderAttrib) do_poly_light(const NodePath &root, const CullTraverserData *data, const TransformState *node_transform) const;
75 
76  virtual void output(ostream &out) const;
77 
78 private:
79  ContribType _contribution_type;
80  PN_stdfloat _weight;
81  LightGroup _lightgroup;
82  LPoint3 _effect_center;
83 
84 protected:
85  virtual int compare_to_impl(const RenderEffect *other) const;
86 
87 public:
88  static TypeHandle get_class_type() {
89  return _type_handle;
90  }
91  static void init_type() {
92  RenderEffect::init_type();
93  register_type(_type_handle, "PolylightEffect",
94  RenderEffect::get_class_type());
95  }
96  virtual TypeHandle get_type() const {
97  return get_class_type();
98  }
99  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
100 
101 private:
102  static TypeHandle _type_handle;
103 };
104 
105 #include "polylightEffect.I"
106 
107 ostream &operator << (ostream &out, PolylightEffect::ContribType ct);
108 
109 #endif
110 
111 
112 
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:56
A PolylightEffect can be used on a node to define a LightGroup for that node.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:35
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48