Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg/eggRenderMode.cxx

Go to the documentation of this file.
00001 // Filename: eggRenderMode.cxx
00002 // Created by:  drose (20Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "eggRenderMode.h"
00020 #include <indent.h>
00021 #include <string_utils.h>
00022 #include <notify.h>
00023 
00024 TypeHandle EggRenderMode::_type_handle;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: EggRenderMode::write
00028 //       Access: Public
00029 //  Description: Writes the attributes to the indicated output stream in
00030 //               Egg format.
00031 ////////////////////////////////////////////////////////////////////
00032 void EggRenderMode::
00033 write(ostream &out, int indent_level) const {
00034   if (get_alpha_mode() != AM_unspecified) {
00035     indent(out, indent_level)
00036       << "<Scalar> alpha { " << get_alpha_mode() << " }\n";
00037   }
00038   if (get_depth_write_mode() != DWM_unspecified) {
00039     indent(out, indent_level)
00040       << "<Scalar> depth_write { " << get_depth_write_mode() << " }\n";
00041   }
00042   if (get_depth_test_mode() != DTM_unspecified) {
00043     indent(out, indent_level)
00044       << "<Scalar> depth_test { " << get_depth_test_mode() << " }\n";
00045   }
00046   if (has_draw_order()) {
00047     indent(out, indent_level)
00048       << "<Scalar> draw-order { " << get_draw_order() << " }\n";
00049   }
00050   if (has_bin()) {
00051     indent(out, indent_level)
00052       << "<Scalar> bin { " << get_bin() << " }\n";
00053   }
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: EggRenderMode::Equality Operator
00058 //       Access: Public
00059 //  Description:
00060 ////////////////////////////////////////////////////////////////////
00061 bool EggRenderMode::
00062 operator == (const EggRenderMode &other) const {
00063   if (_alpha_mode != other._alpha_mode ||
00064       _depth_write_mode != other._depth_write_mode ||
00065       _depth_test_mode != other._depth_test_mode ||
00066       _has_draw_order != other._has_draw_order) {
00067     return false;
00068   }
00069 
00070   if (_has_draw_order) {
00071     if (_draw_order != other._draw_order) {
00072       return false;
00073     }
00074   }
00075 
00076   if (_bin != other._bin) {
00077     return false;
00078   }
00079 
00080   return true;
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: EggRenderMode::Ordering Operator
00085 //       Access: Public
00086 //  Description:
00087 ////////////////////////////////////////////////////////////////////
00088 bool EggRenderMode::
00089 operator < (const EggRenderMode &other) const {
00090   if (_alpha_mode != other._alpha_mode) {
00091     return (int)_alpha_mode < (int)other._alpha_mode;
00092   }
00093   if (_depth_write_mode != other._depth_write_mode) {
00094     return (int)_depth_write_mode < (int)other._depth_write_mode;
00095   }
00096   if (_depth_test_mode != other._depth_test_mode) {
00097     return (int)_depth_test_mode < (int)other._depth_test_mode;
00098   }
00099 
00100   if (_has_draw_order != other._has_draw_order) {
00101     return (int)_has_draw_order < (int)other._has_draw_order;
00102   }
00103 
00104   if (_has_draw_order) {
00105     if (_draw_order != other._draw_order) {
00106       return _draw_order < other._draw_order;
00107     }
00108   }
00109 
00110   if (_bin != other._bin) {
00111     return _bin < other._bin;
00112   }
00113 
00114   return false;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: EggRenderMode::string_alpha_mode
00119 //       Access: Public
00120 //  Description: Returns the AlphaMode value associated with the given
00121 //               string representation, or AM_unspecified if the string
00122 //               does not match any known AlphaMode value.
00123 ////////////////////////////////////////////////////////////////////
00124 EggRenderMode::AlphaMode EggRenderMode::
00125 string_alpha_mode(const string &string) {
00126   if (cmp_nocase_uh(string, "off") == 0) {
00127     return AM_off;
00128   } else if (cmp_nocase_uh(string, "on") == 0) {
00129     return AM_on;
00130   } else if (cmp_nocase_uh(string, "blend") == 0) {
00131     return AM_blend;
00132   } else if (cmp_nocase_uh(string, "blend_no_occlude") == 0) {
00133     return AM_blend_no_occlude;
00134   } else if (cmp_nocase_uh(string, "ms") == 0) {
00135     return AM_ms;
00136   } else if (cmp_nocase_uh(string, "ms_mask") == 0) {
00137     return AM_ms_mask;
00138   } else if (cmp_nocase_uh(string, "binary") == 0) {
00139     return AM_binary;
00140   } else if (cmp_nocase_uh(string, "dual") == 0) {
00141     return AM_dual;
00142   } else {
00143     return AM_unspecified;
00144   }
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: EggRenderMode::string_depth_write_mode
00149 //       Access: Public
00150 //  Description: Returns the DepthWriteMode value associated with the
00151 //               given string representation, or DWM_unspecified if
00152 //               the string does not match any known DepthWriteMode
00153 //               value.
00154 ////////////////////////////////////////////////////////////////////
00155 EggRenderMode::DepthWriteMode EggRenderMode::
00156 string_depth_write_mode(const string &string) {
00157   if (cmp_nocase_uh(string, "off") == 0) {
00158     return DWM_off;
00159   } else if (cmp_nocase_uh(string, "on") == 0) {
00160     return DWM_on;
00161   } else {
00162     return DWM_unspecified;
00163   }
00164 }
00165 
00166 ////////////////////////////////////////////////////////////////////
00167 //     Function: EggRenderMode::string_depth_test_mode
00168 //       Access: Public
00169 //  Description: Returns the DepthTestMode value associated with the
00170 //               given string representation, or DWM_unspecified if
00171 //               the string does not match any known DepthTestMode
00172 //               value.
00173 ////////////////////////////////////////////////////////////////////
00174 EggRenderMode::DepthTestMode EggRenderMode::
00175 string_depth_test_mode(const string &string) {
00176   if (cmp_nocase_uh(string, "off") == 0) {
00177     return DTM_off;
00178   } else if (cmp_nocase_uh(string, "on") == 0) {
00179     return DTM_on;
00180   } else {
00181     return DTM_unspecified;
00182   }
00183 }
00184 
00185 
00186 ////////////////////////////////////////////////////////////////////
00187 //     Function: AlphaMode output operator
00188 //  Description:
00189 ////////////////////////////////////////////////////////////////////
00190 ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) {
00191   switch (mode) {
00192   case EggRenderMode::AM_unspecified:
00193     return out << "unspecified";
00194   case EggRenderMode::AM_off:
00195     return out << "off";
00196   case EggRenderMode::AM_on:
00197     return out << "on";
00198   case EggRenderMode::AM_blend:
00199     return out << "blend";
00200   case EggRenderMode::AM_blend_no_occlude:
00201     return out << "blend_no_occlude";
00202   case EggRenderMode::AM_ms:
00203     return out << "ms";
00204   case EggRenderMode::AM_ms_mask:
00205     return out << "ms_mask";
00206   case EggRenderMode::AM_binary:
00207     return out << "binary";
00208   case EggRenderMode::AM_dual:
00209     return out << "dual";
00210   }
00211 
00212   nassertr(false, out);
00213   return out << "(**invalid**)";
00214 }
00215 
00216 ////////////////////////////////////////////////////////////////////
00217 //     Function: DepthWriteMode output operator
00218 //  Description:
00219 ////////////////////////////////////////////////////////////////////
00220 ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode) {
00221   switch (mode) {
00222   case EggRenderMode::DWM_unspecified:
00223     return out << "unspecified";
00224   case EggRenderMode::DWM_off:
00225     return out << "off";
00226   case EggRenderMode::DWM_on:
00227     return out << "on";
00228   }
00229 
00230   nassertr(false, out);
00231   return out << "(**invalid**)";
00232 }
00233 
00234 ////////////////////////////////////////////////////////////////////
00235 //     Function: DepthTestMode output operator
00236 //  Description:
00237 ////////////////////////////////////////////////////////////////////
00238 ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode) {
00239   switch (mode) {
00240   case EggRenderMode::DTM_unspecified:
00241     return out << "unspecified";
00242   case EggRenderMode::DTM_off:
00243     return out << "off";
00244   case EggRenderMode::DTM_on:
00245     return out << "on";
00246   }
00247 
00248   nassertr(false, out);
00249   return out << "(**invalid**)";
00250 }
00251 
00252 

Generated on Fri May 2 00:37:54 2003 for Panda by doxygen1.3