Panda3D
eggTexture.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 eggTexture.cxx
10  * @author drose
11  * @date 1999-01-18
12  */
13 
14 #include "eggTexture.h"
15 #include "eggMiscFuncs.h"
16 #include "lexerDefs.h"
17 
18 #include "indent.h"
19 #include "string_utils.h"
20 
21 using std::ostream;
22 using std::string;
23 
24 TypeHandle EggTexture::_type_handle;
25 
26 
27 /**
28  *
29  */
30 EggTexture::
31 EggTexture(const string &tref_name, const Filename &filename)
32  : EggFilenameNode(tref_name, filename)
33 {
34  _texture_type = TT_unspecified;
35  _format = F_unspecified;
36  _compression_mode = CM_default;
37  _wrap_mode = WM_unspecified;
38  _wrap_u = WM_unspecified;
39  _wrap_v = WM_unspecified;
40  _wrap_w = WM_unspecified;
41  _minfilter = FT_unspecified;
42  _magfilter = FT_unspecified;
43  _anisotropic_degree = 0;
44  _env_type = ET_unspecified;
45  _saved_result = false;
46  _multiview = false;
47  _num_views = 0;
48  _tex_gen = TG_unspecified;
49  _quality_level = QL_unspecified;
50  _priority = 0;
51  _color.set(0.0f, 0.0f, 0.0f, 1.0f);
52  _border_color.set(0.0f, 0.0f, 0.0f, 1.0f);
53  _flags = 0;
54  _alpha_file_channel = 0;
55  _read_mipmaps = false;
56  _multitexture_sort = 0;
57 }
58 
59 /**
60  *
61  */
62 EggTexture::
63 EggTexture(const EggTexture &copy) {
64  (*this) = copy;
65 }
66 
67 /**
68  *
69  */
70 EggTexture &EggTexture::
71 operator = (const EggTexture &copy) {
73 
74  EggFilenameNode::operator = (copy);
75  EggRenderMode::operator = (copy);
76  EggTransform::operator = (copy);
77 
78  _texture_type = copy._texture_type;
79  _format = copy._format;
80  _compression_mode = copy._compression_mode;
81  _wrap_mode = copy._wrap_mode;
82  _wrap_u = copy._wrap_u;
83  _wrap_v = copy._wrap_v;
84  _wrap_w = copy._wrap_w;
85  _minfilter = copy._minfilter;
86  _magfilter = copy._magfilter;
87  _anisotropic_degree = copy._anisotropic_degree;
88  _env_type = copy._env_type;
89  _saved_result = copy._saved_result;
90  _multiview = copy._multiview;
91  _num_views = copy._num_views;
92  _tex_gen = copy._tex_gen;
93  _quality_level = copy._quality_level;
94  _stage_name = copy._stage_name;
95  _priority = copy._priority;
96  _color = copy._color;
97  _border_color = copy._border_color;
98  _uv_name = copy._uv_name;
99  _rgb_scale = 1;
100  _alpha_scale = 1;
101  _flags = copy._flags;
102  _alpha_filename = copy._alpha_filename;
103  _alpha_fullpath = copy._alpha_fullpath;
104  _alpha_file_channel = copy._alpha_file_channel;
105  _read_mipmaps = copy._read_mipmaps;
106  _multitexture_sort = 0;
107  _combiner[0] = copy._combiner[0];
108  _combiner[1] = copy._combiner[1];
109 
110  return *this;
111 }
112 
113 /**
114  *
115  */
116 EggTexture::
117 ~EggTexture() {
119 }
120 
121 /**
122  * Writes the texture definition to the indicated output stream in Egg format.
123  */
125 write(ostream &out, int indent_level) const {
126  write_header(out, indent_level, "<Texture>");
127  enquote_string(out, get_filename(), indent_level + 2) << "\n";
128 
129  if (has_alpha_filename()) {
130  indent(out, indent_level + 2)
131  << "<Scalar> alpha-file { ";
133  out << " }\n";
134  }
135 
136  if (has_alpha_file_channel()) {
137  indent(out, indent_level + 2)
138  << "<Scalar> alpha-file-channel { "
139  << get_alpha_file_channel() << " }\n";
140  }
141 
142  if (get_read_mipmaps()) {
143  indent(out, indent_level + 2)
144  << "<Scalar> read-mipmaps { 1 }\n";
145  }
146 
147  if (get_texture_type() != TT_unspecified) {
148  indent(out, indent_level + 2)
149  << "<Scalar> type { " << get_texture_type() << " }\n";
150  }
151 
152  if (get_format() != F_unspecified) {
153  indent(out, indent_level + 2)
154  << "<Scalar> format { " << get_format() << " }\n";
155  }
156 
157  if (get_compression_mode() != CM_default) {
158  indent(out, indent_level + 2)
159  << "<Scalar> compression { " << get_compression_mode() << " }\n";
160  }
161 
162  if (get_wrap_mode() != WM_unspecified) {
163  indent(out, indent_level + 2)
164  << "<Scalar> wrap { " << get_wrap_mode() << " }\n";
165  }
166 
167  if (get_wrap_u() != WM_unspecified) {
168  indent(out, indent_level + 2)
169  << "<Scalar> wrapu { " << get_wrap_u() << " }\n";
170  }
171 
172  if (get_wrap_v() != WM_unspecified) {
173  indent(out, indent_level + 2)
174  << "<Scalar> wrapv { " << get_wrap_v() << " }\n";
175  }
176 
177  if (get_wrap_w() != WM_unspecified) {
178  indent(out, indent_level + 2)
179  << "<Scalar> wrapw { " << get_wrap_w() << " }\n";
180  }
181 
182  if (get_minfilter() != FT_unspecified) {
183  indent(out, indent_level + 2)
184  << "<Scalar> minfilter { " << get_minfilter() << " }\n";
185  }
186 
187  if (get_magfilter() != FT_unspecified) {
188  indent(out, indent_level + 2)
189  << "<Scalar> magfilter { " << get_magfilter() << " }\n";
190  }
191 
192  if (has_anisotropic_degree()) {
193  indent(out, indent_level + 2)
194  << "<Scalar> anisotropic-degree { " << get_anisotropic_degree() << " }\n";
195  }
196 
197  if (get_env_type() != ET_unspecified) {
198  indent(out, indent_level + 2)
199  << "<Scalar> envtype { " << get_env_type() << " }\n";
200  }
201 
202  for (int ci = 0; ci < (int)CC_num_channels; ci++) {
203  CombineChannel channel = (CombineChannel)ci;
204  if (get_combine_mode(channel) != CM_unspecified) {
205  indent(out, indent_level + 2)
206  << "<Scalar> combine-" << channel
207  << " { " << get_combine_mode(channel) << " }\n";
208  }
209  for (int i = 0; i < (int)CI_num_indices; i++) {
210  if (get_combine_source(channel, i) != CS_unspecified) {
211  indent(out, indent_level + 2)
212  << "<Scalar> combine-" << channel << "-source" << i
213  << " { " << get_combine_source(channel, i) << " }\n";
214  }
215  if (get_combine_operand(channel, i) != CO_unspecified) {
216  indent(out, indent_level + 2)
217  << "<Scalar> combine-" << channel << "-operand" << i
218  << " { " << get_combine_operand(channel, i) << " }\n";
219  }
220  }
221  }
222 
223  if (get_saved_result()) {
224  indent(out, indent_level + 2)
225  << "<Scalar> saved-result { 1 }\n";
226  }
227 
228  if (get_tex_gen() != TG_unspecified) {
229  indent(out, indent_level + 2)
230  << "<Scalar> tex-gen { " << get_tex_gen() << " }\n";
231  }
232 
233  if (get_quality_level() != QL_unspecified) {
234  indent(out, indent_level + 2)
235  << "<Scalar> quality-level { " << get_quality_level() << " }\n";
236  }
237 
238  if (has_stage_name()) {
239  indent(out, indent_level + 2)
240  << "<Scalar> stage-name { " << get_stage_name() << " }\n";
241  }
242 
243  if (has_priority()) {
244  indent(out, indent_level + 2)
245  << "<Scalar> priority { " << get_priority() << " }\n";
246  }
247 
248  if (has_color()) {
249  indent(out, indent_level + 2)
250  << "<Scalar> blendr { " << _color[0] << " }\n";
251  indent(out, indent_level + 2)
252  << "<Scalar> blendg { " << _color[1] << " }\n";
253  indent(out, indent_level + 2)
254  << "<Scalar> blendb { " << _color[2] << " }\n";
255  indent(out, indent_level + 2)
256  << "<Scalar> blenda { " << _color[3] << " }\n";
257  }
258 
259  if (has_border_color()) {
260  indent(out, indent_level + 2)
261  << "<Scalar> borderr { " << _border_color[0] << " }\n";
262  indent(out, indent_level + 2)
263  << "<Scalar> borderg { " << _border_color[1] << " }\n";
264  indent(out, indent_level + 2)
265  << "<Scalar> borderb { " << _border_color[2] << " }\n";
266  indent(out, indent_level + 2)
267  << "<Scalar> bordera { " << _border_color[3] << " }\n";
268  }
269 
270  if (has_uv_name()) {
271  indent(out, indent_level + 2)
272  << "<Scalar> uv-name { " << get_uv_name() << " }\n";
273  }
274 
275  if (has_rgb_scale()) {
276  indent(out, indent_level + 2)
277  << "<Scalar> rgb-scale { " << get_rgb_scale() << " }\n";
278  }
279 
280  if (has_alpha_scale()) {
281  indent(out, indent_level + 2)
282  << "<Scalar> alpha-scale { " << get_alpha_scale() << " }\n";
283  }
284 
285  if (get_multiview()) {
286  indent(out, indent_level + 2)
287  << "<Scalar> multiview { 1 }\n";
288  }
289 
290  if (has_num_views()) {
291  indent(out, indent_level + 2)
292  << "<Scalar> num-views { " << get_num_views() << " }\n";
293  }
294 
295  EggRenderMode::write(out, indent_level + 2);
296 
297  if (has_transform()) {
298  EggTransform::write(out, indent_level + 2, "<Transform>");
299  }
300 
301  indent(out, indent_level) << "}\n";
302 }
303 
304 /**
305  * Returns true if the two textures are equivalent in all relevant properties
306  * (according to eq), false otherwise.
307  *
308  * The Equivalence parameter, eq, should be set to the bitwise OR of the
309  * following properties, according to what you consider relevant:
310  *
311  * EggTexture::E_basename: The basename part of the texture filename, without
312  * the directory prefix *or* the filename extension.
313  *
314  * EggTexture::E_extension: The extension part of the texture filename.
315  *
316  * EggTexture::E_dirname: The directory prefix of the texture filename.
317  *
318  * EggTexture::E_complete_filename: The union of the above three; that is, the
319  * complete filename, with directory, basename, and extension.
320  *
321  * EggTexture::E_transform: The texture matrix.
322  *
323  * EggTexture::E_attributes: All remaining texture attributes (mode, mipmap,
324  * etc.) except TRef name.
325  *
326  * EggTexture::E_tref_name: The TRef name.
327  */
329 is_equivalent_to(const EggTexture &other, int eq) const {
330  if ((eq & E_complete_filename) == E_complete_filename) {
331  // cout << "compared by filename" << endl;
332  if (get_filename() != other.get_filename()) {
333  return false;
334  }
335  } else {
336  // cout << "compared by not complete filename" << endl;
337  const Filename &a = get_filename();
338  const Filename &b = other.get_filename();
339 
340  if (eq & E_basename) {
342  return false;
343  }
344  }
345  if (eq & E_extension) {
346  if (a.get_extension() != b.get_extension()) {
347  return false;
348  }
349  }
350  if (eq & E_dirname) {
351  if (a.get_dirname() != b.get_dirname()) {
352  return false;
353  }
354  }
355  }
356 
357  if (eq & E_transform) {
358  // cout << "compared by transform" << endl;
359  if (transform_is_identity() != other.transform_is_identity()) {
360  return false;
361  }
362 
363  if (has_transform() && other.has_transform()) {
364  if (!get_transform3d().almost_equal(other.get_transform3d(), 0.0001)) {
365  return false;
366  }
367  }
368  }
369 
370  if (eq & E_attributes) {
371  // cout << "compared by attributes" << endl;
372  if (_texture_type != other._texture_type ||
373  _format != other._format ||
374  _compression_mode != other._compression_mode ||
375  _wrap_mode != other._wrap_mode ||
376  _wrap_u != other._wrap_u ||
377  _wrap_v != other._wrap_v ||
378  _wrap_w != other._wrap_w ||
379  _minfilter != other._minfilter ||
380  _magfilter != other._magfilter ||
381  _env_type != other._env_type) {
382  return false;
383  }
384  if (EggRenderMode::operator != (other)) {
385  return false;
386  }
387  }
388 
389  if (eq & E_tref_name) {
390  // cout << "compared by tref_name" << endl;
391  if (get_name() != other.get_name()) {
392  return false;
393  }
394  }
395 
396  return true;
397 }
398 
399 /**
400  * An ordering operator to compare two textures for sorting order. This
401  * imposes an arbitrary ordering useful to identify unique textures, according
402  * to the indicated Equivalence factor. See is_equivalent_to().
403  */
405 sorts_less_than(const EggTexture &other, int eq) const {
406  if ((eq & E_complete_filename) == E_complete_filename) {
407  if (get_filename() != other.get_filename()) {
408  return get_filename() < other.get_filename();
409  }
410  } else {
411  const Filename &a = get_filename();
412  const Filename &b = other.get_filename();
413 
414  if (eq & E_basename) {
417  }
418  }
419  if (eq & E_extension) {
420  if (a.get_extension() != b.get_extension()) {
421  return a.get_extension() < b.get_extension();
422  }
423  }
424  if (eq & E_dirname) {
425  if (a.get_dirname() != b.get_dirname()) {
426  return a.get_dirname() < b.get_dirname();
427  }
428  }
429  }
430 
431  if (eq & E_transform) {
432  bool is_identity = transform_is_identity();
433  bool other_is_identity = other.transform_is_identity();
434  if (is_identity != other_is_identity) {
435  return (int)is_identity < (int)other_is_identity;
436  }
437 
438  if (has_transform() && other.has_transform()) {
439  int compare = get_transform3d().compare_to(other.get_transform3d());
440  if (compare != 0) {
441  return compare < 0;
442  }
443  }
444  }
445 
446  if (eq & E_attributes) {
447  if (_texture_type != other._texture_type) {
448  return (int)_texture_type < (int)other._texture_type;
449  }
450  if (_format != other._format) {
451  return (int)_format < (int)other._format;
452  }
453  if (_compression_mode != other._compression_mode) {
454  return (int)_compression_mode < (int)other._compression_mode;
455  }
456  if (_wrap_mode != other._wrap_mode) {
457  return (int)_wrap_mode < (int)other._wrap_mode;
458  }
459  if (_wrap_u != other._wrap_u) {
460  return (int)_wrap_u < (int)other._wrap_u;
461  }
462  if (_wrap_v != other._wrap_v) {
463  return (int)_wrap_v < (int)other._wrap_v;
464  }
465  if (_wrap_w != other._wrap_w) {
466  return (int)_wrap_w < (int)other._wrap_w;
467  }
468  if (_minfilter != other._minfilter) {
469  return (int)_minfilter < (int)other._minfilter;
470  }
471  if (_magfilter != other._magfilter) {
472  return (int)_magfilter < (int)other._magfilter;
473  }
474  if (_anisotropic_degree != other._anisotropic_degree) {
475  return _anisotropic_degree < other._anisotropic_degree;
476  }
477  if (_env_type != other._env_type) {
478  return (int)_env_type < (int)other._env_type;
479  }
480  if (EggRenderMode::operator != (other)) {
481  return EggRenderMode::operator < (other);
482  }
483  }
484 
485  if (eq & E_tref_name) {
486  if (get_name() != other.get_name()) {
487  return get_name() < other.get_name();
488  }
489  }
490 
491  return false;
492 }
493 
494 /**
495  * Given the number of color components (channels) in the image file as
496  * actually read from the disk, return true if this texture seems to have an
497  * alpha channel or not. This depends on the EggTexture's format as well as
498  * the number of channels.
499  */
501 has_alpha_channel(int num_components) const {
502  switch (_format) {
503  case F_red:
504  case F_green:
505  case F_blue:
506  case F_luminance:
507  case F_rgb:
508  case F_rgb12:
509  case F_rgb8:
510  case F_rgb5:
511  case F_rgb332:
512  case F_srgb:
513  // These formats never use alpha, regardless of the number of components
514  // we have.
515  return false;
516 
517  case F_alpha:
518  // This format always uses alpha.
519  return true;
520 
521  case F_luminance_alpha:
522  case F_luminance_alphamask:
523  case F_rgba:
524  case F_rgbm:
525  case F_rgba12:
526  case F_rgba8:
527  case F_rgba4:
528  case F_rgba5:
529  case F_srgb_alpha:
530  case F_unspecified:
531  // These formats use alpha if the image had alpha.
532  return (num_components == 2 || num_components == 4);
533  }
534 
535  return false;
536 }
537 
538 /**
539  * Returns true if this texture's environment type or combine mode allows the
540  * texture to have an effect on the polygon's alpha values, false otherwise.
541  */
543 affects_polygon_alpha() const {
544  switch (_env_type) {
545  case ET_modulate:
546  case ET_replace:
547  return true;
548 
549  case ET_decal:
550  case ET_blend:
551  case ET_add:
552  case ET_blend_color_scale:
553  case ET_modulate_glow:
554  case ET_modulate_gloss:
555  case ET_normal:
556  case ET_normal_height:
557  case ET_glow:
558  case ET_gloss:
559  case ET_height:
560  case ET_normal_gloss:
561  return false;
562 
563  case ET_selector:
564  return true;
565 
566  case ET_unspecified:
567  break;
568  }
569 
570  switch (_combiner[CC_alpha]._mode) {
571  case CM_replace:
572  case CM_modulate:
573  case CM_add_signed:
574  case CM_subtract:
575  return true;
576 
577  case CM_interpolate:
578  case CM_add:
579  case CM_dot3_rgb:
580  case CM_dot3_rgba:
581  return false;
582 
583  case CM_unspecified:
584  break;
585  }
586 
587  // A completely unspecified texture environment implies "modulate", which
588  // does affect alpha.
589  return true;
590 }
591 
592 
593 /**
594  * Resets the multitexture flags set by multitexture_over(). After this call,
595  * get_multitexture() will return false, and get_multitexture_sort() will
596  * return 0.
597  */
600  _multitexture_sort = 0;
601 
602  // Now empty out the _over_textures and _under_textures sets. This requires
603  // a bit of care so we don't end up in mutual recursion or iterating through
604  // self-modifying structures. To avoid this, we empty the sets first, and
605  // then walk through their original contents.
606  MultiTextures orig_over_textures, orig_under_textures;
607  orig_over_textures.swap(_over_textures);
608  orig_under_textures.swap(_under_textures);
609 
610  MultiTextures::iterator mti;
611  for (mti = orig_over_textures.begin();
612  mti != orig_over_textures.end();
613  ++mti) {
614  EggTexture *other = (*mti);
615  other->_under_textures.erase(this);
616  }
617  for (mti = orig_under_textures.begin();
618  mti != orig_under_textures.end();
619  ++mti) {
620  EggTexture *other = (*mti);
621  other->_over_textures.erase(this);
622  }
623 }
624 
625 /**
626  * Indicates that this texture should be layered on top of the other texture.
627  * This will guarantee that this->get_multitexture_sort() >
628  * other->get_multitexture_sort(), at least until clear_multitexture() is
629  * called on either one.
630  *
631  * The return value is true if successful, or false if there is a failure
632  * because the other texture was already layered on top of this one (or there
633  * is a three- or more-way cycle).
634  */
637  if (get_multitexture_sort() <= other->get_multitexture_sort()) {
638  MultiTextures cycle_detector;
639  if (!r_min_multitexture_sort(other->get_multitexture_sort() + 1,
640  cycle_detector)) {
641  // Found a cycle right off the bat!
642  return false;
643  }
644  }
645 
646  if (_over_textures.insert(other).second) {
647  bool inserted_under = other->_under_textures.insert(this).second;
648  nassertr(inserted_under, false);
649  }
650  nassertr(get_multitexture_sort() > other->get_multitexture_sort(), false);
651 
652  return true;
653 }
654 
655 /**
656  * Returns the Texture_ype value associated with the given string
657  * representation, or TT_unspecified if the string does not match any known
658  * TextureType value.
659  */
660 EggTexture::TextureType EggTexture::
661 string_texture_type(const string &string) {
662  if (cmp_nocase_uh(string, "1d") == 0 ||
663  cmp_nocase_uh(string, "1dtexture") == 0 ||
664  cmp_nocase_uh(string, "1d_texture") == 0) {
665  return TT_1d_texture;
666 
667  } else if (cmp_nocase_uh(string, "2d") == 0 ||
668  cmp_nocase_uh(string, "2dtexture") == 0 ||
669  cmp_nocase_uh(string, "2d_texture") == 0) {
670  return TT_2d_texture;
671 
672  } else if (cmp_nocase_uh(string, "3d") == 0 ||
673  cmp_nocase_uh(string, "3dtexture") == 0 ||
674  cmp_nocase_uh(string, "3d_texture") == 0) {
675  return TT_3d_texture;
676 
677  } else if (cmp_nocase_uh(string, "cube") == 0 ||
678  cmp_nocase_uh(string, "cubemap") == 0 ||
679  cmp_nocase_uh(string, "cube_map") == 0) {
680  return TT_cube_map;
681 
682  } else {
683  return TT_unspecified;
684  }
685 }
686 
687 /**
688  * Returns the Format value associated with the given string representation,
689  * or F_unspecified if the string does not match any known Format value.
690  */
691 EggTexture::Format EggTexture::
692 string_format(const string &string) {
693  if (cmp_nocase_uh(string, "rgba") == 0) {
694  return F_rgba;
695  } else if (cmp_nocase_uh(string, "srgb_alpha") == 0) {
696  return F_srgb_alpha;
697  } else if (cmp_nocase_uh(string, "rgbm") == 0) {
698  return F_rgbm;
699  } else if (cmp_nocase_uh(string, "rgba12") == 0) {
700  return F_rgba12;
701  } else if (cmp_nocase_uh(string, "rgba8") == 0) {
702  return F_rgba8;
703  } else if (cmp_nocase_uh(string, "rgba4") == 0) {
704  return F_rgba4;
705 
706  } else if (cmp_nocase_uh(string, "rgb") == 0) {
707  return F_rgb;
708  } else if (cmp_nocase_uh(string, "srgb") == 0) {
709  return F_srgb;
710  } else if (cmp_nocase_uh(string, "rgb12") == 0) {
711  return F_rgb12;
712  } else if (cmp_nocase_uh(string, "rgb8") == 0) {
713  return F_rgb8;
714  } else if (cmp_nocase_uh(string, "rgb5") == 0) {
715  return F_rgb5;
716  } else if (cmp_nocase_uh(string, "rgba5") == 0) {
717  return F_rgba5;
718  } else if (cmp_nocase_uh(string, "rgb332") == 0) {
719  return F_rgb332;
720  } else if (cmp_nocase_uh(string, "red") == 0) {
721  return F_red;
722  } else if (cmp_nocase_uh(string, "green") == 0) {
723  return F_green;
724  } else if (cmp_nocase_uh(string, "blue") == 0) {
725  return F_blue;
726  } else if (cmp_nocase_uh(string, "alpha") == 0) {
727  return F_alpha;
728  } else if (cmp_nocase_uh(string, "luminance") == 0) {
729  return F_luminance;
730  } else if (cmp_nocase_uh(string, "luminance_alpha") == 0) {
731  return F_luminance_alpha;
732  } else if (cmp_nocase_uh(string, "luminance_alphamask") == 0) {
733  return F_luminance_alphamask;
734  } else {
735  return F_unspecified;
736  }
737 }
738 
739 /**
740  * Returns the CompressionMode value associated with the given string
741  * representation, or CM_default if the string does not match any known
742  * CompressionMode value.
743  */
744 EggTexture::CompressionMode EggTexture::
745 string_compression_mode(const string &string) {
746  if (cmp_nocase_uh(string, "off") == 0) {
747  return CM_off;
748  } else if (cmp_nocase_uh(string, "on") == 0) {
749  return CM_on;
750  } else if (cmp_nocase_uh(string, "fxt1") == 0) {
751  return CM_fxt1;
752  } else if (cmp_nocase_uh(string, "dxt1") == 0) {
753  return CM_dxt1;
754  } else if (cmp_nocase_uh(string, "dxt2") == 0) {
755  return CM_dxt2;
756  } else if (cmp_nocase_uh(string, "dxt3") == 0) {
757  return CM_dxt3;
758  } else if (cmp_nocase_uh(string, "dxt4") == 0) {
759  return CM_dxt4;
760  } else if (cmp_nocase_uh(string, "dxt5") == 0) {
761  return CM_dxt5;
762  } else {
763  return CM_default;
764  }
765 }
766 
767 /**
768  * Returns the WrapMode value associated with the given string representation,
769  * or WM_unspecified if the string does not match any known WrapMode value.
770  */
771 EggTexture::WrapMode EggTexture::
772 string_wrap_mode(const string &string) {
773  if (cmp_nocase_uh(string, "repeat") == 0) {
774  return WM_repeat;
775  } else if (cmp_nocase_uh(string, "clamp") == 0) {
776  return WM_clamp;
777  } else if (cmp_nocase_uh(string, "mirror") == 0) {
778  return WM_mirror;
779  } else if (cmp_nocase_uh(string, "mirror_once") == 0) {
780  return WM_mirror_once;
781  } else if (cmp_nocase_uh(string, "border_color") == 0) {
782  return WM_border_color;
783  } else {
784  return WM_unspecified;
785  }
786 }
787 
788 /**
789  * Returns the FilterType value associated with the given string
790  * representation, or FT_unspecified if the string does not match any known
791  * FilterType value.
792  */
793 EggTexture::FilterType EggTexture::
794 string_filter_type(const string &string) {
795  // Old egg filter types.
796  if (cmp_nocase_uh(string, "point") == 0) {
797  return FT_nearest;
798  } else if (cmp_nocase_uh(string, "linear") == 0) {
799  return FT_linear;
800  } else if (cmp_nocase_uh(string, "bilinear") == 0) {
801  return FT_linear;
802  } else if (cmp_nocase_uh(string, "trilinear") == 0) {
803  return FT_linear_mipmap_linear;
804  } else if (cmp_nocase_uh(string, "mipmap") == 0) {
805  return FT_linear_mipmap_linear;
806  } else if (cmp_nocase_uh(string, "mipmap_point") == 0) {
807  return FT_nearest_mipmap_nearest;
808  } else if (cmp_nocase_uh(string, "mipmap_linear") == 0) {
809  return FT_nearest_mipmap_linear;
810  } else if (cmp_nocase_uh(string, "mipmap_bilinear") == 0) {
811  return FT_linear_mipmap_nearest;
812  } else if (cmp_nocase_uh(string, "mipmap_trilinear") == 0) {
813  return FT_linear_mipmap_linear;
814 
815  // Current egg filter types, that match those in Texture.
816  } else if (cmp_nocase_uh(string, "nearest") == 0) {
817  return FT_nearest;
818  } else if (cmp_nocase_uh(string, "linear") == 0) {
819  return FT_linear;
820  } else if (cmp_nocase_uh(string, "nearest_mipmap_nearest") == 0) {
821  return FT_nearest_mipmap_nearest;
822  } else if (cmp_nocase_uh(string, "linear_mipmap_nearest") == 0) {
823  return FT_linear_mipmap_nearest;
824  } else if (cmp_nocase_uh(string, "nearest_mipmap_linear") == 0) {
825  return FT_nearest_mipmap_linear;
826  } else if (cmp_nocase_uh(string, "linear_mipmap_linear") == 0) {
827  return FT_linear_mipmap_linear;
828 
829  } else {
830  return FT_unspecified;
831  }
832 }
833 
834 /**
835  * Returns the EnvType value associated with the given string representation,
836  * or ET_unspecified if the string does not match any known EnvType value.
837  */
838 EggTexture::EnvType EggTexture::
839 string_env_type(const string &string) {
840  if (cmp_nocase_uh(string, "modulate") == 0) {
841  return ET_modulate;
842 
843  } else if (cmp_nocase_uh(string, "decal") == 0) {
844  return ET_decal;
845 
846  } else if (cmp_nocase_uh(string, "blend") == 0) {
847  return ET_blend;
848 
849  } else if (cmp_nocase_uh(string, "replace") == 0) {
850  return ET_replace;
851 
852  } else if (cmp_nocase_uh(string, "add") == 0) {
853  return ET_add;
854 
855  } else if (cmp_nocase_uh(string, "blend_color_scale") == 0) {
856  return ET_blend_color_scale;
857 
858  } else if (cmp_nocase_uh(string, "modulate_glow") == 0) {
859  return ET_modulate_glow;
860 
861  } else if (cmp_nocase_uh(string, "modulate_gloss") == 0) {
862  return ET_modulate_gloss;
863 
864  } else if (cmp_nocase_uh(string, "normal") == 0) {
865  return ET_normal;
866 
867  } else if (cmp_nocase_uh(string, "normal_height") == 0) {
868  return ET_normal_height;
869 
870  } else if (cmp_nocase_uh(string, "glow") == 0) {
871  return ET_glow;
872 
873  } else if (cmp_nocase_uh(string, "gloss") == 0) {
874  return ET_gloss;
875 
876  } else if (cmp_nocase_uh(string, "height") == 0) {
877  return ET_height;
878 
879  } else if (cmp_nocase_uh(string, "selector") == 0) {
880  return ET_selector;
881 
882  } else if (cmp_nocase_uh(string, "normal_gloss") == 0) {
883  return ET_normal_gloss;
884 
885  } else {
886  return ET_unspecified;
887  }
888 }
889 
890 /**
891  * Returns the CombineMode value associated with the given string
892  * representation, or CM_unspecified if the string does not match any known
893  * CombineMode value.
894  */
895 EggTexture::CombineMode EggTexture::
896 string_combine_mode(const string &string) {
897  if (cmp_nocase_uh(string, "replace") == 0) {
898  return CM_replace;
899 
900  } else if (cmp_nocase_uh(string, "modulate") == 0) {
901  return CM_modulate;
902 
903  } else if (cmp_nocase_uh(string, "add") == 0) {
904  return CM_add;
905 
906  } else if (cmp_nocase_uh(string, "add_signed") == 0) {
907  return CM_add_signed;
908 
909  } else if (cmp_nocase_uh(string, "interpolate") == 0) {
910  return CM_interpolate;
911 
912  } else if (cmp_nocase_uh(string, "subtract") == 0) {
913  return CM_subtract;
914 
915  } else if (cmp_nocase_uh(string, "dot3_rgb") == 0) {
916  return CM_dot3_rgb;
917 
918  } else if (cmp_nocase_uh(string, "dot3_rgba") == 0) {
919  return CM_dot3_rgba;
920 
921  } else {
922  return CM_unspecified;
923  }
924 }
925 
926 /**
927  * Returns the CombineSource value associated with the given string
928  * representation, or CS_unspecified if the string does not match any known
929  * CombineSource value.
930  */
931 EggTexture::CombineSource EggTexture::
932 string_combine_source(const string &string) {
933  if (cmp_nocase_uh(string, "texture") == 0) {
934  return CS_texture;
935 
936  } else if (cmp_nocase_uh(string, "constant") == 0) {
937  return CS_constant;
938 
939  } else if (cmp_nocase_uh(string, "primary_color") == 0) {
940  return CS_primary_color;
941 
942  } else if (cmp_nocase_uh(string, "previous") == 0) {
943  return CS_previous;
944 
945  } else if (cmp_nocase_uh(string, "constant_color_scale") == 0) {
946  return CS_constant_color_scale;
947 
948  } else if (cmp_nocase_uh(string, "last_saved_result") == 0) {
949  return CS_last_saved_result;
950 
951  } else {
952  return CS_unspecified;
953  }
954 }
955 
956 /**
957  * Returns the CombineOperand value associated with the given string
958  * representation, or CO_unspecified if the string does not match any known
959  * CombineOperand value.
960  */
961 EggTexture::CombineOperand EggTexture::
962 string_combine_operand(const string &string) {
963  if (cmp_nocase_uh(string, "src_color") == 0) {
964  return CO_src_color;
965 
966  } else if (cmp_nocase_uh(string, "one_minus_src_color") == 0) {
967  return CO_one_minus_src_color;
968 
969  } else if (cmp_nocase_uh(string, "src_alpha") == 0) {
970  return CO_src_alpha;
971 
972  } else if (cmp_nocase_uh(string, "one_minus_src_alpha") == 0) {
973  return CO_one_minus_src_alpha;
974 
975  } else {
976  return CO_unspecified;
977  }
978 }
979 
980 /**
981  * Returns the TexGen value associated with the given string representation,
982  * or ET_unspecified if the string does not match any known TexGen value.
983  */
984 EggTexture::TexGen EggTexture::
985 string_tex_gen(const string &string) {
986  if (cmp_nocase_uh(string, "unspecified") == 0) {
987  return TG_unspecified;
988 
989  } else if (cmp_nocase_uh(string, "sphere_map") == 0 ||
990  cmp_nocase_uh(string, "eye_sphere_map") == 0) {
991  return TG_eye_sphere_map;
992 
993  } else if (cmp_nocase_uh(string, "world_cube_map") == 0) {
994  return TG_world_cube_map;
995 
996  } else if (cmp_nocase_uh(string, "cube_map") == 0 ||
997  cmp_nocase_uh(string, "eye_cube_map") == 0) {
998  return TG_eye_cube_map;
999 
1000  } else if (cmp_nocase_uh(string, "world_normal") == 0) {
1001  return TG_world_normal;
1002 
1003  } else if (cmp_nocase_uh(string, "eye_normal") == 0) {
1004  return TG_eye_normal;
1005 
1006  } else if (cmp_nocase_uh(string, "world_position") == 0) {
1007  return TG_world_position;
1008 
1009  } else if (cmp_nocase_uh(string, "eye_position") == 0) {
1010  return TG_eye_position;
1011 
1012  } else if (cmp_nocase_uh(string, "point_sprite") == 0) {
1013  return TG_point_sprite;
1014 
1015  } else {
1016  return TG_unspecified;
1017  }
1018 }
1019 
1020 /**
1021  * Returns the TexGen value associated with the given string representation,
1022  * or ET_unspecified if the string does not match any known TexGen value.
1023  */
1024 EggTexture::QualityLevel EggTexture::
1025 string_quality_level(const string &string) {
1026  if (cmp_nocase_uh(string, "unspecified") == 0) {
1027  return QL_unspecified;
1028 
1029  } else if (cmp_nocase_uh(string, "default") == 0) {
1030  return QL_default;
1031 
1032  } else if (cmp_nocase_uh(string, "fastest") == 0) {
1033  return QL_fastest;
1034 
1035  } else if (cmp_nocase_uh(string, "normal") == 0) {
1036  return QL_normal;
1037 
1038  } else if (cmp_nocase_uh(string, "best") == 0) {
1039  return QL_best;
1040 
1041  } else {
1042  return QL_unspecified;
1043  }
1044 }
1045 
1046 /**
1047  * Returns this object cross-cast to an EggTransform pointer, if it inherits
1048  * from EggTransform, or NULL if it does not.
1049  */
1051 as_transform() {
1052  return this;
1053 }
1054 
1055 /**
1056  * This function is called within parse_egg(). It should call the appropriate
1057  * function on the lexer to initialize the parser into the state associated
1058  * with this object. If the object cannot be parsed into directly, it should
1059  * return false.
1060  */
1061 bool EggTexture::
1062 egg_start_parse_body() {
1063  egg_start_texture_body();
1064  return true;
1065 }
1066 
1067 /**
1068  * Ensures that our multitexture_sort is at least the indicated value.
1069  */
1070 bool EggTexture::
1071 r_min_multitexture_sort(int sort, EggTexture::MultiTextures &cycle_detector) {
1072  if (_multitexture_sort >= sort) {
1073  // No problem.
1074  return true;
1075  }
1076 
1077  if (!cycle_detector.insert(this).second) {
1078  // Oops, we just hit a cycle!
1079  return false;
1080  }
1081 
1082  _multitexture_sort = sort;
1083 
1084  // Now we also have to increment all of the textures that we are under.
1085  bool no_cycles = true;
1086 
1087  MultiTextures::iterator mti;
1088  for (mti = _under_textures.begin();
1089  mti != _under_textures.end();
1090  ++mti) {
1091  EggTexture *other = (*mti);
1092  if (!other->r_min_multitexture_sort(sort + 1, cycle_detector)) {
1093  // Oops, found a cycle!
1094  no_cycles = false;
1095  }
1096  }
1097 
1098  return no_cycles;
1099 }
1100 
1101 
1102 /**
1103  *
1104  */
1105 ostream &operator << (ostream &out, EggTexture::TextureType texture_type) {
1106  switch (texture_type) {
1107  case EggTexture::TT_unspecified:
1108  return out << "unspecified";
1109 
1110  case EggTexture::TT_1d_texture:
1111  return out << "1d";
1112 
1113  case EggTexture::TT_2d_texture:
1114  return out << "2d";
1115 
1116  case EggTexture::TT_3d_texture:
1117  return out << "3d";
1118 
1119  case EggTexture::TT_cube_map:
1120  return out << "cube-map";
1121  }
1122 
1123  nassertr(false, out);
1124  return out << "(**invalid**)";
1125 }
1126 
1127 
1128 /**
1129  *
1130  */
1131 ostream &operator << (ostream &out, EggTexture::Format format) {
1132  switch (format) {
1133  case EggTexture::F_unspecified:
1134  return out << "unspecified";
1135 
1136  case EggTexture::F_rgba:
1137  return out << "rgba";
1138  case EggTexture::F_rgbm:
1139  return out << "rgbm";
1140  case EggTexture::F_rgba12:
1141  return out << "rgba12";
1142  case EggTexture::F_rgba8:
1143  return out << "rgba8";
1144  case EggTexture::F_rgba4:
1145  return out << "rgba4";
1146  case EggTexture::F_srgb_alpha:
1147  return out << "srgb_alpha";
1148 
1149  case EggTexture::F_rgb:
1150  return out << "rgb";
1151  case EggTexture::F_rgb12:
1152  return out << "rgb12";
1153  case EggTexture::F_rgb8:
1154  return out << "rgb8";
1155  case EggTexture::F_rgb5:
1156  return out << "rgb5";
1157  case EggTexture::F_rgba5:
1158  return out << "rgba5";
1159  case EggTexture::F_rgb332:
1160  return out << "rgb332";
1161  case EggTexture::F_srgb:
1162  return out << "srgb";
1163 
1164  case EggTexture::F_red:
1165  return out << "red";
1166  case EggTexture::F_green:
1167  return out << "green";
1168  case EggTexture::F_blue:
1169  return out << "blue";
1170  case EggTexture::F_alpha:
1171  return out << "alpha";
1172  case EggTexture::F_luminance:
1173  return out << "luminance";
1174  case EggTexture::F_luminance_alpha:
1175  return out << "luminance_alpha";
1176  case EggTexture::F_luminance_alphamask:
1177  return out << "luminance_alphamask";
1178  }
1179 
1180  nassertr(false, out);
1181  return out << "(**invalid**)";
1182 }
1183 
1184 /**
1185  *
1186  */
1187 ostream &operator << (ostream &out, EggTexture::CompressionMode mode) {
1188  switch (mode) {
1189  case EggTexture::CM_default:
1190  return out << "default";
1191  case EggTexture::CM_off:
1192  return out << "off";
1193  case EggTexture::CM_on:
1194  return out << "on";
1195  case EggTexture::CM_fxt1:
1196  return out << "fxt1";
1197  case EggTexture::CM_dxt1:
1198  return out << "dxt1";
1199  case EggTexture::CM_dxt2:
1200  return out << "dxt2";
1201  case EggTexture::CM_dxt3:
1202  return out << "dxt3";
1203  case EggTexture::CM_dxt4:
1204  return out << "dxt4";
1205  case EggTexture::CM_dxt5:
1206  return out << "dxt5";
1207  }
1208 
1209  nassertr(false, out);
1210  return out << "(**invalid**)";
1211 }
1212 
1213 /**
1214  *
1215  */
1216 ostream &operator << (ostream &out, EggTexture::WrapMode mode) {
1217  switch (mode) {
1218  case EggTexture::WM_unspecified:
1219  return out << "unspecified";
1220  case EggTexture::WM_repeat:
1221  return out << "repeat";
1222  case EggTexture::WM_clamp:
1223  return out << "clamp";
1224  case EggTexture::WM_mirror:
1225  return out << "mirror";
1226  case EggTexture::WM_mirror_once:
1227  return out << "mirror_once";
1228  case EggTexture::WM_border_color:
1229  return out << "border_color";
1230  }
1231 
1232  nassertr(false, out);
1233  return out << "(**invalid**)";
1234 }
1235 
1236 /**
1237  *
1238  */
1239 ostream &operator << (ostream &out, EggTexture::FilterType type) {
1240  switch (type) {
1241  case EggTexture::FT_unspecified:
1242  return out << "unspecified";
1243 
1244  case EggTexture::FT_nearest:
1245  return out << "nearest";
1246  case EggTexture::FT_linear:
1247  return out << "linear";
1248 
1249  case EggTexture::FT_nearest_mipmap_nearest:
1250  return out << "nearest_mipmap_nearest";
1251  case EggTexture::FT_linear_mipmap_nearest:
1252  return out << "linear_mipmap_nearest";
1253  case EggTexture::FT_nearest_mipmap_linear:
1254  return out << "nearest_mipmap_linear";
1255  case EggTexture::FT_linear_mipmap_linear:
1256  return out << "linear_mipmap_linear";
1257  }
1258 
1259  nassertr(false, out);
1260  return out << "(**invalid**)";
1261 }
1262 
1263 /**
1264  *
1265  */
1266 ostream &operator << (ostream &out, EggTexture::EnvType type) {
1267  switch (type) {
1268  case EggTexture::ET_unspecified:
1269  return out << "unspecified";
1270 
1271  case EggTexture::ET_modulate:
1272  return out << "modulate";
1273 
1274  case EggTexture::ET_decal:
1275  return out << "decal";
1276 
1277  case EggTexture::ET_blend:
1278  return out << "blend";
1279 
1280  case EggTexture::ET_replace:
1281  return out << "replace";
1282 
1283  case EggTexture::ET_add:
1284  return out << "add";
1285 
1286  case EggTexture::ET_blend_color_scale:
1287  return out << "blend_color_scale";
1288 
1289  case EggTexture::ET_modulate_glow:
1290  return out << "modulate_glow";
1291 
1292  case EggTexture::ET_modulate_gloss:
1293  return out << "modulate_gloss";
1294 
1295  case EggTexture::ET_normal:
1296  return out << "normal";
1297 
1298  case EggTexture::ET_normal_height:
1299  return out << "normal_height";
1300 
1301  case EggTexture::ET_glow:
1302  return out << "glow";
1303 
1304  case EggTexture::ET_gloss:
1305  return out << "gloss";
1306 
1307  case EggTexture::ET_height:
1308  return out << "height";
1309 
1310  case EggTexture::ET_selector:
1311  return out << "selector";
1312 
1313  case EggTexture::ET_normal_gloss:
1314  return out << "normal_gloss";
1315  }
1316 
1317  nassertr(false, out);
1318  return out << "(**invalid**)";
1319 }
1320 
1321 ostream &
1322 operator << (ostream &out, EggTexture::CombineMode cm) {
1323  switch (cm) {
1324  case EggTexture::CM_unspecified:
1325  return out << "unspecified";
1326 
1327  case EggTexture::CM_replace:
1328  return out << "replace";
1329 
1330  case EggTexture::CM_modulate:
1331  return out << "modulate";
1332 
1333  case EggTexture::CM_add:
1334  return out << "add";
1335 
1336  case EggTexture::CM_add_signed:
1337  return out << "add_signed";
1338 
1339  case EggTexture::CM_interpolate:
1340  return out << "interpolate";
1341 
1342  case EggTexture::CM_subtract:
1343  return out << "subtract";
1344 
1345  case EggTexture::CM_dot3_rgb:
1346  return out << "dot3_rgb";
1347 
1348  case EggTexture::CM_dot3_rgba:
1349  return out << "dot3_rgba";
1350  }
1351 
1352  return out << "**invalid CombineMode(" << (int)cm << ")**";
1353 }
1354 
1355 ostream &
1356 operator << (ostream &out, EggTexture::CombineChannel cm) {
1357  switch (cm) {
1358  case EggTexture::CC_rgb:
1359  return out << "rgb";
1360 
1361  case EggTexture::CC_alpha:
1362  return out << "alpha";
1363 
1364  case EggTexture::CC_num_channels:
1365  // This case is here just to prevent a compiler warning. Fall out of the
1366  // switch and return the error message.
1367  break;
1368  }
1369 
1370  return out << "**invalid CombineChannel(" << (int)cm << ")**";
1371 }
1372 
1373 ostream &
1374 operator << (ostream &out, EggTexture::CombineSource cs) {
1375  switch (cs) {
1376  case EggTexture::CS_unspecified:
1377  return out << "unspecified";
1378 
1379  case EggTexture::CS_texture:
1380  return out << "texture";
1381 
1382  case EggTexture::CS_constant:
1383  return out << "constant";
1384 
1385  case EggTexture::CS_primary_color:
1386  return out << "primary_color";
1387 
1388  case EggTexture::CS_previous:
1389  return out << "previous";
1390 
1391  case EggTexture::CS_constant_color_scale:
1392  return out << "constant_color_scale";
1393 
1394  case EggTexture::CS_last_saved_result:
1395  return out << "last_saved_result";
1396  }
1397 
1398  return out << "**invalid CombineSource(" << (int)cs << ")**";
1399 }
1400 
1401 ostream &
1402 operator << (ostream &out, EggTexture::CombineOperand co) {
1403  switch (co) {
1404  case EggTexture::CO_unspecified:
1405  return out << "unspecified";
1406 
1407  case EggTexture::CO_src_color:
1408  return out << "src_color";
1409 
1410  case EggTexture::CO_one_minus_src_color:
1411  return out << "one_minus_src_color";
1412 
1413  case EggTexture::CO_src_alpha:
1414  return out << "src_alpha";
1415 
1416  case EggTexture::CO_one_minus_src_alpha:
1417  return out << "one_minus_src_alpha";
1418  }
1419 
1420  return out << "**invalid CombineOperand(" << (int)co << ")**";
1421 }
1422 
1423 ostream &
1424 operator << (ostream &out, EggTexture::TexGen tex_gen) {
1425  switch (tex_gen) {
1426  case EggTexture::TG_unspecified:
1427  return out << "unspecified";
1428 
1429  case EggTexture::TG_eye_sphere_map:
1430  return out << "eye_sphere_map";
1431 
1432  case EggTexture::TG_world_cube_map:
1433  return out << "world_cube_map";
1434 
1435  case EggTexture::TG_eye_cube_map:
1436  return out << "eye_cube_map";
1437 
1438  case EggTexture::TG_world_normal:
1439  return out << "world_normal";
1440 
1441  case EggTexture::TG_eye_normal:
1442  return out << "eye_normal";
1443 
1444  case EggTexture::TG_world_position:
1445  return out << "world_position";
1446 
1447  case EggTexture::TG_eye_position:
1448  return out << "eye_position";
1449 
1450  case EggTexture::TG_point_sprite:
1451  return out << "point_sprite";
1452  }
1453 
1454  return out << "**invalid TexGen(" << (int)tex_gen << ")**";
1455 }
1456 
1457 ostream &
1458 operator << (ostream &out, EggTexture::QualityLevel quality_level) {
1459  switch (quality_level) {
1460  case EggTexture::QL_unspecified:
1461  return out << "unspecified";
1462  case EggTexture::QL_default:
1463  return out << "default";
1464  case EggTexture::QL_fastest:
1465  return out << "fastest";
1466  case EggTexture::QL_normal:
1467  return out << "normal";
1468  case EggTexture::QL_best:
1469  return out << "best";
1470  }
1471 
1472  return out << "**invalid QualityLevel(" << (int)quality_level << ")**";
1473 }
EggFilenameNode
This is an egg node that contains a filename.
Definition: eggFilenameNode.h:27
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
EggTexture::sorts_less_than
bool sorts_less_than(const EggTexture &other, int eq) const
An ordering operator to compare two textures for sorting order.
Definition: eggTexture.cxx:405
EggTexture::get_wrap_v
get_wrap_v
Returns the amount specified for V wrap.
Definition: eggTexture.h:321
EggTexture::get_alpha_filename
get_alpha_filename
Returns the separate file assigned for the alpha channel.
Definition: eggTexture.h:346
EggTransform::write
void write(std::ostream &out, int indent_level, const std::string &label) const
Writes the transform to the indicated stream in Egg format.
Definition: eggTransform.cxx:189
EggTexture::get_alpha_scale
get_alpha_scale
Returns the alpha_scale value that has been specified for the texture, or 1 if no alpha_scale value h...
Definition: eggTexture.h:344
Filename::get_dirname
std::string get_dirname() const
Returns the directory part of the filename.
Definition: filename.I:358
string_utils.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTexture::get_priority
get_priority
Returns the multitexture importance value that has been specified for the texture,...
Definition: eggTexture.h:334
EggTexture::string_filter_type
static FilterType string_filter_type(const std::string &string)
Returns the FilterType value associated with the given string representation, or FT_unspecified if th...
Definition: eggTexture.cxx:794
EggTexture::string_texture_type
static TextureType string_texture_type(const std::string &string)
Returns the Texture_ype value associated with the given string representation, or TT_unspecified if t...
Definition: eggTexture.cxx:661
EggTransform::get_transform3d
const LMatrix4d & get_transform3d() const
Returns the overall transform as a 4x4 matrix.
Definition: eggTransform.I:212
EggTexture::has_alpha_file_channel
has_alpha_file_channel
Returns true if a particular channel has been specified for the alpha-file image, false otherwise.
Definition: eggTexture.h:349
EggTexture::has_uv_name
has_uv_name
Returns true if a texcoord name has been explicitly specified for this texture, false otherwise.
Definition: eggTexture.h:340
EggTexture::string_tex_gen
static TexGen string_tex_gen(const std::string &string)
Returns the TexGen value associated with the given string representation, or ET_unspecified if the st...
Definition: eggTexture.cxx:985
Filename::get_basename_wo_extension
std::string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
Definition: filename.I:386
EggTransform::transform_is_identity
bool transform_is_identity() const
Returns true if the described transform is identity, false otherwise.
Definition: eggTransform.I:220
EggTexture::string_combine_operand
static CombineOperand string_combine_operand(const std::string &string)
Returns the CombineOperand value associated with the given string representation, or CO_unspecified i...
Definition: eggTexture.cxx:962
enquote_string
ostream & enquote_string(ostream &out, const string &str, int indent_level, bool always_quote)
Writes the string to the indicated output stream.
Definition: eggMiscFuncs.cxx:30
EggTexture::write
virtual void write(std::ostream &out, int indent_level) const
Writes the texture definition to the indicated output stream in Egg format.
Definition: eggTexture.cxx:125
EggTexture::is_equivalent_to
bool is_equivalent_to(const EggTexture &other, int eq) const
Returns true if the two textures are equivalent in all relevant properties (according to eq),...
Definition: eggTexture.cxx:329
eggTexture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTexture::get_saved_result
get_saved_result
Returns the current setting of the saved_result flag.
Definition: eggTexture.h:328
EggFilenameNode::get_filename
const Filename & get_filename() const
Returns a nonmodifiable reference to the filename.
Definition: eggFilenameNode.I:58
EggTexture::has_alpha_channel
bool has_alpha_channel(int num_components) const
Given the number of color components (channels) in the image file as actually read from the disk,...
Definition: eggTexture.cxx:501
EggRenderMode::write
void write(std::ostream &out, int indent_level) const
Writes the attributes to the indicated output stream in Egg format.
Definition: eggRenderMode.cxx:60
EggTexture::get_multiview
get_multiview
Returns the current setting of the multiview flag.
Definition: eggTexture.h:350
EggTexture::get_multitexture_sort
get_multitexture_sort
Returns an integer that represents the depth to which this texture is layered on all other textures i...
Definition: eggTexture.h:361
EggTexture::get_wrap_w
get_wrap_w
Returns the amount specified for W wrap.
Definition: eggTexture.h:322
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
EggNamedObject::write_header
void write_header(std::ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
Definition: eggNamedObject.cxx:39
EggTexture::string_compression_mode
static CompressionMode string_compression_mode(const std::string &string)
Returns the CompressionMode value associated with the given string representation,...
Definition: eggTexture.cxx:745
EggTexture::get_alpha_file_channel
get_alpha_file_channel
Returns the particular channel that has been specified for the alpha-file image, or 0 if no channel h...
Definition: eggTexture.h:349
EggTexture::has_priority
has_priority
Returns true if a priority value for multitexture importance has been specified for the texture,...
Definition: eggTexture.h:334
EggTexture::get_num_views
get_num_views
Returns the specified number of views specified for the 3-D multiview texture.
Definition: eggTexture.h:352
EggTexture::get_read_mipmaps
get_read_mipmaps
Returns the current setting of the read_mipmaps flag.
Definition: eggTexture.h:353
EggTexture::has_num_views
has_num_views
Returns true if the number of views has been specified for the 3-D multiview texture,...
Definition: eggTexture.h:352
EggTexture::get_rgb_scale
get_rgb_scale
Returns the rgb_scale value that has been specified for the texture, or 1 if no rgb_scale value has b...
Definition: eggTexture.h:342
EggTexture::has_alpha_scale
has_alpha_scale
Returns true if an alpha_scale has been specified for the texture, false otherwise.
Definition: eggTexture.h:344
EggTexture::get_stage_name
get_stage_name
Returns the stage name that has been specified for this texture, or the tref name if no texture stage...
Definition: eggTexture.h:332
EggTexture::get_uv_name
get_uv_name
Returns the texcoord name that has been specified for this texture, or the empty string if no texcoor...
Definition: eggTexture.h:340
EggTexture::string_combine_mode
static CombineMode string_combine_mode(const std::string &string)
Returns the CombineMode value associated with the given string representation, or CM_unspecified if t...
Definition: eggTexture.cxx:896
EggTexture::string_combine_source
static CombineSource string_combine_source(const std::string &string)
Returns the CombineSource value associated with the given string representation, or CS_unspecified if...
Definition: eggTexture.cxx:932
EggTexture::multitexture_over
bool multitexture_over(EggTexture *other)
Indicates that this texture should be layered on top of the other texture.
Definition: eggTexture.cxx:636
EggTexture::has_alpha_filename
has_alpha_filename
Returns true if a separate file for the alpha component has been applied, false otherwise.
Definition: eggTexture.h:346
EggTexture::has_border_color
has_border_color
Returns true if a border color has been specified for the texture.
Definition: eggTexture.h:338
eggMiscFuncs.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTexture::has_color
has_color
Returns true if a blend color has been specified for the texture.
Definition: eggTexture.h:336
EggTexture::clear_multitexture
void clear_multitexture()
Resets the multitexture flags set by multitexture_over().
Definition: eggTexture.cxx:599
EggTexture
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
EggTransform::has_transform
bool has_transform() const
Returns true if the transform is nonempty, false if it is empty (no transform components have been ad...
Definition: eggTransform.I:143
EggTexture::get_wrap_u
get_wrap_u
Returns the amount specified for U wrap.
Definition: eggTexture.h:320
EggTexture::string_quality_level
static QualityLevel string_quality_level(const std::string &string)
Returns the TexGen value associated with the given string representation, or ET_unspecified if the st...
Definition: eggTexture.cxx:1025
EggTexture::string_wrap_mode
static WrapMode string_wrap_mode(const std::string &string)
Returns the WrapMode value associated with the given string representation, or WM_unspecified if the ...
Definition: eggTexture.cxx:772
indent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTexture::as_transform
virtual EggTransform * as_transform()
Returns this object cross-cast to an EggTransform pointer, if it inherits from EggTransform,...
Definition: eggTexture.cxx:1051
EggTexture::has_stage_name
has_stage_name
Returns true if a stage name has been explicitly specified for this texture, false otherwise.
Definition: eggTexture.h:332
EggTexture::get_anisotropic_degree
get_anisotropic_degree
Returns the anisotropic filtering degree that has been specified for this texture,...
Definition: eggTexture.h:326
EggTexture::has_anisotropic_degree
has_anisotropic_degree
Returns true if a value for the anisotropic filtering degree has been specified for this texture,...
Definition: eggTexture.h:326
EggTexture::string_env_type
static EnvType string_env_type(const std::string &string)
Returns the EnvType value associated with the given string representation, or ET_unspecified if the s...
Definition: eggTexture.cxx:839
EggTexture::affects_polygon_alpha
bool affects_polygon_alpha() const
Returns true if this texture's environment type or combine mode allows the texture to have an effect ...
Definition: eggTexture.cxx:543
EggTexture::string_format
static Format string_format(const std::string &string)
Returns the Format value associated with the given string representation, or F_unspecified if the str...
Definition: eggTexture.cxx:692
lexerDefs.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Filename::get_extension
std::string get_extension() const
Returns the file extension.
Definition: filename.I:400
EggTexture::has_rgb_scale
has_rgb_scale
Returns true if an rgb_scale has been specified for the texture, false otherwise.
Definition: eggTexture.h:342
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
pset< EggTexture * >
EggTransform
This represents the <Transform> entry of a group or texture node: a list of component transform opera...
Definition: eggTransform.h:29