Panda3D
texMatrixAttrib.cxx
1 // Filename: texMatrixAttrib.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 "texMatrixAttrib.h"
16 #include "graphicsStateGuardianBase.h"
17 #include "dcast.h"
18 #include "bamReader.h"
19 #include "bamWriter.h"
20 #include "datagram.h"
21 #include "datagramIterator.h"
22 #include "textureStagePool.h"
23 
24 CPT(RenderAttrib) TexMatrixAttrib::_empty_attrib;
25 TypeHandle TexMatrixAttrib::_type_handle;
26 int TexMatrixAttrib::_attrib_slot;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: TexMatrixAttrib::Destructor
30 // Access: Public, Virtual
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 TexMatrixAttrib::
34 ~TexMatrixAttrib() {
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: TexMatrixAttrib::make
39 // Access: Published, Static
40 // Description: Constructs a TexMatrixAttrib that applies
41 // no stages at all.
42 ////////////////////////////////////////////////////////////////////
43 CPT(RenderAttrib) TexMatrixAttrib::
44 make() {
45  // We make it a special case and store a pointer to the empty attrib
46  // forever once we find it the first time, as an optimization.
47  if (_empty_attrib == (RenderAttrib *)NULL) {
48  _empty_attrib = return_new(new TexMatrixAttrib);
49  }
50 
51  return _empty_attrib;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: TexMatrixAttrib::make
56 // Access: Published, Static
57 // Description: Constructs a TexMatrixAttrib that applies the
58 // indicated matrix to the default texture stage. This
59 // interface is deprecated.
60 ////////////////////////////////////////////////////////////////////
61 CPT(RenderAttrib) TexMatrixAttrib::
62 make(const LMatrix4 &mat) {
63  pgraph_cat.warning()
64  << "Using deprecated TexMatrixAttrib interface.\n";
65  if (mat.is_identity()) {
66  return make();
67  }
68  CPT(TransformState) transform = TransformState::make_mat(mat);
69  return make(TextureStage::get_default(), transform);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: TexMatrixAttrib::make
74 // Access: Published, Static
75 // Description: Constructs a TexMatrixAttrib that applies the
76 // indicated transform to the named texture stage.
77 ////////////////////////////////////////////////////////////////////
78 CPT(RenderAttrib) TexMatrixAttrib::
79 make(TextureStage *stage, const TransformState *transform) {
80  return DCAST(TexMatrixAttrib, make())->add_stage(stage, transform);
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: TexMatrixAttrib::make_default
85 // Access: Published, Static
86 // Description: Returns a RenderAttrib that corresponds to whatever
87 // the standard default properties for render attributes
88 // of this type ought to be.
89 ////////////////////////////////////////////////////////////////////
90 CPT(RenderAttrib) TexMatrixAttrib::
91 make_default() {
92  return return_new(new TexMatrixAttrib);
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: TexMatrixAttrib::add_stage
97 // Access: Published, Static
98 // Description: Returns a new TexMatrixAttrib just like this one,
99 // with the indicated transform for the given stage. If
100 // this stage already exists, its transform is replaced.
101 ////////////////////////////////////////////////////////////////////
102 CPT(RenderAttrib) TexMatrixAttrib::
103 add_stage(TextureStage *stage, const TransformState *transform,
104  int override) const {
105  TexMatrixAttrib *attrib = new TexMatrixAttrib(*this);
106  Stages::iterator si = attrib->_stages.insert(StageNode(stage)).first;
107  (*si)._transform = transform;
108  (*si)._override = override;
109 
110  return return_new(attrib);
111 }
112 
113 ////////////////////////////////////////////////////////////////////
114 // Function: TexMatrixAttrib::remove_stage
115 // Access: Published, Static
116 // Description: Returns a new TexMatrixAttrib just like this one,
117 // with the indicated stage removed.
118 ////////////////////////////////////////////////////////////////////
119 CPT(RenderAttrib) TexMatrixAttrib::
120 remove_stage(TextureStage *stage) const {
121  TexMatrixAttrib *attrib = new TexMatrixAttrib(*this);
122  attrib->_stages.erase(StageNode(stage));
123  return return_new(attrib);
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: TexMatrixAttrib::get_mat
128 // Access: Published
129 // Description: Returns the transformation matrix associated with
130 // the default texture stage.
131 ////////////////////////////////////////////////////////////////////
132 const LMatrix4 &TexMatrixAttrib::
133 get_mat() const {
134  return get_mat(TextureStage::get_default());
135 }
136 
137 ////////////////////////////////////////////////////////////////////
138 // Function: TexMatrixAttrib::is_empty
139 // Access: Published
140 // Description: Returns true if no stages are defined in the
141 // TexMatrixAttrib, false if at least one is.
142 ////////////////////////////////////////////////////////////////////
143 bool TexMatrixAttrib::
144 is_empty() const {
145  return _stages.empty();
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: TexMatrixAttrib::has_stage
150 // Access: Published
151 // Description: Returns true if there is a transform associated with
152 // the indicated stage, or false otherwise (in which
153 // case get_transform(stage) will return the identity
154 // transform).
155 ////////////////////////////////////////////////////////////////////
156 bool TexMatrixAttrib::
157 has_stage(TextureStage *stage) const {
158  Stages::const_iterator mi = _stages.find(StageNode(stage));
159  return (mi != _stages.end());
160 }
161 
162 ////////////////////////////////////////////////////////////////////
163 // Function: TexMatrixAttrib::get_num_stages
164 // Access: Published
165 // Description: Returns the number of stages that are represented by
166 // this attrib.
167 ////////////////////////////////////////////////////////////////////
168 int TexMatrixAttrib::
169 get_num_stages() const {
170  return _stages.size();
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: TexMatrixAttrib::get_stage
175 // Access: Published
176 // Description: Returns the nth stage that is represented by this
177 // attrib. The TextureStages are in no particular
178 // order.
179 ////////////////////////////////////////////////////////////////////
180 TextureStage *TexMatrixAttrib::
181 get_stage(int n) const {
182  nassertr(n >= 0 && n < (int)_stages.size(), NULL);
183  return _stages[n]._stage;
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: TexMatrixAttrib::get_mat
188 // Access: Published
189 // Description: Returns the transformation matrix associated with
190 // the indicated texture stage, or identity matrix if
191 // nothing is associated with the indicated stage.
192 ////////////////////////////////////////////////////////////////////
193 const LMatrix4 &TexMatrixAttrib::
194 get_mat(TextureStage *stage) const {
195  return get_transform(stage)->get_mat();
196 }
197 
198 ////////////////////////////////////////////////////////////////////
199 // Function: TexMatrixAttrib::get_transform
200 // Access: Published
201 // Description: Returns the transformation associated with
202 // the indicated texture stage, or identity matrix if
203 // nothing is associated with the indicated stage.
204 ////////////////////////////////////////////////////////////////////
205 CPT(TransformState) TexMatrixAttrib::
206 get_transform(TextureStage *stage) const {
207  Stages::const_iterator mi = _stages.find(StageNode(stage));
208  if (mi != _stages.end()) {
209  return (*mi)._transform;
210  }
211  return TransformState::make_identity();
212 }
213 
214 ////////////////////////////////////////////////////////////////////
215 // Function: TexMatrixAttrib::output
216 // Access: Public, Virtual
217 // Description:
218 ////////////////////////////////////////////////////////////////////
219 void TexMatrixAttrib::
220 output(ostream &out) const {
221  out << get_type() << ":";
222 
223  Stages::const_iterator mi;
224  for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
225  const StageNode &sn = (*mi);
226  out << " " << sn._stage->get_name() << "(" << *sn._transform << ")";
227  if (sn._override != 0) {
228  out << "^" << sn._override;
229  }
230  }
231 }
232 
233 ////////////////////////////////////////////////////////////////////
234 // Function: TexMatrixAttrib::compare_to_impl
235 // Access: Protected, Virtual
236 // Description: Intended to be overridden by derived TexMatrixAttrib
237 // types to return a unique number indicating whether
238 // this TexMatrixAttrib is equivalent to the other one.
239 //
240 // This should return 0 if the two TexMatrixAttrib objects
241 // are equivalent, a number less than zero if this one
242 // should be sorted before the other one, and a number
243 // greater than zero otherwise.
244 //
245 // This will only be called with two TexMatrixAttrib
246 // objects whose get_type() functions return the same.
247 ////////////////////////////////////////////////////////////////////
248 int TexMatrixAttrib::
249 compare_to_impl(const RenderAttrib *other) const {
250  const TexMatrixAttrib *ta;
251  DCAST_INTO_R(ta, other, 0);
252 
253  Stages::const_iterator ai, bi;
254  ai = _stages.begin();
255  bi = ta->_stages.begin();
256  while (ai != _stages.end() && bi != ta->_stages.end()) {
257  if ((*ai) < (*bi)) {
258  // This stage is in a but not in b.
259  return -1;
260 
261  } else if ((*bi) < (*ai)) {
262  // This stage is in b but not in a.
263  return 1;
264 
265  } else {
266  // This stage is in both.
267  ++ai;
268  ++bi;
269  }
270  }
271 
272  if (bi != ta->_stages.end()) {
273  // a ran out first; b was longer.
274  return -1;
275  }
276 
277  if (ai != _stages.end()) {
278  // b ran out first; a was longer.
279  return 1;
280  }
281 
282  return 0;
283 }
284 
285 ////////////////////////////////////////////////////////////////////
286 // Function: TexMatrixAttrib::get_hash_impl
287 // Access: Protected, Virtual
288 // Description: Intended to be overridden by derived RenderAttrib
289 // types to return a unique hash for these particular
290 // properties. RenderAttribs that compare the same with
291 // compare_to_impl(), above, should return the same
292 // hash; RenderAttribs that compare differently should
293 // return a different hash.
294 ////////////////////////////////////////////////////////////////////
295 size_t TexMatrixAttrib::
296 get_hash_impl() const {
297  size_t hash = 0;
298  Stages::const_iterator si;
299  for (si = _stages.begin(); si != _stages.end(); ++si) {
300  const StageNode &sn = (*si);
301 
302  hash = pointer_hash::add_hash(hash, sn._stage);
303  hash = pointer_hash::add_hash(hash, sn._transform);
304  hash = int_hash::add_hash(hash, sn._override);
305  }
306 
307  return hash;
308 }
309 
310 ////////////////////////////////////////////////////////////////////
311 // Function: TexMatrixAttrib::compose_impl
312 // Access: Protected, Virtual
313 // Description: Intended to be overridden by derived RenderAttrib
314 // types to specify how two consecutive RenderAttrib
315 // objects of the same type interact.
316 //
317 // This should return the result of applying the other
318 // RenderAttrib to a node in the scene graph below this
319 // RenderAttrib, which was already applied. In most
320 // cases, the result is the same as the other
321 // RenderAttrib (that is, a subsequent RenderAttrib
322 // completely replaces the preceding one). On the other
323 // hand, some kinds of RenderAttrib (for instance,
324 // ColorTransformAttrib) might combine in meaningful
325 // ways.
326 ////////////////////////////////////////////////////////////////////
327 CPT(RenderAttrib) TexMatrixAttrib::
328 compose_impl(const RenderAttrib *other) const {
329  const TexMatrixAttrib *ta;
330  DCAST_INTO_R(ta, other, 0);
331 
332  // The composition is the union of the two attribs. In the case
333  // when a stage is in both attribs, we compose the stages.
334 
335  TexMatrixAttrib *attrib = new TexMatrixAttrib;
336 
337  Stages::const_iterator ai, bi;
338  ai = _stages.begin();
339  bi = ta->_stages.begin();
340  while (ai != _stages.end() && bi != ta->_stages.end()) {
341  if ((*ai)._stage < (*bi)._stage) {
342  // This stage is in a but not in b.
343  attrib->_stages.insert(attrib->_stages.end(), *ai);
344  ++ai;
345 
346  } else if ((*bi)._stage < (*ai)._stage) {
347  // This stage is in b but not in a.
348  attrib->_stages.insert(attrib->_stages.end(), *bi);
349  ++bi;
350 
351  } else {
352  // This stage is in both.
353  if ((*ai)._override == (*bi)._override) {
354  // Same override; compose them.
355  CPT(TransformState) new_transform = (*ai)._transform->compose((*bi)._transform);
356  StageNode sn((*ai)._stage);
357  sn._transform = new_transform;
358  sn._override = (*ai)._override;
359  attrib->_stages.insert(attrib->_stages.end(), sn);
360  } else if ((*ai)._override < (*bi)._override) {
361  // Override b wins.
362  attrib->_stages.insert(attrib->_stages.end(), *bi);
363  } else {
364  // Override a wins.
365  attrib->_stages.insert(attrib->_stages.end(), *ai);
366  }
367 
368  ++ai;
369  ++bi;
370  }
371  }
372 
373  while (ai != _stages.end()) {
374  // This stage is in a but not in b.
375  attrib->_stages.insert(attrib->_stages.end(), *ai);
376  ++ai;
377  }
378 
379  while (bi != ta->_stages.end()) {
380  // This stage is in b but not in a.
381  attrib->_stages.insert(attrib->_stages.end(), *bi);
382  ++bi;
383  }
384 
385  return return_new(attrib);
386 }
387 
388 ////////////////////////////////////////////////////////////////////
389 // Function: TexMatrixAttrib::invert_compose_impl
390 // Access: Protected, Virtual
391 // Description: Intended to be overridden by derived RenderAttrib
392 // types to specify how two consecutive RenderAttrib
393 // objects of the same type interact.
394 //
395 // See invert_compose() and compose_impl().
396 ////////////////////////////////////////////////////////////////////
397 CPT(RenderAttrib) TexMatrixAttrib::
398 invert_compose_impl(const RenderAttrib *other) const {
399  const TexMatrixAttrib *ta;
400  DCAST_INTO_R(ta, other, 0);
401 
402  // The inverse composition works a lot like the composition, except
403  // we invert the ai stages.
404 
405  TexMatrixAttrib *attrib = new TexMatrixAttrib;
406 
407  Stages::const_iterator ai, bi;
408  ai = _stages.begin();
409  bi = ta->_stages.begin();
410  while (ai != _stages.end() && bi != ta->_stages.end()) {
411  if ((*ai)._stage < (*bi)._stage) {
412  // This stage is in a but not in b.
413  CPT(TransformState) inv_a =
414  (*ai)._transform->invert_compose(TransformState::make_identity());
415  StageNode sn((*ai)._stage);
416  sn._transform = inv_a;
417  sn._override = (*ai)._override;
418  attrib->_stages.insert(attrib->_stages.end(), sn);
419  ++ai;
420 
421  } else if ((*bi)._stage < (*ai)._stage) {
422  // This stage is in b but not in a.
423  attrib->_stages.insert(attrib->_stages.end(), *bi);
424  ++bi;
425 
426  } else {
427  // This stage is in both.
428  if ((*ai)._override == (*bi)._override) {
429  // Same override; compose them.
430  CPT(TransformState) new_transform = (*ai)._transform->invert_compose((*bi)._transform);
431  StageNode sn((*ai)._stage);
432  sn._transform = new_transform;
433  sn._override = (*ai)._override;
434  attrib->_stages.insert(attrib->_stages.end(), sn);
435 
436  } else if ((*ai)._override < (*bi)._override) {
437  // Override b wins.
438  attrib->_stages.insert(attrib->_stages.end(), *bi);
439 
440  } else {
441  // Override a wins.
442  CPT(TransformState) inv_a =
443  (*ai)._transform->invert_compose(TransformState::make_identity());
444  StageNode sn((*ai)._stage);
445  sn._transform = inv_a;
446  sn._override = (*ai)._override;
447  attrib->_stages.insert(attrib->_stages.end(), sn);
448  }
449 
450  ++ai;
451  ++bi;
452  }
453  }
454 
455  while (ai != _stages.end()) {
456  // This stage is in a but not in b.
457  CPT(TransformState) inv_a =
458  (*ai)._transform->invert_compose(TransformState::make_identity());
459  StageNode sn((*ai)._stage);
460  sn._transform = inv_a;
461  sn._override = (*ai)._override;
462  attrib->_stages.insert(attrib->_stages.end(), sn);
463  ++ai;
464  }
465 
466  while (bi != ta->_stages.end()) {
467  // This stage is in b but not in a.
468  attrib->_stages.insert(attrib->_stages.end(), *bi);
469  ++bi;
470  }
471 
472  return return_new(attrib);
473 }
474 
475 ////////////////////////////////////////////////////////////////////
476 // Function: TexMatrixAttrib::get_auto_shader_attrib_impl
477 // Access: Protected, Virtual
478 // Description:
479 ////////////////////////////////////////////////////////////////////
480 CPT(RenderAttrib) TexMatrixAttrib::
481 get_auto_shader_attrib_impl(const RenderState *state) const {
482  // For a TexMatrixAttrib, the particular matrix per TextureStage
483  // isn't important, just whether there is a matrix at all. So we
484  // create a new state with an identity matrix everywhere there is a
485  // matrix at all in the original.
486 
487  TexMatrixAttrib *attrib = new TexMatrixAttrib;
488 
489  Stages::const_iterator ai;
490  for (ai = _stages.begin(); ai != _stages.end(); ++ai) {
491  StageNode sn((*ai)._stage);
492  sn._transform = TransformState::make_identity();
493  attrib->_stages.insert(attrib->_stages.end(), sn);
494  }
495 
496  return return_new(attrib);
497 }
498 
499 ////////////////////////////////////////////////////////////////////
500 // Function: TexMatrixAttrib::register_with_read_factory
501 // Access: Public, Static
502 // Description: Tells the BamReader how to create objects of type
503 // TexMatrixAttrib.
504 ////////////////////////////////////////////////////////////////////
505 void TexMatrixAttrib::
506 register_with_read_factory() {
507  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
508 }
509 
510 ////////////////////////////////////////////////////////////////////
511 // Function: TexMatrixAttrib::write_datagram
512 // Access: Public, Virtual
513 // Description: Writes the contents of this object to the datagram
514 // for shipping out to a Bam file.
515 ////////////////////////////////////////////////////////////////////
518  RenderAttrib::write_datagram(manager, dg);
519 
520  dg.add_uint16(_stages.size());
521 
522  Stages::const_iterator si;
523  for (si = _stages.begin(); si != _stages.end(); ++si) {
524  const StageNode &sn = (*si);
525 
526  manager->write_pointer(dg, sn._stage);
527  manager->write_pointer(dg, sn._transform);
528  dg.add_int32(sn._override);
529  }
530 }
531 
532 ////////////////////////////////////////////////////////////////////
533 // Function: TexMatrixAttrib::complete_pointers
534 // Access: Public, Virtual
535 // Description: Receives an array of pointers, one for each time
536 // manager->read_pointer() was called in fillin().
537 // Returns the number of pointers processed.
538 ////////////////////////////////////////////////////////////////////
541  int pi = RenderAttrib::complete_pointers(p_list, manager);
542 
543  for (size_t sni = 0; sni < _stages.size(); ++sni) {
544  // Filter the TextureStage through the TextureStagePool.
545  PT(TextureStage) ts = DCAST(TextureStage, p_list[pi++]);
547 
548  const TransformState *transform = DCAST(TransformState, p_list[pi++]);
549 
550  StageNode &sn = _stages[sni];
551  sn._stage = ts;
552  sn._transform = transform;
553  }
554  _stages.sort();
555 
556  return pi;
557 }
558 
559 ////////////////////////////////////////////////////////////////////
560 // Function: TexMatrixAttrib::make_from_bam
561 // Access: Protected, Static
562 // Description: This function is called by the BamReader's factory
563 // when a new object of type TexMatrixAttrib is encountered
564 // in the Bam file. It should create the TexMatrixAttrib
565 // and extract its information from the file.
566 ////////////////////////////////////////////////////////////////////
567 TypedWritable *TexMatrixAttrib::
568 make_from_bam(const FactoryParams &params) {
569  TexMatrixAttrib *attrib = new TexMatrixAttrib;
570  DatagramIterator scan;
571  BamReader *manager;
572 
573  parse_params(params, scan, manager);
574  attrib->fillin(scan, manager);
575 
576  return attrib;
577 }
578 
579 ////////////////////////////////////////////////////////////////////
580 // Function: TexMatrixAttrib::fillin
581 // Access: Protected
582 // Description: This internal function is called by make_from_bam to
583 // read in all of the relevant data from the BamFile for
584 // the new TexMatrixAttrib.
585 ////////////////////////////////////////////////////////////////////
586 void TexMatrixAttrib::
587 fillin(DatagramIterator &scan, BamReader *manager) {
588  RenderAttrib::fillin(scan, manager);
589 
590  size_t num_stages = scan.get_uint16();
591  for (size_t i = 0; i < num_stages; i++) {
592  manager->read_pointer(scan);
593  manager->read_pointer(scan);
594  int override = 0;
595  if (manager->get_file_minor_ver() >= 24) {
596  override = scan.get_int32();
597  }
598 
599  StageNode sn(NULL);
600  sn._override = override;
601  _stages.push_back(sn);
602  }
603 }
static size_t add_hash(size_t start, const void *key)
Adds the indicated key into a running hash.
Definition: stl_compares.I:133
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
size_type_0 size() const
Returns the number of elements in the ordered vector.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
string get_name(TypedObject *object=(TypedObject *) NULL) const
Returns the name of the type.
Definition: typeHandle.I:132
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
PN_int32 get_int32()
Extracts a signed 32-bit integer.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
Definition: bamReader.I:105
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
Definition: stl_compares.I:122
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
void sort()
Maps to sort_unique().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:90
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:181
Applies a transform matrix to UV&#39;s before they are rendered.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:213
bool is_identity() const
Returns true if this is (close enough to) the identity matrix, false otherwise.
Definition: lmatrix.h:1433
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
Definition: datagram.I:159
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
static TextureStage * get_default()
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
Definition: textureStage.I:766
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
static TextureStage * get_stage(TextureStage *temp)
Returns a TextureStage pointer that represents the same TextureStage described by temp...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition: bamWriter.cxx:279
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition: bamReader.cxx:658