Panda3D
|
00001 // Filename: eggRenderMode.h 00002 // Created by: drose (20Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef EGGRENDERMODE_H 00016 #define EGGRENDERMODE_H 00017 00018 #include "pandabase.h" 00019 #include "typedObject.h" 00020 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : EggRenderMode 00024 // Description : This class stores miscellaneous rendering properties 00025 // that is associated with geometry, and which may be 00026 // set on the geometry primitive level, on the group 00027 // above it, or indirectly via a texture. It's intended 00028 // to be a base class for egg objects that can have 00029 // these properties set. 00030 // 00031 // This class cannot inherit from EggObject, because it 00032 // causes problems at the EggPolygon level with multiple 00033 // appearances of the EggObject base class. And making 00034 // EggObject a virtual base class is just no fun. 00035 //////////////////////////////////////////////////////////////////// 00036 class EXPCL_PANDAEGG EggRenderMode { 00037 PUBLISHED: 00038 EggRenderMode(); 00039 INLINE EggRenderMode(const EggRenderMode ©); 00040 EggRenderMode &operator = (const EggRenderMode ©); 00041 00042 void write(ostream &out, int indent_level) const; 00043 00044 enum AlphaMode { // Specifies implementation of transparency. 00045 AM_unspecified, 00046 AM_off, // No transparency. 00047 AM_on, // Use whatever the default model is. 00048 AM_blend, // Normal alpha blending, e.g. TransparencyAttrib::M_alpha. 00049 AM_blend_no_occlude, // Alpha blending w/o depth write. 00050 AM_ms, // TransparencyAttrib::M_multisample 00051 AM_ms_mask, // TransparencyAttrib::M_multisample_mask 00052 AM_binary, // TransparencyAttrib::M_binary 00053 AM_dual // TransparencyAttrib::M_dual 00054 }; 00055 00056 enum DepthWriteMode { 00057 DWM_unspecified, DWM_off, DWM_on 00058 }; 00059 00060 enum DepthTestMode { 00061 DTM_unspecified, DTM_off, DTM_on 00062 }; 00063 00064 enum VisibilityMode { 00065 VM_unspecified, VM_hidden, VM_normal 00066 }; 00067 00068 INLINE void set_alpha_mode(AlphaMode mode); 00069 INLINE AlphaMode get_alpha_mode() const; 00070 00071 INLINE void set_depth_write_mode(DepthWriteMode mode); 00072 INLINE DepthWriteMode get_depth_write_mode() const; 00073 00074 INLINE void set_depth_test_mode(DepthTestMode mode); 00075 INLINE DepthTestMode get_depth_test_mode() const; 00076 00077 INLINE void set_visibility_mode(VisibilityMode mode); 00078 INLINE VisibilityMode get_visibility_mode() const; 00079 00080 INLINE void set_depth_offset(int bias); 00081 INLINE int get_depth_offset() const; 00082 INLINE bool has_depth_offset() const; 00083 INLINE void clear_depth_offset(); 00084 00085 INLINE void set_draw_order(int order); 00086 INLINE int get_draw_order() const; 00087 INLINE bool has_draw_order() const; 00088 INLINE void clear_draw_order(); 00089 00090 INLINE void set_bin(const string &bin); 00091 INLINE string get_bin() const; 00092 INLINE bool has_bin() const; 00093 INLINE void clear_bin(); 00094 00095 // Comparison operators are handy. 00096 bool operator == (const EggRenderMode &other) const; 00097 INLINE bool operator != (const EggRenderMode &other) const; 00098 bool operator < (const EggRenderMode &other) const; 00099 00100 static AlphaMode string_alpha_mode(const string &string); 00101 static DepthWriteMode string_depth_write_mode(const string &string); 00102 static DepthTestMode string_depth_test_mode(const string &string); 00103 static VisibilityMode string_visibility_mode(const string &string); 00104 00105 private: 00106 AlphaMode _alpha_mode; 00107 DepthWriteMode _depth_write_mode; 00108 DepthTestMode _depth_test_mode; 00109 VisibilityMode _visibility_mode; 00110 int _depth_offset; 00111 bool _has_depth_offset; 00112 int _draw_order; 00113 bool _has_draw_order; 00114 string _bin; 00115 00116 00117 public: 00118 static TypeHandle get_class_type() { 00119 return _type_handle; 00120 } 00121 static void init_type() { 00122 register_type(_type_handle, "EggRenderMode"); 00123 } 00124 00125 private: 00126 static TypeHandle _type_handle; 00127 }; 00128 00129 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode); 00130 EXPCL_PANDAEGG istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode); 00131 00132 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode); 00133 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode); 00134 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode); 00135 00136 #include "eggRenderMode.I" 00137 00138 #endif 00139