Panda3D

Loading...
Searching...
No Matches
renderEffect.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 renderEffect.h
10 * @author drose
11 * @date 2002-03-14
12 */
13
14#ifndef RENDEREFFECT_H
15#define RENDEREFFECT_H
16
17#include "pandabase.h"
18
19#include "transformState.h"
20#include "renderState.h"
21
22#include "typedWritableReferenceCount.h"
23#include "pointerTo.h"
24#include "pset.h"
25#include "luse.h"
26
27 class CullTraverser;
28 class CullTraverserData;
29 class PandaNode;
30
31/**
32 * This is the base class for a number of special render effects that may be
33 * set on scene graph nodes to change the way they render. This includes
34 * BillboardEffect, DecalEffect, etc.
35 *
36 * RenderEffect represents render properties that must be applied as soon as
37 * they are encountered in the scene graph, rather than propagating down to
38 * the leaves. This is different from RenderAttrib, which represents
39 * properties like color and texture that don't do anything until they
40 * propagate down to a GeomNode.
41 *
42 * You should not attempt to create or modify a RenderEffect directly;
43 * instead, use the make() method of the appropriate kind of effect you want.
44 * This will allocate and return a new RenderEffect of the appropriate type,
45 * and it may share pointers if possible. Do not modify the new RenderEffect
46 * if you wish to change its properties; instead, create a new one.
47 */
48 class EXPCL_PANDA_PGRAPH RenderEffect : public TypedWritableReferenceCount {
49 protected:
50 RenderEffect();
51
52 public:
53 RenderEffect(const RenderEffect &copy) = delete;
54 virtual ~RenderEffect();
55
56 RenderEffect &operator = (const RenderEffect &copy) = delete;
57
58 virtual bool safe_to_transform() const;
59 virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
60 virtual bool safe_to_combine() const;
61 virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const;
62
63 virtual bool has_cull_callback() const;
64 virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
65 CPT(TransformState) &node_transform,
66 CPT(RenderState) &node_state) const;
67
68 virtual bool has_adjust_transform() const;
69 virtual void adjust_transform(CPT(TransformState) &net_transform,
70 CPT(TransformState) &node_transform,
71 const PandaNode *node) const;
72
73PUBLISHED:
74 INLINE int compare_to(const RenderEffect &other) const;
75
76 virtual void output(std::ostream &out) const;
77 virtual void write(std::ostream &out, int indent_level) const;
78
79 static int get_num_effects();
80 static void list_effects(std::ostream &out);
81 static bool validate_effects();
82
83 protected:
84 static CPT(RenderEffect) return_new(RenderEffect *effect);
85
86 virtual int compare_to_impl(const RenderEffect *other) const;
87
88 private:
89 typedef pset<const RenderEffect *, indirect_compare_to<const RenderEffect *> > Effects;
90 static Effects *_effects;
91
92 Effects::iterator _saved_entry;
93
94 public:
95 virtual void write_datagram(BamWriter *manager, Datagram &dg);
96 static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
97 virtual void finalize(BamReader *manager);
98
99 protected:
100 static TypedWritable *new_from_bam(RenderEffect *effect, BamReader *manager);
101 void fillin(DatagramIterator &scan, BamReader *manager);
102
103 public:
104 static TypeHandle get_class_type() {
105 return _type_handle;
106 }
107 static void init_type() {
108 TypedWritableReferenceCount::init_type();
109 register_type(_type_handle, "RenderEffect",
110 TypedWritableReferenceCount::get_class_type());
111 }
112 virtual TypeHandle get_type() const {
113 return get_class_type();
114 }
115 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
116
117 private:
118 static TypeHandle _type_handle;
119};
120
121INLINE std::ostream &operator << (std::ostream &out, const RenderEffect &effect) {
122 effect.output(out);
123 return out;
124}
125
126#include "renderEffect.I"
127
128#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
CullTraverserData
This collects together the pieces of data that are accumulated for each node while walking the scene ...
Definition cullTraverserData.h:40
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition cullTraverser.h:45
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
PandaNode
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
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
RenderEffect::safe_to_combine
virtual bool safe_to_combine() const
Returns true if this kind of effect can safely be combined with sibling nodes that share the exact sa...
Definition renderEffect.cxx:88
RenderEffect::list_effects
static void list_effects(std::ostream &out)
Lists all of the RenderEffects in the cache to the output stream, one per line.
Definition renderEffect.cxx:184
RenderEffect::get_num_effects
static int get_num_effects()
Returns the total number of unique RenderEffect objects allocated in the world.
Definition renderEffect.cxx:171
RenderEffect::xform
virtual ConstPointerTo< RenderEffect > xform(const LMatrix4 &mat) const
Returns a new RenderEffect transformed by the indicated matrix.
Definition renderEffect.cxx:96
RenderEffect::has_adjust_transform
virtual bool has_adjust_transform() const
Should be overridden by derived classes to return true if adjust_transform() has been defined,...
Definition renderEffect.cxx:133
RenderEffect::safe_to_transform
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
Definition renderEffect.cxx:68
RenderEffect::adjust_transform
virtual void adjust_transform(ConstPointerTo< TransformState > &net_transform, ConstPointerTo< TransformState > &node_transform, const PandaNode *node) const
Performs some operation on the node's apparent net and/or local transforms.
Definition renderEffect.cxx:146
RenderEffect::prepare_flatten_transform
virtual ConstPointerTo< TransformState > prepare_flatten_transform(const TransformState *net_transform) const
Preprocesses the accumulated transform that is about to be applied to (or through) this node due to a...
Definition renderEffect.cxx:78
RenderEffect::has_cull_callback
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
Definition renderEffect.cxx:106
RenderEffect::cull_callback
virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, ConstPointerTo< TransformState > &node_transform, ConstPointerTo< RenderState > &node_state) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
Definition renderEffect.cxx:123
RenderEffect::compare_to
int compare_to(const RenderEffect &other) const
Provides an arbitrary ordering among all unique RenderEffects, so we can store the essentially differ...
Definition renderEffect.I:23
RenderEffect::change_this
static TypedWritable * change_this(TypedWritable *old_ptr, BamReader *manager)
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointe...
Definition renderEffect.cxx:296
RenderEffect::validate_effects
static bool validate_effects()
Ensures that the cache is still stored in sorted order.
Definition renderEffect.cxx:199
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
TransformState
Indicates a coordinate-system transform on vertices.
Definition transformState.h:54
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::finalize
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
Definition typedWritable.cxx:113
TypedWritable::fillin
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
renderEffect.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
renderState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
transformState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.