Panda3D
 All Classes Functions Variables Enumerations
renderEffect.h
1 // Filename: renderEffect.h
2 // Created by: drose (14Mar02)
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 RENDEREFFECT_H
16 #define RENDEREFFECT_H
17 
18 #include "pandabase.h"
19 
20 #include "transformState.h"
21 #include "renderState.h"
22 
23 #include "typedWritableReferenceCount.h"
24 #include "pointerTo.h"
25 #include "pset.h"
26 #include "luse.h"
27 
28 class CullTraverser;
29 class CullTraverserData;
30 class PandaNode;
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : RenderEffect
34 // Description : This is the base class for a number of special render
35 // effects that may be set on scene graph nodes to
36 // change the way they render. This includes
37 // BillboardEffect, DecalEffect, etc.
38 //
39 // RenderEffect represents render properties that must
40 // be applied as soon as they are encountered in the
41 // scene graph, rather than propagating down to the
42 // leaves. This is different from RenderAttrib, which
43 // represents properties like color and texture that
44 // don't do anything until they propagate down to a
45 // GeomNode.
46 //
47 // You should not attempt to create or modify a
48 // RenderEffect directly; instead, use the make() method
49 // of the appropriate kind of effect you want. This
50 // will allocate and return a new RenderEffect of the
51 // appropriate type, and it may share pointers if
52 // possible. Do not modify the new RenderEffect if you
53 // wish to change its properties; instead, create a new
54 // one.
55 ////////////////////////////////////////////////////////////////////
56 class EXPCL_PANDA_PGRAPH RenderEffect : public TypedWritableReferenceCount {
57 protected:
58  RenderEffect();
59 private:
60  RenderEffect(const RenderEffect &copy);
61  void operator = (const RenderEffect &copy);
62 
63 public:
64  virtual ~RenderEffect();
65 
66  virtual bool safe_to_transform() const;
67  virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
68  virtual bool safe_to_combine() const;
69  virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const;
70 
71  virtual bool has_cull_callback() const;
72  virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
73  CPT(TransformState) &node_transform,
74  CPT(RenderState) &node_state) const;
75 
76  virtual bool has_adjust_transform() const;
77  virtual void adjust_transform(CPT(TransformState) &net_transform,
78  CPT(TransformState) &node_transform,
79  PandaNode *node) const;
80 
81 PUBLISHED:
82  INLINE int compare_to(const RenderEffect &other) const;
83 
84  virtual void output(ostream &out) const;
85  virtual void write(ostream &out, int indent_level) const;
86 
87  static int get_num_effects();
88  static void list_effects(ostream &out);
89  static bool validate_effects();
90 
91 protected:
92  static CPT(RenderEffect) return_new(RenderEffect *effect);
93 
94  virtual int compare_to_impl(const RenderEffect *other) const;
95 
96 private:
98  static Effects *_effects;
99 
100  Effects::iterator _saved_entry;
101 
102 public:
103  virtual void write_datagram(BamWriter *manager, Datagram &dg);
104  static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
105  virtual void finalize(BamReader *manager);
106 
107 protected:
108  static TypedWritable *new_from_bam(RenderEffect *effect, BamReader *manager);
109  void fillin(DatagramIterator &scan, BamReader *manager);
110 
111 public:
112  static TypeHandle get_class_type() {
113  return _type_handle;
114  }
115  static void init_type() {
116  TypedWritableReferenceCount::init_type();
117  register_type(_type_handle, "RenderEffect",
118  TypedWritableReferenceCount::get_class_type());
119  }
120  virtual TypeHandle get_type() const {
121  return get_class_type();
122  }
123  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
124 
125 private:
126  static TypeHandle _type_handle;
127 };
128 
129 INLINE ostream &operator << (ostream &out, const RenderEffect &effect) {
130  effect.output(out);
131  return out;
132 }
133 
134 #include "renderEffect.I"
135 
136 #endif
137 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
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
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
This is our own Panda specialization on the default STL set.
Definition: pset.h:52
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48