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