Panda3D
eggRenderMode.h
1 // Filename: eggRenderMode.h
2 // Created by: drose (20Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGRENDERMODE_H
16 #define EGGRENDERMODE_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : EggRenderMode
24 // Description : This class stores miscellaneous rendering properties
25 // that is associated with geometry, and which may be
26 // set on the geometry primitive level, on the group
27 // above it, or indirectly via a texture. It's intended
28 // to be a base class for egg objects that can have
29 // these properties set.
30 //
31 // This class cannot inherit from EggObject, because it
32 // causes problems at the EggPolygon level with multiple
33 // appearances of the EggObject base class. And making
34 // EggObject a virtual base class is just no fun.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDAEGG EggRenderMode {
37 PUBLISHED:
38  EggRenderMode();
39  INLINE EggRenderMode(const EggRenderMode &copy);
40  EggRenderMode &operator = (const EggRenderMode &copy);
41 
42  void write(ostream &out, int indent_level) const;
43 
44  enum AlphaMode { // Specifies implementation of transparency.
45  AM_unspecified,
46  AM_off, // No transparency.
47  AM_on, // Use whatever the default model is.
48  AM_blend, // Normal alpha blending, e.g. TransparencyAttrib::M_alpha.
49  AM_blend_no_occlude, // Alpha blending w/o depth write.
50  AM_ms, // TransparencyAttrib::M_multisample
51  AM_ms_mask, // TransparencyAttrib::M_multisample_mask
52  AM_binary, // TransparencyAttrib::M_binary
53  AM_dual // TransparencyAttrib::M_dual
54  };
55 
56  enum DepthWriteMode {
57  DWM_unspecified, DWM_off, DWM_on
58  };
59 
60  enum DepthTestMode {
61  DTM_unspecified, DTM_off, DTM_on
62  };
63 
64  enum VisibilityMode {
65  VM_unspecified, VM_hidden, VM_normal
66  };
67 
68  INLINE void set_alpha_mode(AlphaMode mode);
69  INLINE AlphaMode get_alpha_mode() const;
70 
71  INLINE void set_depth_write_mode(DepthWriteMode mode);
72  INLINE DepthWriteMode get_depth_write_mode() const;
73 
74  INLINE void set_depth_test_mode(DepthTestMode mode);
75  INLINE DepthTestMode get_depth_test_mode() const;
76 
77  INLINE void set_visibility_mode(VisibilityMode mode);
78  INLINE VisibilityMode get_visibility_mode() const;
79 
80  INLINE void set_depth_offset(int bias);
81  INLINE int get_depth_offset() const;
82  INLINE bool has_depth_offset() const;
83  INLINE void clear_depth_offset();
84 
85  INLINE void set_draw_order(int order);
86  INLINE int get_draw_order() const;
87  INLINE bool has_draw_order() const;
88  INLINE void clear_draw_order();
89 
90  INLINE void set_bin(const string &bin);
91  INLINE string get_bin() const;
92  INLINE bool has_bin() const;
93  INLINE void clear_bin();
94 
95  // Comparison operators are handy.
96  bool operator == (const EggRenderMode &other) const;
97  INLINE bool operator != (const EggRenderMode &other) const;
98  bool operator < (const EggRenderMode &other) const;
99 
100  static AlphaMode string_alpha_mode(const string &string);
101  static DepthWriteMode string_depth_write_mode(const string &string);
102  static DepthTestMode string_depth_test_mode(const string &string);
103  static VisibilityMode string_visibility_mode(const string &string);
104 
105 private:
106  AlphaMode _alpha_mode;
107  DepthWriteMode _depth_write_mode;
108  DepthTestMode _depth_test_mode;
109  VisibilityMode _visibility_mode;
110  int _depth_offset;
111  bool _has_depth_offset;
112  int _draw_order;
113  bool _has_draw_order;
114  string _bin;
115 
116 
117 public:
118  static TypeHandle get_class_type() {
119  return _type_handle;
120  }
121  static void init_type() {
122  register_type(_type_handle, "EggRenderMode");
123  }
124 
125 private:
126  static TypeHandle _type_handle;
127 };
128 
129 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode);
130 EXPCL_PANDAEGG istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode);
131 
132 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode);
133 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode);
134 EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode);
135 
136 #include "eggRenderMode.I"
137 
138 #endif
139 
This class stores miscellaneous rendering properties that is associated with geometry, and which may be set on the geometry primitive level, on the group above it, or indirectly via a texture.
Definition: eggRenderMode.h:36
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85