23int LightRampAttrib::_attrib_slot;
32 if (_default ==
nullptr) {
33 LightRampAttrib *attrib =
new LightRampAttrib();
34 _default = return_new(attrib);
46 LightRampAttrib *attrib =
new LightRampAttrib();
47 attrib->_mode = LRT_identity;
48 return return_new(attrib);
65 LightRampAttrib *attrib =
new LightRampAttrib();
66 attrib->_mode = LRT_single_threshold;
67 attrib->_threshold[0] = thresh0;
68 attrib->_level[0] = val0;
69 return return_new(attrib);
88 LightRampAttrib *attrib =
new LightRampAttrib();
89 attrib->_mode = LRT_double_threshold;
90 attrib->_threshold[0] = thresh0;
91 attrib->_level[0] = val0;
92 attrib->_threshold[1] = thresh1;
93 attrib->_level[1] = val1;
94 return return_new(attrib);
118 LightRampAttrib *attrib =
new LightRampAttrib();
119 attrib->_mode = LRT_hdr0;
120 return return_new(attrib);
144 LightRampAttrib *attrib =
new LightRampAttrib();
145 attrib->_mode = LRT_hdr1;
146 return return_new(attrib);
170 LightRampAttrib *attrib =
new LightRampAttrib();
171 attrib->_mode = LRT_hdr2;
172 return return_new(attrib);
178void LightRampAttrib::
179output(std::ostream &out)
const {
180 out << get_type() <<
":";
188 case LRT_single_threshold:
189 out <<
"single_threshold(" << _level[0] <<
"," << _level[1] <<
"," << _threshold[0] <<
")";
191 case LRT_double_threshold:
192 out <<
"double_threshold(" << _level[0] <<
"," << _level[1] <<
"," << _threshold[0] <<
"," << _threshold[1] <<
")";
220 const LightRampAttrib *ta = (
const LightRampAttrib *)other;
222 int compare_result = ((int)_mode - (int)ta->_mode) ;
223 if (compare_result != 0) {
224 return compare_result;
226 for (
int i = 0; i < 2; i++) {
227 if (_level[i] != ta->_level[i]) {
228 return (_level[i] < ta->_level[i]) ? -1 : 1;
231 for (
int i = 0; i < 2; i++) {
232 if (_threshold[i] != ta->_threshold[i]) {
233 return (_threshold[i] < ta->_threshold[i]) ? -1 : 1;
245size_t LightRampAttrib::
246get_hash_impl()
const {
250 for (
int i = 0; i < 2; i++) {
251 hash = fh.
add_hash(hash, _level[i]);
252 hash = fh.
add_hash(hash, _threshold[i]);
274 for (
int i=0; i<2; i++) {
277 for (
int i=0; i<2; i++) {
294 attrib->fillin(scan, manager);
303void LightRampAttrib::
305 RenderAttrib::fillin(scan, manager);
307 _mode = (LightRampMode)scan.
get_int8();
308 for (
int i=0; i<2; i++) {
311 for (
int i=0; i<2; i++) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
int8_t get_int8()
Extracts a signed 8-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_int8(int8_t value)
Adds a signed 8-bit integer to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
A Light Ramp is any unary operator that takes a rendered pixel as input, and adjusts the brightness 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.
static ConstPointerTo< RenderAttrib > make_hdr2()
Constructs a new LightRampAttrib object.
static ConstPointerTo< RenderAttrib > make_single_threshold(PN_stdfloat thresh0, PN_stdfloat lev0)
Constructs a new LightRampAttrib object.
static ConstPointerTo< RenderAttrib > make_identity()
Constructs a new LightRampAttrib object.
static void register_with_read_factory()
Tells the BamReader how to create objects of type LightRampAttrib.
static ConstPointerTo< RenderAttrib > make_double_threshold(PN_stdfloat thresh0, PN_stdfloat lev0, PN_stdfloat thresh1, PN_stdfloat lev1)
Constructs a new LightRampAttrib object.
static ConstPointerTo< RenderAttrib > make_hdr1()
Constructs a new LightRampAttrib object.
static ConstPointerTo< RenderAttrib > make_default()
Constructs a new LightRampAttrib object.
static ConstPointerTo< RenderAttrib > make_hdr0()
Constructs a new LightRampAttrib object.
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.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
size_t add_hash(size_t start, const Key &key) const
Adds the indicated key into a running hash.
static size_t add_hash(size_t start, const int &key)
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.