23 int LightRampAttrib::_attrib_slot;
32 if (_default ==
nullptr) {
34 _default = return_new(attrib);
47 attrib->_mode = LRT_identity;
48 return return_new(attrib);
64 make_single_threshold(PN_stdfloat thresh0, PN_stdfloat val0) {
66 attrib->_mode = LRT_single_threshold;
67 attrib->_threshold[0] = thresh0;
68 attrib->_level[0] = val0;
69 return return_new(attrib);
87 make_double_threshold(PN_stdfloat thresh0, PN_stdfloat val0, PN_stdfloat thresh1, PN_stdfloat val1) {
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);
119 attrib->_mode = LRT_hdr0;
120 return return_new(attrib);
145 attrib->_mode = LRT_hdr1;
146 return return_new(attrib);
171 attrib->_mode = LRT_hdr2;
172 return return_new(attrib);
178 void LightRampAttrib::
179 output(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] <<
")";
218 int LightRampAttrib::
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;
245 size_t LightRampAttrib::
246 get_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);
303 void 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++) {
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
static void register_with_read_factory()
Tells the BamReader how to create objects of type LightRampAttrib.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A Light Ramp is any unary operator that takes a rendered pixel as input, and adjusts the brightness o...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
This hash_compare class hashes a float or a double.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_int8(int8_t value)
Adds a signed 8-bit integer to the datagram.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
CPT(RenderAttrib) LightRampAttrib CPT(RenderAttrib) LightRampAttrib
Constructs a new LightRampAttrib object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
size_t add_hash(size_t start, const Key &key) const
Adds the indicated key into a running hash.
A class to retrieve the individual data elements previously stored in a Datagram.
int8_t get_int8()
Extracts a signed 8-bit integer.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.