Panda3D
 All Classes Functions Variables Enumerations
decalEffect.cxx
1 // Filename: decalEffect.cxx
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 #include "decalEffect.h"
16 #include "bamReader.h"
17 #include "bamWriter.h"
18 #include "datagram.h"
19 #include "datagramIterator.h"
20 
21 TypeHandle DecalEffect::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: DecalEffect::make
25 // Access: Published, Static
26 // Description: Constructs a new DecalEffect object.
27 ////////////////////////////////////////////////////////////////////
29 make() {
30  DecalEffect *effect = new DecalEffect;
31  return return_new(effect);
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: DecalEffect::safe_to_combine
36 // Access: Public, Virtual
37 // Description: Returns true if this kind of effect can safely be
38 // combined with sibling nodes that share the exact same
39 // effect, or false if this is not a good idea.
40 ////////////////////////////////////////////////////////////////////
41 bool DecalEffect::
42 safe_to_combine() const {
43  return false;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: DecalEffect::compare_to_impl
48 // Access: Protected, Virtual
49 // Description: Intended to be overridden by derived DecalEffect
50 // types to return a unique number indicating whether
51 // this DecalEffect is equivalent to the other one.
52 //
53 // This should return 0 if the two DecalEffect objects
54 // are equivalent, a number less than zero if this one
55 // should be sorted before the other one, and a number
56 // greater than zero otherwise.
57 //
58 // This will only be called with two DecalEffect
59 // objects whose get_type() functions return the same.
60 ////////////////////////////////////////////////////////////////////
61 int DecalEffect::
62 compare_to_impl(const RenderEffect *other) const {
63  // All DecalEffects are equivalent--there are no properties to
64  // store.
65  return 0;
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: DecalEffect::register_with_read_factory
70 // Access: Public, Static
71 // Description: Tells the BamReader how to create objects of type
72 // DecalEffect.
73 ////////////////////////////////////////////////////////////////////
74 void DecalEffect::
76  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: DecalEffect::write_datagram
81 // Access: Public, Virtual
82 // Description: Writes the contents of this object to the datagram
83 // for shipping out to a Bam file.
84 ////////////////////////////////////////////////////////////////////
85 void DecalEffect::
87  RenderEffect::write_datagram(manager, dg);
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: DecalEffect::make_from_bam
92 // Access: Protected, Static
93 // Description: This function is called by the BamReader's factory
94 // when a new object of type DecalEffect is encountered
95 // in the Bam file. It should create the DecalEffect
96 // and extract its information from the file.
97 ////////////////////////////////////////////////////////////////////
98 TypedWritable *DecalEffect::
99 make_from_bam(const FactoryParams &params) {
100  DecalEffect *effect = new DecalEffect;
101  DatagramIterator scan;
102  BamReader *manager;
103 
104  parse_params(params, scan, manager);
105  effect->fillin(scan, manager);
106 
107  return effect;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: DecalEffect::fillin
112 // Access: Protected
113 // Description: This internal function is called by make_from_bam to
114 // read in all of the relevant data from the BamFile for
115 // the new DecalEffect.
116 ////////////////////////////////////////////////////////////////////
117 void DecalEffect::
118 fillin(DatagramIterator &scan, BamReader *manager) {
119  RenderEffect::fillin(scan, manager);
120 }
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 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 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:86
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:90
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:75
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:213
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
Applied to a GeomNode to indicate that the children of this GeomNode are coplanar and should be drawn...
Definition: decalEffect.h:30