15 #include "rescaleNormalAttrib.h"
16 #include "graphicsStateGuardianBase.h"
17 #include "string_utils.h"
19 #include "bamReader.h"
20 #include "bamWriter.h"
22 #include "datagramIterator.h"
23 #include "configVariableEnum.h"
24 #include "config_pgraph.h"
27 int RescaleNormalAttrib::_attrib_slot;
33 (
"rescale-normals", RescaleNormalAttrib::M_auto,
34 PRC_DESC(
"Specifies the kind of RescaleNormalAttrib that should be "
35 "created for the top of the scene graph. This can automatically "
36 "ensure that your lighting normals are unit-length, which may be "
37 "particularly necessary in the presence of scales in the scene "
38 "graph. Turning it off ('none') may produce a small performance "
51 return return_new(attrib);
65 return return_new(attrib);
73 void RescaleNormalAttrib::
74 output(ostream &out)
const {
75 out << get_type() <<
":" <<
get_mode();
93 int RescaleNormalAttrib::
96 DCAST_INTO_R(ta, other, 0);
97 return (
int)_mode - (int)ta->_mode;
110 size_t RescaleNormalAttrib::
111 get_hash_impl()
const {
155 parse_params(params, scan, manager);
156 attrib->fillin(scan, manager);
168 void RescaleNormalAttrib::
170 RenderAttrib::fillin(scan, manager);
180 operator << (ostream &out, RescaleNormalAttrib::Mode mode) {
182 case RescaleNormalAttrib::M_none:
183 return out <<
"none";
185 case RescaleNormalAttrib::M_rescale:
186 return out <<
"rescale";
188 case RescaleNormalAttrib::M_normalize:
189 return out <<
"normalize";
191 case RescaleNormalAttrib::M_auto:
192 return out <<
"auto";
195 return out <<
"(**invalid RescaleNormalAttrib::Mode(" << (int)mode <<
")**)";
203 operator >> (istream &in, RescaleNormalAttrib::Mode &mode) {
207 if (cmp_nocase(word,
"none") == 0) {
208 mode = RescaleNormalAttrib::M_none;
210 }
else if (cmp_nocase(word,
"rescale") == 0) {
211 mode = RescaleNormalAttrib::M_rescale;
213 }
else if (cmp_nocase(word,
"normalize") == 0) {
214 mode = RescaleNormalAttrib::M_normalize;
216 }
else if (cmp_nocase(word,
"auto") == 0) {
217 mode = RescaleNormalAttrib::M_auto;
221 <<
"Invalid RescaleNormalAttrib::Mode value: " << word <<
"\n";
222 mode = RescaleNormalAttrib::M_none;
PN_int8 get_int8()
Extracts a signed 8-bit integer.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void add_int8(PN_int8 value)
Adds a signed 8-bit integer to the datagram.
Base class for objects that can be written to and read from Bam files.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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...
This class specializes ConfigVariable as an enumerated type.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Mode get_mode() const
Returns the render mode.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Specifies how polygons are to be drawn.
A class to retrieve the individual data elements previously stored in a Datagram. ...
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 ...
static void register_with_read_factory()
Tells the BamReader how to create objects of type RescaleNormalAttrib.