15 #include "eggTexture.h"
16 #include "eggMiscFuncs.h"
17 #include "lexerDefs.h"
20 #include "string_utils.h"
31 EggTexture(
const string &tref_name,
const Filename &filename)
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;
48 _tex_gen = TG_unspecified;
49 _quality_level = QL_unspecified;
51 _color.set(0.0f, 0.0f, 0.0f, 1.0f);
52 _border_color.set(0.0f, 0.0f, 0.0f, 1.0f);
54 _alpha_file_channel = 0;
55 _read_mipmaps =
false;
56 _multitexture_sort = 0;
78 EggFilenameNode::operator = (copy);
79 EggRenderMode::operator = (copy);
80 EggTransform::operator = (copy);
82 _texture_type = copy._texture_type;
83 _format = copy._format;
84 _compression_mode = copy._compression_mode;
85 _wrap_mode = copy._wrap_mode;
86 _wrap_u = copy._wrap_u;
87 _wrap_v = copy._wrap_v;
88 _wrap_w = copy._wrap_w;
89 _minfilter = copy._minfilter;
90 _magfilter = copy._magfilter;
91 _anisotropic_degree = copy._anisotropic_degree;
92 _env_type = copy._env_type;
93 _saved_result = copy._saved_result;
94 _multiview = copy._multiview;
95 _num_views = copy._num_views;
96 _tex_gen = copy._tex_gen;
97 _quality_level = copy._quality_level;
98 _stage_name = copy._stage_name;
99 _priority = copy._priority;
100 _color = copy._color;
101 _border_color = copy._border_color;
102 _uv_name = copy._uv_name;
105 _flags = copy._flags;
106 _alpha_filename = copy._alpha_filename;
107 _alpha_fullpath = copy._alpha_fullpath;
108 _alpha_file_channel = copy._alpha_file_channel;
109 _read_mipmaps = copy._read_mipmaps;
110 _multitexture_sort = 0;
111 _combiner[0] = copy._combiner[0];
112 _combiner[1] = copy._combiner[1];
134 write(ostream &out,
int indent_level)
const {
136 enquote_string(out,
get_filename(), indent_level + 2) <<
"\n";
139 indent(out, indent_level + 2)
140 <<
"<Scalar> alpha-file { ";
146 indent(out, indent_level + 2)
147 <<
"<Scalar> alpha-file-channel { "
152 indent(out, indent_level + 2)
153 <<
"<Scalar> read-mipmaps { 1 }\n";
156 if (get_texture_type() != TT_unspecified) {
157 indent(out, indent_level + 2)
158 <<
"<Scalar> type { " << get_texture_type() <<
" }\n";
161 if (get_format() != F_unspecified) {
162 indent(out, indent_level + 2)
163 <<
"<Scalar> format { " << get_format() <<
" }\n";
166 if (get_compression_mode() != CM_default) {
167 indent(out, indent_level + 2)
168 <<
"<Scalar> compression { " << get_compression_mode() <<
" }\n";
171 if (get_wrap_mode() != WM_unspecified) {
172 indent(out, indent_level + 2)
173 <<
"<Scalar> wrap { " << get_wrap_mode() <<
" }\n";
177 indent(out, indent_level + 2)
178 <<
"<Scalar> wrapu { " <<
get_wrap_u() <<
" }\n";
182 indent(out, indent_level + 2)
183 <<
"<Scalar> wrapv { " <<
get_wrap_v() <<
" }\n";
187 indent(out, indent_level + 2)
188 <<
"<Scalar> wrapw { " <<
get_wrap_w() <<
" }\n";
191 if (get_minfilter() != FT_unspecified) {
192 indent(out, indent_level + 2)
193 <<
"<Scalar> minfilter { " << get_minfilter() <<
" }\n";
196 if (get_magfilter() != FT_unspecified) {
197 indent(out, indent_level + 2)
198 <<
"<Scalar> magfilter { " << get_magfilter() <<
" }\n";
202 indent(out, indent_level + 2)
206 if (get_env_type() != ET_unspecified) {
207 indent(out, indent_level + 2)
208 <<
"<Scalar> envtype { " << get_env_type() <<
" }\n";
211 for (
int ci = 0; ci < (int)CC_num_channels; ci++) {
212 CombineChannel channel = (CombineChannel)ci;
213 if (get_combine_mode(channel) != CM_unspecified) {
214 indent(out, indent_level + 2)
215 <<
"<Scalar> combine-" << channel
216 <<
" { " << get_combine_mode(channel) <<
" }\n";
218 for (
int i = 0; i < (int)CI_num_indices; i++) {
219 if (get_combine_source(channel, i) != CS_unspecified) {
220 indent(out, indent_level + 2)
221 <<
"<Scalar> combine-" << channel <<
"-source" << i
222 <<
" { " << get_combine_source(channel, i) <<
" }\n";
224 if (get_combine_operand(channel, i) != CO_unspecified) {
225 indent(out, indent_level + 2)
226 <<
"<Scalar> combine-" << channel <<
"-operand" << i
227 <<
" { " << get_combine_operand(channel, i) <<
" }\n";
233 indent(out, indent_level + 2)
234 <<
"<Scalar> saved-result { 1 }\n";
237 if (get_tex_gen() != TG_unspecified) {
238 indent(out, indent_level + 2)
239 <<
"<Scalar> tex-gen { " << get_tex_gen() <<
" }\n";
242 if (get_quality_level() != QL_unspecified) {
243 indent(out, indent_level + 2)
244 <<
"<Scalar> quality-level { " << get_quality_level() <<
" }\n";
248 indent(out, indent_level + 2)
253 indent(out, indent_level + 2)
258 indent(out, indent_level + 2)
259 <<
"<Scalar> blendr { " << _color[0] <<
" }\n";
260 indent(out, indent_level + 2)
261 <<
"<Scalar> blendg { " << _color[1] <<
" }\n";
262 indent(out, indent_level + 2)
263 <<
"<Scalar> blendb { " << _color[2] <<
" }\n";
264 indent(out, indent_level + 2)
265 <<
"<Scalar> blenda { " << _color[3] <<
" }\n";
269 indent(out, indent_level + 2)
270 <<
"<Scalar> borderr { " << _border_color[0] <<
" }\n";
271 indent(out, indent_level + 2)
272 <<
"<Scalar> borderg { " << _border_color[1] <<
" }\n";
273 indent(out, indent_level + 2)
274 <<
"<Scalar> borderb { " << _border_color[2] <<
" }\n";
275 indent(out, indent_level + 2)
276 <<
"<Scalar> bordera { " << _border_color[3] <<
" }\n";
280 indent(out, indent_level + 2)
281 <<
"<Scalar> uv-name { " <<
get_uv_name() <<
" }\n";
285 indent(out, indent_level + 2)
290 indent(out, indent_level + 2)
295 indent(out, indent_level + 2)
296 <<
"<Scalar> multiview { 1 }\n";
300 indent(out, indent_level + 2)
310 indent(out, indent_level) <<
"}\n";
350 if ((eq & E_complete_filename) == E_complete_filename) {
360 if (eq & E_basename) {
365 if (eq & E_extension) {
370 if (eq & E_dirname) {
377 if (eq & E_transform) {
390 if (eq & E_attributes) {
392 if (_texture_type != other._texture_type ||
393 _format != other._format ||
394 _compression_mode != other._compression_mode ||
395 _wrap_mode != other._wrap_mode ||
396 _wrap_u != other._wrap_u ||
397 _wrap_v != other._wrap_v ||
398 _wrap_w != other._wrap_w ||
399 _minfilter != other._minfilter ||
400 _magfilter != other._magfilter ||
401 _env_type != other._env_type) {
404 if (EggRenderMode::operator != (other)) {
409 if (eq & E_tref_name) {
411 if (get_name() != other.get_name()) {
430 if ((eq & E_complete_filename) == E_complete_filename) {
438 if (eq & E_basename) {
443 if (eq & E_extension) {
448 if (eq & E_dirname) {
455 if (eq & E_transform) {
458 if (is_identity != other_is_identity) {
459 return (
int)is_identity < (int)other_is_identity;
470 if (eq & E_attributes) {
471 if (_texture_type != other._texture_type) {
472 return (
int)_texture_type < (int)other._texture_type;
474 if (_format != other._format) {
475 return (
int)_format < (int)other._format;
477 if (_compression_mode != other._compression_mode) {
478 return (
int)_compression_mode < (int)other._compression_mode;
480 if (_wrap_mode != other._wrap_mode) {
481 return (
int)_wrap_mode < (int)other._wrap_mode;
483 if (_wrap_u != other._wrap_u) {
484 return (
int)_wrap_u < (int)other._wrap_u;
486 if (_wrap_v != other._wrap_v) {
487 return (
int)_wrap_v < (int)other._wrap_v;
489 if (_wrap_w != other._wrap_w) {
490 return (
int)_wrap_w < (int)other._wrap_w;
492 if (_minfilter != other._minfilter) {
493 return (
int)_minfilter < (int)other._minfilter;
495 if (_magfilter != other._magfilter) {
496 return (
int)_magfilter < (int)other._magfilter;
498 if (_anisotropic_degree != other._anisotropic_degree) {
499 return _anisotropic_degree < other._anisotropic_degree;
501 if (_env_type != other._env_type) {
502 return (
int)_env_type < (int)other._env_type;
504 if (EggRenderMode::operator != (other)) {
505 return EggRenderMode::operator < (other);
509 if (eq & E_tref_name) {
510 if (get_name() != other.get_name()) {
511 return get_name() < other.get_name();
547 case F_luminance_alpha:
548 case F_luminance_alphamask:
557 return (num_components == 2 || num_components == 4);
580 case ET_blend_color_scale:
581 case ET_modulate_glow:
582 case ET_modulate_gloss:
584 case ET_normal_height:
588 case ET_normal_gloss:
598 switch (_combiner[CC_alpha]._mode) {
631 _multitexture_sort = 0;
639 orig_over_textures.swap(_over_textures);
640 orig_under_textures.swap(_under_textures);
642 MultiTextures::iterator mti;
643 for (mti = orig_over_textures.begin();
644 mti != orig_over_textures.end();
647 other->_under_textures.erase(
this);
649 for (mti = orig_under_textures.begin();
650 mti != orig_under_textures.end();
653 other->_over_textures.erase(
this);
682 if (_over_textures.insert(other).second) {
683 bool inserted_under = other->_under_textures.insert(
this).second;
684 nassertr(inserted_under,
false);
700 if (cmp_nocase_uh(
string,
"1d") == 0 ||
701 cmp_nocase_uh(
string,
"1dtexture") == 0 ||
702 cmp_nocase_uh(
string,
"1d_texture") == 0) {
703 return TT_1d_texture;
705 }
else if (cmp_nocase_uh(
string,
"2d") == 0 ||
706 cmp_nocase_uh(
string,
"2dtexture") == 0 ||
707 cmp_nocase_uh(
string,
"2d_texture") == 0) {
708 return TT_2d_texture;
710 }
else if (cmp_nocase_uh(
string,
"3d") == 0 ||
711 cmp_nocase_uh(
string,
"3dtexture") == 0 ||
712 cmp_nocase_uh(
string,
"3d_texture") == 0) {
713 return TT_3d_texture;
715 }
else if (cmp_nocase_uh(
string,
"cube") == 0 ||
716 cmp_nocase_uh(
string,
"cubemap") == 0 ||
717 cmp_nocase_uh(
string,
"cube_map") == 0) {
721 return TT_unspecified;
734 if (cmp_nocase_uh(
string,
"rgba") == 0) {
736 }
else if (cmp_nocase_uh(
string,
"rgbm") == 0) {
738 }
else if (cmp_nocase_uh(
string,
"rgba12") == 0) {
740 }
else if (cmp_nocase_uh(
string,
"rgba8") == 0) {
742 }
else if (cmp_nocase_uh(
string,
"rgba4") == 0) {
745 }
else if (cmp_nocase_uh(
string,
"rgb") == 0) {
747 }
else if (cmp_nocase_uh(
string,
"rgb12") == 0) {
749 }
else if (cmp_nocase_uh(
string,
"rgb8") == 0) {
751 }
else if (cmp_nocase_uh(
string,
"rgb5") == 0) {
753 }
else if (cmp_nocase_uh(
string,
"rgba5") == 0) {
755 }
else if (cmp_nocase_uh(
string,
"rgb332") == 0) {
757 }
else if (cmp_nocase_uh(
string,
"red") == 0) {
759 }
else if (cmp_nocase_uh(
string,
"green") == 0) {
761 }
else if (cmp_nocase_uh(
string,
"blue") == 0) {
763 }
else if (cmp_nocase_uh(
string,
"alpha") == 0) {
765 }
else if (cmp_nocase_uh(
string,
"luminance") == 0) {
767 }
else if (cmp_nocase_uh(
string,
"luminance_alpha") == 0) {
768 return F_luminance_alpha;
769 }
else if (cmp_nocase_uh(
string,
"luminance_alphamask") == 0) {
770 return F_luminance_alphamask;
772 return F_unspecified;
785 if (cmp_nocase_uh(
string,
"off") == 0) {
787 }
else if (cmp_nocase_uh(
string,
"on") == 0) {
789 }
else if (cmp_nocase_uh(
string,
"fxt1") == 0) {
791 }
else if (cmp_nocase_uh(
string,
"dxt1") == 0) {
793 }
else if (cmp_nocase_uh(
string,
"dxt2") == 0) {
795 }
else if (cmp_nocase_uh(
string,
"dxt3") == 0) {
797 }
else if (cmp_nocase_uh(
string,
"dxt4") == 0) {
799 }
else if (cmp_nocase_uh(
string,
"dxt5") == 0) {
815 if (cmp_nocase_uh(
string,
"repeat") == 0) {
817 }
else if (cmp_nocase_uh(
string,
"clamp") == 0) {
819 }
else if (cmp_nocase_uh(
string,
"mirror") == 0) {
821 }
else if (cmp_nocase_uh(
string,
"mirror_once") == 0) {
822 return WM_mirror_once;
823 }
else if (cmp_nocase_uh(
string,
"border_color") == 0) {
824 return WM_border_color;
826 return WM_unspecified;
840 if (cmp_nocase_uh(
string,
"point") == 0) {
842 }
else if (cmp_nocase_uh(
string,
"linear") == 0) {
844 }
else if (cmp_nocase_uh(
string,
"bilinear") == 0) {
846 }
else if (cmp_nocase_uh(
string,
"trilinear") == 0) {
847 return FT_linear_mipmap_linear;
848 }
else if (cmp_nocase_uh(
string,
"mipmap") == 0) {
849 return FT_linear_mipmap_linear;
850 }
else if (cmp_nocase_uh(
string,
"mipmap_point") == 0) {
851 return FT_nearest_mipmap_nearest;
852 }
else if (cmp_nocase_uh(
string,
"mipmap_linear") == 0) {
853 return FT_nearest_mipmap_linear;
854 }
else if (cmp_nocase_uh(
string,
"mipmap_bilinear") == 0) {
855 return FT_linear_mipmap_nearest;
856 }
else if (cmp_nocase_uh(
string,
"mipmap_trilinear") == 0) {
857 return FT_linear_mipmap_linear;
860 }
else if (cmp_nocase_uh(
string,
"nearest") == 0) {
862 }
else if (cmp_nocase_uh(
string,
"linear") == 0) {
864 }
else if (cmp_nocase_uh(
string,
"nearest_mipmap_nearest") == 0) {
865 return FT_nearest_mipmap_nearest;
866 }
else if (cmp_nocase_uh(
string,
"linear_mipmap_nearest") == 0) {
867 return FT_linear_mipmap_nearest;
868 }
else if (cmp_nocase_uh(
string,
"nearest_mipmap_linear") == 0) {
869 return FT_nearest_mipmap_linear;
870 }
else if (cmp_nocase_uh(
string,
"linear_mipmap_linear") == 0) {
871 return FT_linear_mipmap_linear;
874 return FT_unspecified;
887 if (cmp_nocase_uh(
string,
"modulate") == 0) {
890 }
else if (cmp_nocase_uh(
string,
"decal") == 0) {
893 }
else if (cmp_nocase_uh(
string,
"blend") == 0) {
896 }
else if (cmp_nocase_uh(
string,
"replace") == 0) {
899 }
else if (cmp_nocase_uh(
string,
"add") == 0) {
902 }
else if (cmp_nocase_uh(
string,
"blend_color_scale") == 0) {
903 return ET_blend_color_scale;
905 }
else if (cmp_nocase_uh(
string,
"modulate_glow") == 0) {
906 return ET_modulate_glow;
908 }
else if (cmp_nocase_uh(
string,
"modulate_gloss") == 0) {
909 return ET_modulate_gloss;
911 }
else if (cmp_nocase_uh(
string,
"normal") == 0) {
914 }
else if (cmp_nocase_uh(
string,
"normal_height") == 0) {
915 return ET_normal_height;
917 }
else if (cmp_nocase_uh(
string,
"glow") == 0) {
920 }
else if (cmp_nocase_uh(
string,
"gloss") == 0) {
923 }
else if (cmp_nocase_uh(
string,
"height") == 0) {
926 }
else if (cmp_nocase_uh(
string,
"selector") == 0) {
929 }
else if (cmp_nocase_uh(
string,
"normal_gloss") == 0) {
930 return ET_normal_gloss;
933 return ET_unspecified;
946 if (cmp_nocase_uh(
string,
"replace") == 0) {
949 }
else if (cmp_nocase_uh(
string,
"modulate") == 0) {
952 }
else if (cmp_nocase_uh(
string,
"add") == 0) {
955 }
else if (cmp_nocase_uh(
string,
"add_signed") == 0) {
956 return CM_add_signed;
958 }
else if (cmp_nocase_uh(
string,
"interpolate") == 0) {
959 return CM_interpolate;
961 }
else if (cmp_nocase_uh(
string,
"subtract") == 0) {
964 }
else if (cmp_nocase_uh(
string,
"dot3_rgb") == 0) {
967 }
else if (cmp_nocase_uh(
string,
"dot3_rgba") == 0) {
971 return CM_unspecified;
984 if (cmp_nocase_uh(
string,
"texture") == 0) {
987 }
else if (cmp_nocase_uh(
string,
"constant") == 0) {
990 }
else if (cmp_nocase_uh(
string,
"primary_color") == 0) {
991 return CS_primary_color;
993 }
else if (cmp_nocase_uh(
string,
"previous") == 0) {
996 }
else if (cmp_nocase_uh(
string,
"constant_color_scale") == 0) {
997 return CS_constant_color_scale;
999 }
else if (cmp_nocase_uh(
string,
"last_saved_result") == 0) {
1000 return CS_last_saved_result;
1003 return CS_unspecified;
1016 if (cmp_nocase_uh(
string,
"src_color") == 0) {
1017 return CO_src_color;
1019 }
else if (cmp_nocase_uh(
string,
"one_minus_src_color") == 0) {
1020 return CO_one_minus_src_color;
1022 }
else if (cmp_nocase_uh(
string,
"src_alpha") == 0) {
1023 return CO_src_alpha;
1025 }
else if (cmp_nocase_uh(
string,
"one_minus_src_alpha") == 0) {
1026 return CO_one_minus_src_alpha;
1029 return CO_unspecified;
1042 if (cmp_nocase_uh(
string,
"unspecified") == 0) {
1043 return TG_unspecified;
1045 }
else if (cmp_nocase_uh(
string,
"sphere_map") == 0 ||
1046 cmp_nocase_uh(
string,
"eye_sphere_map") == 0) {
1047 return TG_eye_sphere_map;
1049 }
else if (cmp_nocase_uh(
string,
"world_cube_map") == 0) {
1050 return TG_world_cube_map;
1052 }
else if (cmp_nocase_uh(
string,
"cube_map") == 0 ||
1053 cmp_nocase_uh(
string,
"eye_cube_map") == 0) {
1054 return TG_eye_cube_map;
1056 }
else if (cmp_nocase_uh(
string,
"world_normal") == 0) {
1057 return TG_world_normal;
1059 }
else if (cmp_nocase_uh(
string,
"eye_normal") == 0) {
1060 return TG_eye_normal;
1062 }
else if (cmp_nocase_uh(
string,
"world_position") == 0) {
1063 return TG_world_position;
1065 }
else if (cmp_nocase_uh(
string,
"eye_position") == 0) {
1066 return TG_eye_position;
1068 }
else if (cmp_nocase_uh(
string,
"point_sprite") == 0) {
1069 return TG_point_sprite;
1072 return TG_unspecified;
1085 if (cmp_nocase_uh(
string,
"unspecified") == 0) {
1086 return QL_unspecified;
1088 }
else if (cmp_nocase_uh(
string,
"default") == 0) {
1091 }
else if (cmp_nocase_uh(
string,
"fastest") == 0) {
1094 }
else if (cmp_nocase_uh(
string,
"normal") == 0) {
1097 }
else if (cmp_nocase_uh(
string,
"best") == 0) {
1101 return QL_unspecified;
1127 egg_start_parse_body() {
1128 egg_start_texture_body();
1140 if (_multitexture_sort >= sort) {
1145 if (!cycle_detector.insert(
this).second) {
1150 _multitexture_sort = sort;
1154 bool no_cycles =
true;
1156 MultiTextures::iterator mti;
1157 for (mti = _under_textures.begin();
1158 mti != _under_textures.end();
1161 if (!other->r_min_multitexture_sort(sort + 1, cycle_detector)) {
1175 ostream &operator << (ostream &out, EggTexture::TextureType texture_type) {
1176 switch (texture_type) {
1177 case EggTexture::TT_unspecified:
1178 return out <<
"unspecified";
1180 case EggTexture::TT_1d_texture:
1183 case EggTexture::TT_2d_texture:
1186 case EggTexture::TT_3d_texture:
1189 case EggTexture::TT_cube_map:
1190 return out <<
"cube-map";
1193 nassertr(
false, out);
1194 return out <<
"(**invalid**)";
1202 ostream &operator << (ostream &out, EggTexture::Format format) {
1204 case EggTexture::F_unspecified:
1205 return out <<
"unspecified";
1207 case EggTexture::F_rgba:
1208 return out <<
"rgba";
1209 case EggTexture::F_rgbm:
1210 return out <<
"rgbm";
1211 case EggTexture::F_rgba12:
1212 return out <<
"rgba12";
1213 case EggTexture::F_rgba8:
1214 return out <<
"rgba8";
1215 case EggTexture::F_rgba4:
1216 return out <<
"rgba4";
1218 case EggTexture::F_rgb:
1219 return out <<
"rgb";
1220 case EggTexture::F_rgb12:
1221 return out <<
"rgb12";
1222 case EggTexture::F_rgb8:
1223 return out <<
"rgb8";
1224 case EggTexture::F_rgb5:
1225 return out <<
"rgb5";
1226 case EggTexture::F_rgba5:
1227 return out <<
"rgba5";
1228 case EggTexture::F_rgb332:
1229 return out <<
"rgb332";
1231 case EggTexture::F_red:
1232 return out <<
"red";
1233 case EggTexture::F_green:
1234 return out <<
"green";
1235 case EggTexture::F_blue:
1236 return out <<
"blue";
1237 case EggTexture::F_alpha:
1238 return out <<
"alpha";
1239 case EggTexture::F_luminance:
1240 return out <<
"luminance";
1241 case EggTexture::F_luminance_alpha:
1242 return out <<
"luminance_alpha";
1243 case EggTexture::F_luminance_alphamask:
1244 return out <<
"luminance_alphamask";
1247 nassertr(
false, out);
1248 return out <<
"(**invalid**)";
1255 ostream &operator << (ostream &out, EggTexture::CompressionMode mode) {
1257 case EggTexture::CM_default:
1258 return out <<
"default";
1259 case EggTexture::CM_off:
1260 return out <<
"off";
1261 case EggTexture::CM_on:
1263 case EggTexture::CM_fxt1:
1264 return out <<
"fxt1";
1265 case EggTexture::CM_dxt1:
1266 return out <<
"dxt1";
1267 case EggTexture::CM_dxt2:
1268 return out <<
"dxt2";
1269 case EggTexture::CM_dxt3:
1270 return out <<
"dxt3";
1271 case EggTexture::CM_dxt4:
1272 return out <<
"dxt4";
1273 case EggTexture::CM_dxt5:
1274 return out <<
"dxt5";
1277 nassertr(
false, out);
1278 return out <<
"(**invalid**)";
1285 ostream &operator << (ostream &out, EggTexture::WrapMode mode) {
1287 case EggTexture::WM_unspecified:
1288 return out <<
"unspecified";
1289 case EggTexture::WM_repeat:
1290 return out <<
"repeat";
1291 case EggTexture::WM_clamp:
1292 return out <<
"clamp";
1293 case EggTexture::WM_mirror:
1294 return out <<
"mirror";
1295 case EggTexture::WM_mirror_once:
1296 return out <<
"mirror_once";
1297 case EggTexture::WM_border_color:
1298 return out <<
"border_color";
1301 nassertr(
false, out);
1302 return out <<
"(**invalid**)";
1309 ostream &operator << (ostream &out, EggTexture::FilterType type) {
1311 case EggTexture::FT_unspecified:
1312 return out <<
"unspecified";
1314 case EggTexture::FT_nearest:
1315 return out <<
"nearest";
1316 case EggTexture::FT_linear:
1317 return out <<
"linear";
1319 case EggTexture::FT_nearest_mipmap_nearest:
1320 return out <<
"nearest_mipmap_nearest";
1321 case EggTexture::FT_linear_mipmap_nearest:
1322 return out <<
"linear_mipmap_nearest";
1323 case EggTexture::FT_nearest_mipmap_linear:
1324 return out <<
"nearest_mipmap_linear";
1325 case EggTexture::FT_linear_mipmap_linear:
1326 return out <<
"linear_mipmap_linear";
1329 nassertr(
false, out);
1330 return out <<
"(**invalid**)";
1337 ostream &operator << (ostream &out, EggTexture::EnvType type) {
1339 case EggTexture::ET_unspecified:
1340 return out <<
"unspecified";
1342 case EggTexture::ET_modulate:
1343 return out <<
"modulate";
1345 case EggTexture::ET_decal:
1346 return out <<
"decal";
1348 case EggTexture::ET_blend:
1349 return out <<
"blend";
1351 case EggTexture::ET_replace:
1352 return out <<
"replace";
1354 case EggTexture::ET_add:
1355 return out <<
"add";
1357 case EggTexture::ET_blend_color_scale:
1358 return out <<
"blend_color_scale";
1360 case EggTexture::ET_modulate_glow:
1361 return out <<
"modulate_glow";
1363 case EggTexture::ET_modulate_gloss:
1364 return out <<
"modulate_gloss";
1366 case EggTexture::ET_normal:
1367 return out <<
"normal";
1369 case EggTexture::ET_normal_height:
1370 return out <<
"normal_height";
1372 case EggTexture::ET_glow:
1373 return out <<
"glow";
1375 case EggTexture::ET_gloss:
1376 return out <<
"gloss";
1378 case EggTexture::ET_height:
1379 return out <<
"height";
1381 case EggTexture::ET_selector:
1382 return out <<
"selector";
1384 case EggTexture::ET_normal_gloss:
1385 return out <<
"normal_gloss";
1388 nassertr(
false, out);
1389 return out <<
"(**invalid**)";
1393 operator << (ostream &out, EggTexture::CombineMode cm) {
1395 case EggTexture::CM_unspecified:
1396 return out <<
"unspecified";
1398 case EggTexture::CM_replace:
1399 return out <<
"replace";
1401 case EggTexture::CM_modulate:
1402 return out <<
"modulate";
1404 case EggTexture::CM_add:
1405 return out <<
"add";
1407 case EggTexture::CM_add_signed:
1408 return out <<
"add_signed";
1410 case EggTexture::CM_interpolate:
1411 return out <<
"interpolate";
1413 case EggTexture::CM_subtract:
1414 return out <<
"subtract";
1416 case EggTexture::CM_dot3_rgb:
1417 return out <<
"dot3_rgb";
1419 case EggTexture::CM_dot3_rgba:
1420 return out <<
"dot3_rgba";
1423 return out <<
"**invalid CombineMode(" << (int)cm <<
")**";
1427 operator << (ostream &out, EggTexture::CombineChannel cm) {
1429 case EggTexture::CC_rgb:
1430 return out <<
"rgb";
1432 case EggTexture::CC_alpha:
1433 return out <<
"alpha";
1435 case EggTexture::CC_num_channels:
1441 return out <<
"**invalid CombineChannel(" << (int)cm <<
")**";
1445 operator << (ostream &out, EggTexture::CombineSource cs) {
1447 case EggTexture::CS_unspecified:
1448 return out <<
"unspecified";
1450 case EggTexture::CS_texture:
1451 return out <<
"texture";
1453 case EggTexture::CS_constant:
1454 return out <<
"constant";
1456 case EggTexture::CS_primary_color:
1457 return out <<
"primary_color";
1459 case EggTexture::CS_previous:
1460 return out <<
"previous";
1462 case EggTexture::CS_constant_color_scale:
1463 return out <<
"constant_color_scale";
1465 case EggTexture::CS_last_saved_result:
1466 return out <<
"last_saved_result";
1469 return out <<
"**invalid CombineSource(" << (int)cs <<
")**";
1473 operator << (ostream &out, EggTexture::CombineOperand co) {
1475 case EggTexture::CO_unspecified:
1476 return out <<
"unspecified";
1478 case EggTexture::CO_src_color:
1479 return out <<
"src_color";
1481 case EggTexture::CO_one_minus_src_color:
1482 return out <<
"one_minus_src_color";
1484 case EggTexture::CO_src_alpha:
1485 return out <<
"src_alpha";
1487 case EggTexture::CO_one_minus_src_alpha:
1488 return out <<
"one_minus_src_alpha";
1491 return out <<
"**invalid CombineOperand(" << (int)co <<
")**";
1495 operator << (ostream &out, EggTexture::TexGen tex_gen) {
1497 case EggTexture::TG_unspecified:
1498 return out <<
"unspecified";
1500 case EggTexture::TG_eye_sphere_map:
1501 return out <<
"eye_sphere_map";
1503 case EggTexture::TG_world_cube_map:
1504 return out <<
"world_cube_map";
1506 case EggTexture::TG_eye_cube_map:
1507 return out <<
"eye_cube_map";
1509 case EggTexture::TG_world_normal:
1510 return out <<
"world_normal";
1512 case EggTexture::TG_eye_normal:
1513 return out <<
"eye_normal";
1515 case EggTexture::TG_world_position:
1516 return out <<
"world_position";
1518 case EggTexture::TG_eye_position:
1519 return out <<
"eye_position";
1521 case EggTexture::TG_point_sprite:
1522 return out <<
"point_sprite";
1525 return out <<
"**invalid TexGen(" << (int)tex_gen <<
")**";
1529 operator << (ostream &out, EggTexture::QualityLevel quality_level) {
1530 switch (quality_level) {
1531 case EggTexture::QL_unspecified:
1532 return out <<
"unspecified";
1533 case EggTexture::QL_default:
1534 return out <<
"default";
1535 case EggTexture::QL_fastest:
1536 return out <<
"fastest";
1537 case EggTexture::QL_normal:
1538 return out <<
"normal";
1539 case EggTexture::QL_best:
1540 return out <<
"best";
1543 return out <<
"**invalid QualityLevel(" << (int)quality_level <<
")**";
bool affects_polygon_alpha() const
Returns true if this texture's environment type or combine mode allows the texture to have an effect ...
int get_multitexture_sort() const
Returns an integer that represents the depth to which this texture is layered on all other textures i...
int get_anisotropic_degree() const
Returns the anisotropic filtering degree that has been specified for this texture, or 0 if nothing has been specified.
static WrapMode string_wrap_mode(const string &string)
Returns the WrapMode value associated with the given string representation, or WM_unspecified if the ...
void write_header(ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
bool multitexture_over(EggTexture *other)
Indicates that this texture should be layered on top of the other texture.
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)...
This is an egg node that contains a filename.
bool get_multiview() const
Returns the current setting of the multiview flag.
void clear_multitexture()
Resets the multitexture flags set by multitexture_over().
Defines a texture map that may be applied to geometry.
bool has_stage_name() const
Returns true if a stage name has been explicitly specified for this texture, false otherwise...
bool has_priority() const
Returns true if a priority value for multitexture importance has been specified for the texture...
static EnvType string_env_type(const string &string)
Returns the EnvType value associated with the given string representation, or ET_unspecified if the s...
bool has_color() const
Returns true if a blend color has been specified for the texture.
static QualityLevel string_quality_level(const string &string)
Returns the TexGen value associated with the given string representation, or ET_unspecified if the st...
bool has_alpha_file_channel() const
Returns true if a particular channel has been specified for the alpha-file image, false otherwise...
virtual EggTransform * as_transform()
Returns this object cross-cast to an EggTransform pointer, if it inherits from EggTransform, or NULL if it does not.
int get_rgb_scale() const
Returns the rgb_scale value that has been specified for the texture, or 1 if no rgb_scale value has b...
string get_dirname() const
Returns the directory part of the filename.
bool get_read_mipmaps() const
Returns the current setting of the read_mipmaps flag.
int get_num_views() const
Returns the specified number of views specified for the 3-D multiview texture.
static CompressionMode string_compression_mode(const string &string)
Returns the CompressionMode value associated with the given string representation, or CM_default if the string does not match any known CompressionMode value.
bool has_anisotropic_degree() const
Returns true if a value for the anisotropic filtering degree has been specified for this texture...
static Format string_format(const string &string)
Returns the Format value associated with the given string representation, or F_unspecified if the str...
static CombineOperand string_combine_operand(const string &string)
Returns the CombineOperand value associated with the given string representation, or CO_unspecified i...
WrapMode get_wrap_v() const
Returns the amount specified for V wrap.
void write(ostream &out, int indent_level) const
Writes the attributes to the indicated output stream in Egg format.
WrapMode get_wrap_u() const
Returns the amount specified for U wrap.
const string & get_uv_name() const
Returns the texcoord name that has been specified for this texture, or the empty string if no texcoor...
bool almost_equal(const LMatrix4d &other, double threshold) const
Returns true if two matrices are memberwise equal within a specified tolerance.
static FilterType string_filter_type(const string &string)
Returns the FilterType value associated with the given string representation, or FT_unspecified if th...
The name of a file, such as a texture file or an Egg file.
bool has_alpha_filename() const
Returns true if a separate file for the alpha component has been applied, false otherwise.
int get_alpha_file_channel() const
Returns the particular channel that has been specified for the alpha-file image, or 0 if no channel h...
bool sorts_less_than(const EggTexture &other, int eq) const
An ordering operator to compare two textures for sorting order.
static CombineMode string_combine_mode(const string &string)
Returns the CombineMode value associated with the given string representation, or CM_unspecified if t...
static TextureType string_texture_type(const string &string)
Returns the Texture_ype value associated with the given string representation, or TT_unspecified if t...
static TexGen string_tex_gen(const string &string)
Returns the TexGen value associated with the given string representation, or ET_unspecified if the st...
const Filename & get_filename() const
Returns a nonmodifiable reference to the filename.
int get_alpha_scale() const
Returns the alpha_scale value that has been specified for the texture, or 1 if no alpha_scale value h...
int compare_to(const LMatrix4d &other) const
This flavor of compare_to uses a default threshold value based on the numeric type.
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...
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
bool has_alpha_scale() const
Returns true if an alpha_scale has been specified for the texture, false otherwise.
virtual void write(ostream &out, int indent_level) const
Writes the texture definition to the indicated output stream in Egg format.
const Filename & get_alpha_filename() const
Returns the separate file assigned for the alpha channel.
bool has_border_color() const
Returns true if a border color has been specified for the texture.
WrapMode get_wrap_w() const
Returns the amount specified for W wrap.
bool has_uv_name() const
Returns true if a texcoord name has been explicitly specified for this texture, false otherwise...
TypeHandle is the identifier used to differentiate C++ class types.
static CombineSource string_combine_source(const string &string)
Returns the CombineSource value associated with the given string representation, or CS_unspecified if...
bool has_rgb_scale() const
Returns true if an rgb_scale has been specified for the texture, false otherwise. ...
bool has_num_views() const
Returns true if the number of views has been specified for the 3-D multiview texture, false otherwise.
string get_extension() const
Returns the file extension.
int get_priority() const
Returns the multitexture importance value that has been specified for the texture, or 0 if no priority value has been specified.
bool get_saved_result() const
Returns the current setting of the saved_result flag.
const string & get_stage_name() const
Returns the stage name that has been specified for this texture, or the tref name if no texture stage...