Panda3D
cullFaceAttrib.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file cullFaceAttrib.h
10  * @author drose
11  * @date 2002-02-27
12  */
13 
14 #ifndef CULLFACEATTRIB_H
15 #define CULLFACEATTRIB_H
16 
17 #include "pandabase.h"
18 
19 #include "renderAttrib.h"
20 
21 class FactoryParams;
22 
23 /**
24  * Indicates which faces should be culled based on their vertex ordering.
25  */
26 class EXPCL_PANDA_PGRAPH CullFaceAttrib : public RenderAttrib {
27 PUBLISHED:
28  enum Mode {
29  M_cull_none, // Cull no polygons
30  M_cull_clockwise, // Cull clockwise-oriented polygons
31  M_cull_counter_clockwise, // Cull counter-clockwise-oriented polygons
32  M_cull_unchanged, // Do not change existing cull behavior
33  };
34 
35 private:
36  INLINE CullFaceAttrib(Mode mode, bool reverse);
37 
38 PUBLISHED:
39  static CPT(RenderAttrib) make(Mode mode = M_cull_clockwise);
40  static CPT(RenderAttrib) make_reverse();
41  static CPT(RenderAttrib) make_default();
42 
43  INLINE Mode get_actual_mode() const;
44  INLINE bool get_reverse() const;
45  Mode get_effective_mode() const;
46 
47 PUBLISHED:
48  MAKE_PROPERTY(mode, get_actual_mode);
49  MAKE_PROPERTY(reverse, get_reverse);
50  MAKE_PROPERTY(effective_mode, get_effective_mode);
51 
52 public:
53  virtual void output(std::ostream &out) const;
54 
55 protected:
56  virtual int compare_to_impl(const RenderAttrib *other) const;
57  virtual size_t get_hash_impl() const;
58  virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
59  virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
60 
61 private:
62  Mode _mode;
63  bool _reverse;
64 
65 PUBLISHED:
66  static int get_class_slot() {
67  return _attrib_slot;
68  }
69  virtual int get_slot() const {
70  return get_class_slot();
71  }
72  MAKE_PROPERTY(class_slot, get_class_slot);
73 
74 public:
75  static void register_with_read_factory();
76  virtual void write_datagram(BamWriter *manager, Datagram &dg);
77 
78 protected:
79  static TypedWritable *make_from_bam(const FactoryParams &params);
80  void fillin(DatagramIterator &scan, BamReader *manager);
81 
82 public:
83  static TypeHandle get_class_type() {
84  return _type_handle;
85  }
86  static void init_type() {
87  RenderAttrib::init_type();
88  register_type(_type_handle, "CullFaceAttrib",
89  RenderAttrib::get_class_type());
90  _attrib_slot = register_slot(_type_handle, 100,
91  new CullFaceAttrib(M_cull_clockwise, false));
92  }
93  virtual TypeHandle get_type() const {
94  return get_class_type();
95  }
96  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
97 
98 private:
99  static TypeHandle _type_handle;
100  static int _attrib_slot;
101 };
102 
103 #include "cullFaceAttrib.I"
104 
105 #endif
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
Indicates which faces should be culled based on their vertex ordering.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:101
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38