Panda3D
 All Classes Functions Variables Enumerations
cullFaceAttrib.h
1 // Filename: cullFaceAttrib.h
2 // Created by: drose (27Feb02)
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 CULLFACEATTRIB_H
16 #define CULLFACEATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 
22 class FactoryParams;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : CullFaceAttrib
26 // Description : Indicates which faces should be culled based on their
27 // vertex ordering.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDA_PGRAPH CullFaceAttrib : public RenderAttrib {
30 PUBLISHED:
31  enum Mode {
32  M_cull_none, // Cull no polygons
33  M_cull_clockwise, // Cull clockwise-oriented polygons
34  M_cull_counter_clockwise, // Cull counter-clockwise-oriented polygons
35  M_cull_unchanged, // Do not change existing cull behavior
36  };
37 
38 private:
39  INLINE CullFaceAttrib(Mode mode, bool reverse);
40 
41 PUBLISHED:
42  static CPT(RenderAttrib) make(Mode mode = M_cull_clockwise);
43  static CPT(RenderAttrib) make_reverse();
44  static CPT(RenderAttrib) make_default();
45 
46  INLINE Mode get_actual_mode() const;
47  INLINE bool get_reverse() const;
48  Mode get_effective_mode() const;
49 
50 public:
51  virtual void output(ostream &out) const;
52 
53 protected:
54  virtual int compare_to_impl(const RenderAttrib *other) const;
55  virtual size_t get_hash_impl() const;
56  virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
57  virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
58 
59 private:
60  Mode _mode;
61  bool _reverse;
62 
63 PUBLISHED:
64  static int get_class_slot() {
65  return _attrib_slot;
66  }
67  virtual int get_slot() const {
68  return get_class_slot();
69  }
70 
71 public:
72  static void register_with_read_factory();
73  virtual void write_datagram(BamWriter *manager, Datagram &dg);
74 
75 protected:
76  static TypedWritable *make_from_bam(const FactoryParams &params);
77  void fillin(DatagramIterator &scan, BamReader *manager);
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  RenderAttrib::init_type();
85  register_type(_type_handle, "CullFaceAttrib",
86  RenderAttrib::get_class_type());
87  _attrib_slot = register_slot(_type_handle, 100, make_default);
88  }
89  virtual TypeHandle get_type() const {
90  return get_class_type();
91  }
92  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
93 
94 private:
95  static TypeHandle _type_handle;
96  static int _attrib_slot;
97 };
98 
99 #include "cullFaceAttrib.I"
100 
101 #endif
102 
static int register_slot(TypeHandle type_handle, int sort, RenderAttribRegistry::MakeDefaultFunc *make_default_func)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:163
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
Indicates which faces should be culled based on their vertex ordering.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43