Panda3D
cullBinAttrib.h
1 // Filename: cullBinAttrib.h
2 // Created by: drose (01Mar02)
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 CULLBINATTRIB_H
16 #define CULLBINATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 
22 class FactoryParams;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : CullBinAttrib
26 // Description : Assigns geometry to a particular bin by name. The
27 // bins must be created separately via the
28 // CullBinManager interface.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PGRAPH CullBinAttrib : public RenderAttrib {
31 private:
32  INLINE CullBinAttrib();
33 
34 PUBLISHED:
35  static CPT(RenderAttrib) make(const string &bin_name, int draw_order);
36  static CPT(RenderAttrib) make_default();
37 
38  INLINE const string &get_bin_name() const;
39  INLINE int get_draw_order() const;
40 
41 public:
42  virtual void output(ostream &out) const;
43 
44 protected:
45  virtual int compare_to_impl(const RenderAttrib *other) const;
46  virtual size_t get_hash_impl() const;
47 
48 private:
49  string _bin_name;
50  int _draw_order;
51 
52 PUBLISHED:
53  static int get_class_slot() {
54  return _attrib_slot;
55  }
56  virtual int get_slot() const {
57  return get_class_slot();
58  }
59 
60 public:
61  static void register_with_read_factory();
62  virtual void write_datagram(BamWriter *manager, Datagram &dg);
63 
64 protected:
65  static TypedWritable *make_from_bam(const FactoryParams &params);
66  void fillin(DatagramIterator &scan, BamReader *manager);
67 
68 public:
69  static TypeHandle get_class_type() {
70  return _type_handle;
71  }
72  static void init_type() {
73  RenderAttrib::init_type();
74  register_type(_type_handle, "CullBinAttrib",
75  RenderAttrib::get_class_type());
76  _attrib_slot = register_slot(_type_handle, 100, make_default);
77  }
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82 
83 private:
84  static TypeHandle _type_handle;
85  static int _attrib_slot;
86 };
87 
88 #include "cullBinAttrib.I"
89 
90 #endif
91 
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
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
Assigns geometry to a particular bin by name.
Definition: cullBinAttrib.h:30
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