Panda3D
decalEffect.cxx
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 decalEffect.cxx
10  * @author drose
11  * @date 2002-03-14
12  */
13 
14 #include "decalEffect.h"
15 #include "bamReader.h"
16 #include "bamWriter.h"
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 
20 TypeHandle DecalEffect::_type_handle;
21 
22 /**
23  * Constructs a new DecalEffect object.
24  */
25 CPT(RenderEffect) DecalEffect::
26 make() {
27  DecalEffect *effect = new DecalEffect;
28  return return_new(effect);
29 }
30 
31 /**
32  * Returns true if this kind of effect can safely be combined with sibling
33  * nodes that share the exact same effect, or false if this is not a good
34  * idea.
35  */
36 bool DecalEffect::
37 safe_to_combine() const {
38  return false;
39 }
40 
41 /**
42  * Intended to be overridden by derived DecalEffect types to return a unique
43  * number indicating whether this DecalEffect is equivalent to the other one.
44  *
45  * This should return 0 if the two DecalEffect objects are equivalent, a
46  * number less than zero if this one should be sorted before the other one,
47  * and a number greater than zero otherwise.
48  *
49  * This will only be called with two DecalEffect objects whose get_type()
50  * functions return the same.
51  */
52 int DecalEffect::
53 compare_to_impl(const RenderEffect *other) const {
54  // All DecalEffects are equivalent--there are no properties to store.
55  return 0;
56 }
57 
58 /**
59  * Tells the BamReader how to create objects of type DecalEffect.
60  */
61 void DecalEffect::
63  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
64 }
65 
66 /**
67  * Writes the contents of this object to the datagram for shipping out to a
68  * Bam file.
69  */
70 void DecalEffect::
72  RenderEffect::write_datagram(manager, dg);
73 }
74 
75 /**
76  * This function is called by the BamReader's factory when a new object of
77  * type DecalEffect is encountered in the Bam file. It should create the
78  * DecalEffect and extract its information from the file.
79  */
80 TypedWritable *DecalEffect::
81 make_from_bam(const FactoryParams &params) {
82  DecalEffect *effect = new DecalEffect;
83  DatagramIterator scan;
84  BamReader *manager;
85 
86  parse_params(params, scan, manager);
87  effect->fillin(scan, manager);
88 
89  return effect;
90 }
91 
92 /**
93  * This internal function is called by make_from_bam to read in all of the
94  * relevant data from the BamFile for the new DecalEffect.
95  */
96 void DecalEffect::
97 fillin(DatagramIterator &scan, BamReader *manager) {
98  RenderEffect::fillin(scan, manager);
99 }
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
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
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition: bamReader.I:275
CPT(RenderEffect) DecalEffect
Constructs a new DecalEffect object.
Definition: decalEffect.cxx:25
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: decalEffect.cxx:71
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:73
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static void register_with_read_factory()
Tells the BamReader how to create objects of type DecalEffect.
Definition: decalEffect.cxx:62
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
Applied to a GeomNode to indicate that the children of this GeomNode are coplanar and should be drawn...
Definition: decalEffect.h:27
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.