Panda3D
Loading...
Searching...
No Matches
colorAttrib.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 colorAttrib.h
10 * @author drose
11 * @date 2002-02-22
12 */
13
14#ifndef COLORATTRIB_H
15#define COLORATTRIB_H
16
17#include "pandabase.h"
18
19#include "renderAttrib.h"
20#include "luse.h"
21
22class FactoryParams;
23
24/**
25 * Indicates what color should be applied to renderable geometry.
26 */
27class EXPCL_PANDA_PGRAPH ColorAttrib : public RenderAttrib {
28PUBLISHED:
29 enum Type {
30 T_vertex, T_flat, T_off
31 };
32
33private:
34 INLINE ColorAttrib(Type type, const LColor &color);
35
36PUBLISHED:
37 static CPT(RenderAttrib) make_vertex();
38 static CPT(RenderAttrib) make_flat(const LColor &color);
39 static CPT(RenderAttrib) make_off();
40 static CPT(RenderAttrib) make_default();
41
42 INLINE Type get_color_type() const;
43 INLINE const LColor &get_color() const;
44
45PUBLISHED:
46 MAKE_PROPERTY(color_type, get_color_type);
47 MAKE_PROPERTY(color, get_color);
48
49public:
50 virtual void output(std::ostream &out) const;
51
52protected:
53 virtual int compare_to_impl(const RenderAttrib *other) const;
54 virtual size_t get_hash_impl() const;
55
56private:
57 void quantize_color();
58
59private:
60 Type _type;
61 LColor _color;
62 static CPT(RenderAttrib) _off;
63 static CPT(RenderAttrib) _vertex;
64
65PUBLISHED:
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
74public:
75 static void register_with_read_factory();
76 virtual void write_datagram(BamWriter *manager, Datagram &dg);
77
78protected:
79 static TypedWritable *make_from_bam(const FactoryParams &params);
80 void fillin(DatagramIterator &scan, BamReader *manager);
81
82public:
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, "ColorAttrib",
89 RenderAttrib::get_class_type());
90 _attrib_slot = register_slot(_type_handle, 100,
91 new ColorAttrib(T_vertex, LColor::zero()));
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
98private:
99 static TypeHandle _type_handle;
100 static int _attrib_slot;
101};
102
103#include "colorAttrib.I"
104
105#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
Indicates what color should be applied to renderable geometry.
Definition colorAttrib.h:27
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
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 ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.