Panda3D
 All Classes Functions Variables Enumerations
colorScaleAttrib.h
1 // Filename: colorScaleAttrib.h
2 // Created by: drose (14Mar02)
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 COLORSCALEATTRIB_H
16 #define COLORSCALEATTRIB_H
17 
18 #include "pandabase.h"
19 
20 #include "renderAttrib.h"
21 #include "luse.h"
22 
23 class FactoryParams;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : ColorScaleAttrib
27 // Description : Applies a scale to colors in the scene graph and on
28 // vertices.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PGRAPH ColorScaleAttrib : public RenderAttrib {
31 protected:
32  ColorScaleAttrib(bool off, const LVecBase4 &scale);
33  INLINE ColorScaleAttrib(const ColorScaleAttrib &copy);
34 
35 PUBLISHED:
36  static CPT(RenderAttrib) make_identity();
37  static CPT(RenderAttrib) make(const LVecBase4 &scale);
38  static CPT(RenderAttrib) make_off();
39  static CPT(RenderAttrib) make_default();
40 
41  INLINE bool is_off() const;
42  INLINE bool is_identity() const;
43  INLINE bool has_scale() const;
44  INLINE bool has_rgb_scale() const;
45  INLINE bool has_alpha_scale() const;
46  INLINE const LVecBase4 &get_scale() const;
47  CPT(RenderAttrib) set_scale(const LVecBase4 &scale) const;
48 
49 public:
50  virtual bool lower_attrib_can_override() const;
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  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
59 
60 private:
61  void quantize_scale();
62 
63 private:
64  bool _off;
65  bool _has_scale;
66  bool _has_rgb_scale;
67  bool _has_alpha_scale;
68  LVecBase4 _scale;
69  static CPT(RenderAttrib) _identity_attrib;
70 
71 PUBLISHED:
72  static int get_class_slot() {
73  return _attrib_slot;
74  }
75  virtual int get_slot() const {
76  return get_class_slot();
77  }
78 
79 public:
80  static void register_with_read_factory();
81  virtual void write_datagram(BamWriter *manager, Datagram &dg);
82 
83 protected:
84  static TypedWritable *make_from_bam(const FactoryParams &params);
85  void fillin(DatagramIterator &scan, BamReader *manager);
86 
87 public:
88  static TypeHandle get_class_type() {
89  return _type_handle;
90  }
91  static void init_type() {
92  RenderAttrib::init_type();
93  register_type(_type_handle, "ColorScaleAttrib",
94  RenderAttrib::get_class_type());
95  _attrib_slot = register_slot(_type_handle, 100, make_default);
96  }
97  virtual TypeHandle get_type() const {
98  return get_class_type();
99  }
100  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
101 
102 private:
103  static TypeHandle _type_handle;
104  static int _attrib_slot;
105 };
106 
107 #include "colorScaleAttrib.I"
108 
109 #endif
110 
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 bool lower_attrib_can_override() const
Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib o...
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
Applies a scale to colors in the scene graph and on vertices.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
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