Panda3D
textureProperties.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 textureProperties.cxx
10  * @author drose
11  * @date 2000-11-29
12  */
13 
14 #include "textureProperties.h"
15 #include "palettizer.h"
16 #include "pnmFileType.h"
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 #include "bamReader.h"
20 #include "bamWriter.h"
21 #include "string_utils.h"
22 
23 using std::string;
24 
25 TypeHandle TextureProperties::_type_handle;
26 
27 /**
28  *
29  */
30 TextureProperties::
31 TextureProperties() {
32  _got_num_channels = false;
33  _num_channels = 0;
34  _effective_num_channels = 0;
35  _format = EggTexture::F_unspecified;
36  _force_format = false;
37  _generic_format = false;
38  _keep_format = false;
39  _minfilter = EggTexture::FT_unspecified;
40  _magfilter = EggTexture::FT_unspecified;
41  _quality_level = EggTexture::QL_unspecified;
42  _anisotropic_degree = 0;
43  _color_type = nullptr;
44  _alpha_type = nullptr;
45 }
46 
47 /**
48  *
49  */
50 TextureProperties::
51 TextureProperties(const TextureProperties &copy) :
52  _format(copy._format),
53  _force_format(copy._force_format),
54  _generic_format(copy._generic_format),
55  _keep_format(copy._keep_format),
56  _minfilter(copy._minfilter),
57  _magfilter(copy._magfilter),
58  _quality_level(copy._quality_level),
59  _anisotropic_degree(copy._anisotropic_degree),
60  _color_type(copy._color_type),
61  _alpha_type(copy._alpha_type),
62  _got_num_channels(copy._got_num_channels),
63  _num_channels(copy._num_channels),
64  _effective_num_channels(copy._effective_num_channels)
65 {
66 }
67 
68 /**
69  *
70  */
71 void TextureProperties::
72 operator = (const TextureProperties &copy) {
73  _force_format = copy._force_format;
74  _generic_format = copy._generic_format;
75  _keep_format = copy._keep_format;
76  _minfilter = copy._minfilter;
77  _magfilter = copy._magfilter;
78  _quality_level = copy._quality_level;
79  _anisotropic_degree = copy._anisotropic_degree;
80  _color_type = copy._color_type;
81  _alpha_type = copy._alpha_type;
82  _got_num_channels = copy._got_num_channels;
83  _num_channels = copy._num_channels;
84  _effective_num_channels = copy._effective_num_channels;
85  _format = copy._format;
86 }
87 
88 /**
89  * Resets only the properties that might be changed by update_properties() to
90  * a neutral state.
91  */
94  if (!_force_format) {
95  _format = EggTexture::F_unspecified;
96  }
97 
98  _minfilter = EggTexture::FT_unspecified;
99  _magfilter = EggTexture::FT_unspecified;
100  _quality_level = EggTexture::QL_unspecified;
101  _anisotropic_degree = 0;
102 }
103 
104 /**
105  * Returns true if the number of channels is known.
106  */
109  return _got_num_channels;
110 }
111 
112 /**
113  * Returns the number of channels (1 through 4) associated with the image. It
114  * is an error to call this unless has_num_channels() returns true.
115  */
118  nassertr(_got_num_channels, 0);
119  return _effective_num_channels;
120 }
121 
122 /**
123  * Sets the number of channels (1 through 4) associated with the image,
124  * presumably after reading this information from the image header.
125  */
127 set_num_channels(int num_channels) {
128  _num_channels = num_channels;
129  _effective_num_channels = num_channels;
130  _got_num_channels = true;
131 }
132 
133 /**
134  * Sets the actual number of channels to indicate a grayscale image,
135  * presumably after discovering that the image contains no colored pixels.
136  */
139  nassertv(_got_num_channels && _num_channels >= 3);
140  _num_channels -= 2;
141  _effective_num_channels = _num_channels;
142 }
143 
144 /**
145  * Sets the actual number of channels to indicate an image with no alpha
146  * channel, presumably after discovering that the alpha channel contains no
147  * meaningful pixels.
148  */
151  nassertv(_got_num_channels && (_num_channels == 2 || _num_channels == 4));
152  _num_channels--;
153  _effective_num_channels = _num_channels;
154 }
155 
156 /**
157  * Returns true if the texture uses an alpha channel, false otherwise.
158  */
160 uses_alpha() const {
161  switch (_format) {
162  case EggTexture::F_rgba:
163  case EggTexture::F_rgbm:
164  case EggTexture::F_rgba12:
165  case EggTexture::F_rgba8:
166  case EggTexture::F_rgba4:
167  case EggTexture::F_rgba5:
168  case EggTexture::F_alpha:
169  case EggTexture::F_luminance_alpha:
170  case EggTexture::F_luminance_alphamask:
171  return true;
172 
173  default:
174  return false;
175  }
176 }
177 
178 /**
179  * Returns a string corresponding to the TextureProperties object. Each
180  * unique set of TextureProperties will generate a unique string. This is
181  * used to generate unique palette image filenames.
182  */
183 string TextureProperties::
184 get_string() const {
185  string result;
186 
187  if (_got_num_channels) {
188  std::ostringstream num;
189  num << _effective_num_channels;
190  result += num.str();
191  }
192 
193  result += get_format_string(_format);
194  result += get_filter_string(_minfilter);
195  result += get_filter_string(_magfilter);
196  result += get_anisotropic_degree_string(_anisotropic_degree);
197  result += get_type_string(_color_type, _alpha_type);
198  result += get_quality_level_string(_quality_level);
199  return result;
200 }
201 
202 /**
203  * If the indicate TextureProperties structure is more specific than this one,
204  * updates this one.
205  */
208  if (!_got_num_channels) {
209  _got_num_channels = other._got_num_channels;
210  _num_channels = other._num_channels;
211  _effective_num_channels = _num_channels;
212  }
213  if (_force_format) {
214  // If we've forced our own format, it doesn't change.
215  } else if (other._force_format) {
216  _format = other._format;
217  } else {
218  _format = union_format(_format, other._format);
219  }
220 
221  _minfilter = union_filter(_minfilter, other._minfilter);
222  _magfilter = union_filter(_magfilter, other._magfilter);
223  _quality_level = union_quality_level(_quality_level, other._quality_level);
224 
225  _anisotropic_degree = other._anisotropic_degree;
226 
227  if (_color_type == nullptr) {
228  _color_type = other._color_type;
229  _alpha_type = other._alpha_type;
230  }
231 }
232 
233 /**
234  * If any properties remain unspecified, specify them now. Also reconcile
235  * conflicting information.
236  */
239  if (!_got_num_channels || _force_format) {
240  switch (_format) {
241  case EggTexture::F_rgba:
242  case EggTexture::F_rgbm:
243  case EggTexture::F_rgba12:
244  case EggTexture::F_rgba8:
245  case EggTexture::F_rgba4:
246  case EggTexture::F_rgba5:
247  _num_channels = 4;
248  break;
249 
250  case EggTexture::F_unspecified:
251  case EggTexture::F_rgb:
252  case EggTexture::F_rgb12:
253  case EggTexture::F_rgb8:
254  case EggTexture::F_rgb5:
255  case EggTexture::F_rgb332:
256  _num_channels = 3;
257  break;
258 
259  case EggTexture::F_luminance_alpha:
260  case EggTexture::F_luminance_alphamask:
261  _num_channels = 2;
262  break;
263 
264  case EggTexture::F_red:
265  case EggTexture::F_green:
266  case EggTexture::F_blue:
267  case EggTexture::F_alpha:
268  case EggTexture::F_luminance:
269  _num_channels = 1;
270  break;
271  }
272  _got_num_channels = true;
273  }
274 
275  _effective_num_channels = _num_channels;
276 
277  // Respect the _generic_format flag. If this is set, it means the user has
278  // indicated that we should strip off any bitcount-specific formats and
279  // replace them with the more generic equivalents.
280  if (_generic_format) {
281  switch (_format) {
282  case EggTexture::F_unspecified:
283  case EggTexture::F_rgba:
284  case EggTexture::F_rgbm:
285  case EggTexture::F_rgb:
286  case EggTexture::F_red:
287  case EggTexture::F_green:
288  case EggTexture::F_blue:
289  case EggTexture::F_alpha:
290  case EggTexture::F_luminance:
291  case EggTexture::F_luminance_alpha:
292  case EggTexture::F_luminance_alphamask:
293  break;
294 
295  case EggTexture::F_rgba12:
296  case EggTexture::F_rgba8:
297  case EggTexture::F_rgba4:
298  case EggTexture::F_rgba5:
299  _format = EggTexture::F_rgba;
300  break;
301 
302  case EggTexture::F_rgb12:
303  case EggTexture::F_rgb8:
304  case EggTexture::F_rgb5:
305  case EggTexture::F_rgb332:
306  _format = EggTexture::F_rgb;
307  break;
308  }
309  }
310 
311  // Make sure the format reflects the number of channels, although we accept
312  // a format that ignores an alpha channel.
313  if (!_force_format && !_keep_format) {
314  switch (_num_channels) {
315  case 1:
316  switch (_format) {
317  case EggTexture::F_red:
318  case EggTexture::F_green:
319  case EggTexture::F_blue:
320  case EggTexture::F_alpha:
321  case EggTexture::F_luminance:
322  break;
323 
324  // These formats suggest an alpha channel; they are quietly replaced
325  // with non-alpha equivalents.
326  case EggTexture::F_luminance_alpha:
327  case EggTexture::F_luminance_alphamask:
328  _format = EggTexture::F_luminance;
329  break;
330 
331  default:
332  _format = EggTexture::F_luminance;
333  }
334  break;
335 
336  case 2:
337  switch (_format) {
338  case EggTexture::F_luminance_alpha:
339  case EggTexture::F_luminance_alphamask:
340  break;
341 
342  // These formats implicitly reduce the number of channels to 1.
343  case EggTexture::F_red:
344  case EggTexture::F_green:
345  case EggTexture::F_blue:
346  case EggTexture::F_alpha:
347  case EggTexture::F_luminance:
348  break;
349 
350  default:
351  _format = EggTexture::F_luminance_alpha;
352  }
353  break;
354 
355  case 3:
356  switch (_format) {
357  case EggTexture::F_rgb:
358  case EggTexture::F_rgb12:
359  case EggTexture::F_rgb8:
360  case EggTexture::F_rgb5:
361  case EggTexture::F_rgb332:
362  break;
363 
364  // These formats suggest an alpha channel; they are quietly replaced
365  // with non-alpha equivalents.
366  case EggTexture::F_rgba8:
367  _format = EggTexture::F_rgb8;
368  break;
369 
370  case EggTexture::F_rgba5:
371  case EggTexture::F_rgba4:
372  _format = EggTexture::F_rgb5;
373  break;
374 
375  // These formats implicitly reduce the number of channels to 1.
376  case EggTexture::F_red:
377  case EggTexture::F_green:
378  case EggTexture::F_blue:
379  case EggTexture::F_alpha:
380  case EggTexture::F_luminance:
381  break;
382 
383  default:
384  _format = EggTexture::F_rgb;
385  }
386  break;
387 
388  case 4:
389  switch (_format) {
390  case EggTexture::F_rgba:
391  case EggTexture::F_rgbm:
392  case EggTexture::F_rgba12:
393  case EggTexture::F_rgba8:
394  case EggTexture::F_rgba4:
395  case EggTexture::F_rgba5:
396  break;
397 
398  // These formats implicitly reduce the number of channels to 3.
399  case EggTexture::F_rgb:
400  case EggTexture::F_rgb12:
401  case EggTexture::F_rgb8:
402  case EggTexture::F_rgb5:
403  case EggTexture::F_rgb332:
404  _effective_num_channels = 3;
405  break;
406 
407  // These formats implicitly reduce the number of channels to 2.
408  case EggTexture::F_luminance_alpha:
409  case EggTexture::F_luminance_alphamask:
410  _effective_num_channels = 2;
411  break;
412 
413  // These formats implicitly reduce the number of channels to 1.
414  case EggTexture::F_red:
415  case EggTexture::F_green:
416  case EggTexture::F_blue:
417  case EggTexture::F_alpha:
418  case EggTexture::F_luminance:
419  _effective_num_channels = 1;
420  break;
421 
422  default:
423  _format = EggTexture::F_rgba;
424  }
425  }
426  }
427 
428  switch (_minfilter) {
429  case EggTexture::FT_unspecified:
430  _minfilter = EggTexture::FT_linear;
431  break;
432 
433  default:
434  break;
435  }
436 
437  switch (_magfilter) {
438  case EggTexture::FT_unspecified:
439  case EggTexture::FT_nearest_mipmap_nearest:
440  case EggTexture::FT_linear_mipmap_nearest:
441  case EggTexture::FT_nearest_mipmap_linear:
442  case EggTexture::FT_linear_mipmap_linear:
443  _magfilter = EggTexture::FT_linear;
444  break;
445 
446  default:
447  break;
448  }
449 
450  if (_color_type == nullptr) {
451  _color_type = pal->_color_type;
452  _alpha_type = pal->_alpha_type;
453  }
454 }
455 
456 /**
457  * Adjusts the texture properties of the indicated egg reference to match
458  * these properties.
459  */
461 update_egg_tex(EggTexture *egg_tex) const {
462  egg_tex->set_format(_format);
463  egg_tex->set_minfilter(_minfilter);
464  egg_tex->set_magfilter(_minfilter);
465  egg_tex->set_quality_level(_quality_level);
466  egg_tex->set_anisotropic_degree(_anisotropic_degree);
467 }
468 
469 /**
470  * Returns true if all of the properties that are reflected directly in an egg
471  * file match between this TextureProperties object and the other, or false if
472  * any of them differ.
473  */
476  return (_format == other._format &&
477  _minfilter == other._minfilter &&
478  _magfilter == other._magfilter &&
479  _quality_level == other._quality_level &&
480  _anisotropic_degree == other._anisotropic_degree);
481 }
482 
483 /**
484  *
485  */
486 bool TextureProperties::
487 operator < (const TextureProperties &other) const {
488  if (_format != other._format) {
489  return (int)_format < (int)other._format;
490  }
491  if (_minfilter != other._minfilter) {
492  return (int)_minfilter < (int)other._minfilter;
493  }
494  if (_magfilter != other._magfilter) {
495  return (int)_magfilter < (int)other._magfilter;
496  }
497  if (_quality_level != other._quality_level) {
498  return (int)_quality_level < (int)other._quality_level;
499  }
500  if (_anisotropic_degree != other._anisotropic_degree) {
501  return _anisotropic_degree < other._anisotropic_degree;
502  }
503  if (_color_type != other._color_type) {
504  return _color_type < other._color_type;
505  }
506  if (_color_type != nullptr) {
507  if (_alpha_type != other._alpha_type) {
508  return _alpha_type < other._alpha_type;
509  }
510  }
511  return false;
512 }
513 
514 /**
515  *
516  */
517 bool TextureProperties::
518 operator == (const TextureProperties &other) const {
519  return (_format == other._format &&
520  _minfilter == other._minfilter &&
521  _magfilter == other._magfilter &&
522  _quality_level == other._quality_level &&
523  _anisotropic_degree == other._anisotropic_degree &&
524  _color_type == other._color_type &&
525  (_color_type == nullptr ||
526  _alpha_type == other._alpha_type));
527 }
528 
529 /**
530  *
531  */
532 bool TextureProperties::
533 operator != (const TextureProperties &other) const {
534  return !operator == (other);
535 }
536 
537 /**
538  * Returns a short string representing the given EggTexture format.
539  */
540 string TextureProperties::
541 get_format_string(EggTexture::Format format) {
542  switch (format) {
543  case EggTexture::F_unspecified:
544  return "u";
545 
546  case EggTexture::F_rgba:
547  return "a";
548 
549  case EggTexture::F_rgbm:
550  return "m";
551 
552  case EggTexture::F_rgba12:
553  return "a12";
554 
555  case EggTexture::F_rgba8:
556  return "a8";
557 
558  case EggTexture::F_rgba4:
559  return "a4";
560 
561  case EggTexture::F_rgba5:
562  return "a5";
563 
564  case EggTexture::F_rgb:
565  return "c";
566 
567  case EggTexture::F_rgb12:
568  return "c12";
569 
570  case EggTexture::F_rgb8:
571  return "c8";
572 
573  case EggTexture::F_rgb5:
574  return "c5";
575 
576  case EggTexture::F_rgb332:
577  return "c3";
578 
579  case EggTexture::F_luminance_alpha:
580  return "t"; // t for two-channel
581 
582  case EggTexture::F_luminance_alphamask:
583  return "t1";
584 
585  case EggTexture::F_red:
586  return "r";
587 
588  case EggTexture::F_green:
589  return "g";
590 
591  case EggTexture::F_blue:
592  return "b";
593 
594  case EggTexture::F_alpha:
595  return "a";
596 
597  case EggTexture::F_luminance:
598  return "l";
599  }
600 
601  return "x";
602 }
603 
604 /**
605  * Returns a short string representing the given EggTexture filter type.
606  */
607 string TextureProperties::
608 get_filter_string(EggTexture::FilterType filter_type) {
609  switch (filter_type) {
610  case EggTexture::FT_unspecified:
611  return "u";
612 
613  case EggTexture::FT_nearest:
614  return "n";
615 
616  case EggTexture::FT_linear:
617  return "l";
618 
619  case EggTexture::FT_nearest_mipmap_nearest:
620  return "m1";
621 
622  case EggTexture::FT_linear_mipmap_nearest:
623  return "m2";
624 
625  case EggTexture::FT_nearest_mipmap_linear:
626  return "m3";
627 
628  case EggTexture::FT_linear_mipmap_linear:
629  return "m";
630  }
631 
632  return "x";
633 }
634 
635 /**
636  * Returns a short string describing the anisotropic degree.
637  */
638 string TextureProperties::
639 get_anisotropic_degree_string(int aniso_degree) {
640  if (aniso_degree <= 1) {
641  return "";
642  } else {
643  return string("an") + format_string(aniso_degree);
644  }
645 }
646 
647 /**
648  * Returns a short string describing the quality level.
649  */
650 string TextureProperties::
651 get_quality_level_string(EggTexture::QualityLevel quality_level) {
652  switch (quality_level) {
653  case EggTexture::QL_unspecified:
654  case EggTexture::QL_default:
655  return "";
656 
657  case EggTexture::QL_fastest:
658  return "f";
659 
660  case EggTexture::QL_normal:
661  return "n";
662 
663  case EggTexture::QL_best:
664  return "b";
665  }
666  return "";
667 }
668 
669 /**
670  * Returns a short string representing whether the color and/or alpha type has
671  * been specified or not.
672  */
673 string TextureProperties::
674 get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) {
675  if (color_type == nullptr) {
676  return "";
677  }
678  if (alpha_type == nullptr) {
679  return "c";
680  }
681  return "a";
682 }
683 
684 /**
685  * Returns the EggTexture format which is the more specific of the two.
686  */
687 EggTexture::Format TextureProperties::
688 union_format(EggTexture::Format a, EggTexture::Format b) {
689  switch (a) {
690  case EggTexture::F_unspecified:
691  return b;
692 
693  case EggTexture::F_rgba:
694  switch (b) {
695  case EggTexture::F_rgbm:
696  case EggTexture::F_rgba12:
697  case EggTexture::F_rgba8:
698  case EggTexture::F_rgba4:
699  case EggTexture::F_rgba5:
700  case EggTexture::F_red:
701  case EggTexture::F_green:
702  case EggTexture::F_blue:
703  case EggTexture::F_alpha:
704  return b;
705 
706  default:
707  return a;
708  };
709 
710  case EggTexture::F_rgb:
711  if (b != EggTexture::F_unspecified) {
712  return b;
713  }
714  return a;
715 
716  default:
717  return a;
718  }
719 }
720 
721 /**
722  * Returns the EggTexture filter type which is the more specific of the two.
723  */
724 EggTexture::FilterType TextureProperties::
725 union_filter(EggTexture::FilterType a, EggTexture::FilterType b) {
726  if ((int)a < (int)b) {
727  return b;
728  } else {
729  return a;
730  }
731 }
732 
733 /**
734  * Returns the EggTexture quality level which is the more specific of the two.
735  */
736 EggTexture::QualityLevel TextureProperties::
737 union_quality_level(EggTexture::QualityLevel a, EggTexture::QualityLevel b) {
738  if ((int)a < (int)b) {
739  return b;
740  } else {
741  return a;
742  }
743 }
744 
745 /**
746  * Registers the current object as something that can be read from a Bam file.
747  */
751  register_factory(get_class_type(), make_TextureProperties);
752 }
753 
754 /**
755  * Fills the indicated datagram up with a binary representation of the current
756  * object, in preparation for writing to a Bam file.
757  */
759 write_datagram(BamWriter *writer, Datagram &datagram) {
760  TypedWritable::write_datagram(writer, datagram);
761  datagram.add_bool(_got_num_channels);
762  datagram.add_int32(_num_channels);
763  datagram.add_int32(_effective_num_channels);
764  datagram.add_int32((int)_format);
765  datagram.add_bool(_force_format);
766  datagram.add_bool(_generic_format);
767  datagram.add_bool(_keep_format);
768  datagram.add_int32((int)_minfilter);
769  datagram.add_int32((int)_magfilter);
770  datagram.add_int32((int)_quality_level);
771  datagram.add_int32(_anisotropic_degree);
772  writer->write_pointer(datagram, _color_type);
773  writer->write_pointer(datagram, _alpha_type);
774 }
775 
776 /**
777  * Called after the object is otherwise completely read from a Bam file, this
778  * function's job is to store the pointers that were retrieved from the Bam
779  * file for each pointer object written. The return value is the number of
780  * pointers processed from the list.
781  */
784  int index = TypedWritable::complete_pointers(p_list, manager);
785 
786  if (p_list[index] != nullptr) {
787  DCAST_INTO_R(_color_type, p_list[index], index);
788  }
789  index++;
790 
791  if (p_list[index] != nullptr) {
792  DCAST_INTO_R(_alpha_type, p_list[index], index);
793  }
794  index++;
795 
796  return index;
797 }
798 
799 /**
800  * This method is called by the BamReader when an object of this type is
801  * encountered in a Bam file; it should allocate and return a new object with
802  * all the data read.
803  */
804 TypedWritable* TextureProperties::
805 make_TextureProperties(const FactoryParams &params) {
807  DatagramIterator scan;
808  BamReader *manager;
809 
810  parse_params(params, scan, manager);
811  me->fillin(scan, manager);
812  return me;
813 }
814 
815 /**
816  * Reads the binary data from the given datagram iterator, which was written
817  * by a previous call to write_datagram().
818  */
821  TypedWritable::fillin(scan, manager);
822  _got_num_channels = scan.get_bool();
823  _num_channels = scan.get_int32();
824  _effective_num_channels = _num_channels;
825  if (Palettizer::_read_pi_version >= 9) {
826  _effective_num_channels = scan.get_int32();
827  }
828  _format = (EggTexture::Format)scan.get_int32();
829  _force_format = scan.get_bool();
830  _generic_format = false;
831  if (Palettizer::_read_pi_version >= 9) {
832  _generic_format = scan.get_bool();
833  }
834  _keep_format = false;
835  if (Palettizer::_read_pi_version >= 13) {
836  _keep_format = scan.get_bool();
837  }
838  _minfilter = (EggTexture::FilterType)scan.get_int32();
839  _magfilter = (EggTexture::FilterType)scan.get_int32();
840  if (Palettizer::_read_pi_version >= 18) {
841  _quality_level = (EggTexture::QualityLevel)scan.get_int32();
842  }
843  _anisotropic_degree = scan.get_int32();
844 
845  manager->read_pointer(scan); // _color_type
846  manager->read_pointer(scan); // _alpha_type
847 }
void set_num_channels(int num_channels)
Sets the number of channels (1 through 4) associated with the image, presumably after reading this in...
int get_num_channels() const
Returns the number of channels (1 through 4) associated with the image.
bool get_bool()
Extracts a boolean value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:32
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function's job is to store...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
set_anisotropic_degree
Sets the degree of anisotropic filtering for this texture.
Definition: eggTexture.h:323
int32_t get_int32()
Extracts a signed 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
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.
void update_egg_tex(EggTexture *egg_tex) const
Adjusts the texture properties of the indicated egg reference to match these properties.
std::string get_string() const
Returns a string corresponding to the TextureProperties object.
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
void add_bool(bool value)
Adds a boolean value to the datagram.
Definition: datagram.I:34
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().
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 force_nonalpha()
Sets the actual number of channels to indicate an image with no alpha channel, presumably after disco...
bool uses_alpha() const
Returns true if the texture uses an alpha channel, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_num_channels() const
Returns true if the number of channels is known.
void fillin(DatagramIterator &scan, BamReader *manager)
Reads the binary data from the given datagram iterator, which was written by a previous call to write...
void force_grayscale()
Sets the actual number of channels to indicate a grayscale image, presumably after discovering that t...
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
Definition: datagram.I:67
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
bool egg_properties_match(const TextureProperties &other) const
Returns true if all of the properties that are reflected directly in an egg file match between this T...
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition: bamReader.cxx:610
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
void clear_basic()
Resets only the properties that might be changed by update_properties() to a neutral state.
A class to retrieve the individual data elements previously stored in a Datagram.
void update_properties(const TextureProperties &other)
If the indicate TextureProperties structure is more specific than this one, updates this one.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
void fully_define()
If any properties remain unspecified, specify them now.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition: bamWriter.cxx:317
This is the set of characteristics of a texture that, if different from another texture,...