00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "eggRenderMode.h"
00016 #include "indent.h"
00017 #include "string_utils.h"
00018 #include "pnotify.h"
00019
00020 TypeHandle EggRenderMode::_type_handle;
00021
00022
00023
00024
00025
00026
00027 EggRenderMode::
00028 EggRenderMode() {
00029 _alpha_mode = AM_unspecified;
00030 _depth_write_mode = DWM_unspecified;
00031 _depth_test_mode = DTM_unspecified;
00032 _visibility_mode = VM_unspecified;
00033 _depth_offset = 0;
00034 _has_depth_offset = false;
00035 _draw_order = 0;
00036 _has_draw_order = false;
00037 }
00038
00039
00040
00041
00042
00043
00044 EggRenderMode &EggRenderMode::
00045 operator = (const EggRenderMode ©) {
00046 _alpha_mode = copy._alpha_mode;
00047 _depth_write_mode = copy._depth_write_mode;
00048 _depth_test_mode = copy._depth_test_mode;
00049 _visibility_mode = copy._visibility_mode;
00050 _depth_offset = copy._depth_offset;
00051 _has_depth_offset = copy._has_depth_offset;
00052 _draw_order = copy._draw_order;
00053 _has_draw_order = copy._has_draw_order;
00054 return *this;
00055 }
00056
00057
00058
00059
00060
00061
00062
00063 void EggRenderMode::
00064 write(ostream &out, int indent_level) const {
00065 if (get_alpha_mode() != AM_unspecified) {
00066 indent(out, indent_level)
00067 << "<Scalar> alpha { " << get_alpha_mode() << " }\n";
00068 }
00069 if (get_depth_write_mode() != DWM_unspecified) {
00070 indent(out, indent_level)
00071 << "<Scalar> depth_write { " << get_depth_write_mode() << " }\n";
00072 }
00073 if (get_depth_test_mode() != DTM_unspecified) {
00074 indent(out, indent_level)
00075 << "<Scalar> depth_test { " << get_depth_test_mode() << " }\n";
00076 }
00077 if (get_visibility_mode() != VM_unspecified) {
00078 indent(out, indent_level)
00079 << "<Scalar> visibility { " << get_visibility_mode() << " }\n";
00080 }
00081 if (has_depth_offset()) {
00082 indent(out, indent_level)
00083 << "<Scalar> depth-offset { " << get_depth_offset() << " }\n";
00084 }
00085 if (has_draw_order()) {
00086 indent(out, indent_level)
00087 << "<Scalar> draw-order { " << get_draw_order() << " }\n";
00088 }
00089 if (has_bin()) {
00090 indent(out, indent_level)
00091 << "<Scalar> bin { " << get_bin() << " }\n";
00092 }
00093 }
00094
00095
00096
00097
00098
00099
00100 bool EggRenderMode::
00101 operator == (const EggRenderMode &other) const {
00102 if (_alpha_mode != other._alpha_mode ||
00103 _depth_write_mode != other._depth_write_mode ||
00104 _depth_test_mode != other._depth_test_mode ||
00105 _visibility_mode != other._visibility_mode ||
00106 _has_depth_offset != other._has_depth_offset ||
00107 _has_draw_order != other._has_draw_order) {
00108 return false;
00109 }
00110
00111 if (_has_depth_offset) {
00112 if (_depth_offset != other._depth_offset) {
00113 return false;
00114 }
00115 }
00116
00117 if (_has_draw_order) {
00118 if (_draw_order != other._draw_order) {
00119 return false;
00120 }
00121 }
00122
00123 if (_bin != other._bin) {
00124 return false;
00125 }
00126
00127 return true;
00128 }
00129
00130
00131
00132
00133
00134
00135 bool EggRenderMode::
00136 operator < (const EggRenderMode &other) const {
00137 if (_alpha_mode != other._alpha_mode) {
00138 return (int)_alpha_mode < (int)other._alpha_mode;
00139 }
00140 if (_depth_write_mode != other._depth_write_mode) {
00141 return (int)_depth_write_mode < (int)other._depth_write_mode;
00142 }
00143 if (_depth_test_mode != other._depth_test_mode) {
00144 return (int)_depth_test_mode < (int)other._depth_test_mode;
00145 }
00146 if (_visibility_mode != other._visibility_mode) {
00147 return (int)_visibility_mode < (int)other._visibility_mode;
00148 }
00149
00150 if (_has_depth_offset != other._has_depth_offset) {
00151 return (int)_has_depth_offset < (int)other._has_depth_offset;
00152 }
00153 if (_has_draw_order != other._has_draw_order) {
00154 return (int)_has_draw_order < (int)other._has_draw_order;
00155 }
00156
00157 if (_has_depth_offset) {
00158 if (_depth_offset != other._depth_offset) {
00159 return _depth_offset < other._depth_offset;
00160 }
00161 }
00162 if (_has_draw_order) {
00163 if (_draw_order != other._draw_order) {
00164 return _draw_order < other._draw_order;
00165 }
00166 }
00167
00168 if (_bin != other._bin) {
00169 return _bin < other._bin;
00170 }
00171
00172 return false;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182 EggRenderMode::AlphaMode EggRenderMode::
00183 string_alpha_mode(const string &string) {
00184 if (cmp_nocase_uh(string, "off") == 0) {
00185 return AM_off;
00186 } else if (cmp_nocase_uh(string, "on") == 0) {
00187 return AM_on;
00188 } else if (cmp_nocase_uh(string, "blend") == 0) {
00189 return AM_blend;
00190 } else if (cmp_nocase_uh(string, "blend_no_occlude") == 0) {
00191 return AM_blend_no_occlude;
00192 } else if (cmp_nocase_uh(string, "ms") == 0) {
00193 return AM_ms;
00194 } else if (cmp_nocase_uh(string, "ms_mask") == 0) {
00195 return AM_ms_mask;
00196 } else if (cmp_nocase_uh(string, "binary") == 0) {
00197 return AM_binary;
00198 } else if (cmp_nocase_uh(string, "dual") == 0) {
00199 return AM_dual;
00200 } else {
00201 return AM_unspecified;
00202 }
00203 }
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 EggRenderMode::DepthWriteMode EggRenderMode::
00214 string_depth_write_mode(const string &string) {
00215 if (cmp_nocase_uh(string, "off") == 0) {
00216 return DWM_off;
00217 } else if (cmp_nocase_uh(string, "on") == 0) {
00218 return DWM_on;
00219 } else {
00220 return DWM_unspecified;
00221 }
00222 }
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 EggRenderMode::DepthTestMode EggRenderMode::
00233 string_depth_test_mode(const string &string) {
00234 if (cmp_nocase_uh(string, "off") == 0) {
00235 return DTM_off;
00236 } else if (cmp_nocase_uh(string, "on") == 0) {
00237 return DTM_on;
00238 } else {
00239 return DTM_unspecified;
00240 }
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 EggRenderMode::VisibilityMode EggRenderMode::
00252 string_visibility_mode(const string &string) {
00253 if (cmp_nocase_uh(string, "hidden") == 0) {
00254 return VM_hidden;
00255 } else if (cmp_nocase_uh(string, "normal") == 0) {
00256 return VM_normal;
00257 } else {
00258 return VM_unspecified;
00259 }
00260 }
00261
00262
00263
00264
00265
00266
00267 ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) {
00268 switch (mode) {
00269 case EggRenderMode::AM_unspecified:
00270 return out << "unspecified";
00271 case EggRenderMode::AM_off:
00272 return out << "off";
00273 case EggRenderMode::AM_on:
00274 return out << "on";
00275 case EggRenderMode::AM_blend:
00276 return out << "blend";
00277 case EggRenderMode::AM_blend_no_occlude:
00278 return out << "blend_no_occlude";
00279 case EggRenderMode::AM_ms:
00280 return out << "ms";
00281 case EggRenderMode::AM_ms_mask:
00282 return out << "ms_mask";
00283 case EggRenderMode::AM_binary:
00284 return out << "binary";
00285 case EggRenderMode::AM_dual:
00286 return out << "dual";
00287 }
00288
00289 nassertr(false, out);
00290 return out << "(**invalid**)";
00291 }
00292
00293
00294
00295
00296
00297 istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode) {
00298 string word;
00299 in >> word;
00300 mode = EggRenderMode::string_alpha_mode(word);
00301 return in;
00302 }
00303
00304
00305
00306
00307
00308 ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode) {
00309 switch (mode) {
00310 case EggRenderMode::DWM_unspecified:
00311 return out << "unspecified";
00312 case EggRenderMode::DWM_off:
00313 return out << "off";
00314 case EggRenderMode::DWM_on:
00315 return out << "on";
00316 }
00317
00318 nassertr(false, out);
00319 return out << "(**invalid**)";
00320 }
00321
00322
00323
00324
00325
00326 ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode) {
00327 switch (mode) {
00328 case EggRenderMode::DTM_unspecified:
00329 return out << "unspecified";
00330 case EggRenderMode::DTM_off:
00331 return out << "off";
00332 case EggRenderMode::DTM_on:
00333 return out << "on";
00334 }
00335
00336 nassertr(false, out);
00337 return out << "(**invalid**)";
00338 }
00339
00340
00341
00342
00343
00344
00345
00346 ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode) {
00347 switch (mode) {
00348 case EggRenderMode::VM_unspecified:
00349 return out << "unspecified";
00350 case EggRenderMode::VM_hidden:
00351 return out << "hidden";
00352 case EggRenderMode::VM_normal:
00353 return out << "normal";
00354 }
00355
00356 nassertr(false, out);
00357 return out << "(**invalid**)";
00358 }
00359
00360