30 int RescaleNormalAttrib::_attrib_slot;
31 CPT(
RenderAttrib) RescaleNormalAttrib::_attribs[RescaleNormalAttrib::M_auto + 1];
39 make(RescaleNormalAttrib::Mode mode) {
40 if (_attribs[mode].is_null()) {
45 return _attribs[mode];
51 void RescaleNormalAttrib::
52 output(ostream &out)
const {
53 out << get_type() <<
":" <<
get_mode();
68 int RescaleNormalAttrib::
71 return (
int)_mode - (int)ta->_mode;
80 size_t RescaleNormalAttrib::
81 get_hash_impl()
const {
118 attrib->fillin(scan, manager);
127 void RescaleNormalAttrib::
129 RenderAttrib::fillin(scan, manager);
137 void RescaleNormalAttrib::
139 RenderAttrib::init_type();
141 RenderAttrib::get_class_type());
147 (
"rescale-normals", RescaleNormalAttrib::M_auto,
148 PRC_DESC(
"Specifies the kind of RescaleNormalAttrib that should be " 149 "created for the top of the scene graph. This can automatically " 150 "ensure that your lighting normals are unit-length, which may be " 151 "particularly necessary in the presence of scales in the scene " 152 "graph. Turning it off ('none') may produce a small performance " 155 Mode mode = rescale_normals;
158 _attribs[mode] = attrib;
165 operator << (ostream &out, RescaleNormalAttrib::Mode mode) {
167 case RescaleNormalAttrib::M_none:
168 return out <<
"none";
170 case RescaleNormalAttrib::M_rescale:
171 return out <<
"rescale";
173 case RescaleNormalAttrib::M_normalize:
174 return out <<
"normalize";
176 case RescaleNormalAttrib::M_auto:
177 return out <<
"auto";
180 return out <<
"(**invalid RescaleNormalAttrib::Mode(" << (int)mode <<
")**)";
187 operator >> (istream &in, RescaleNormalAttrib::Mode &mode) {
191 if (cmp_nocase(word,
"none") == 0) {
192 mode = RescaleNormalAttrib::M_none;
194 }
else if (cmp_nocase(word,
"rescale") == 0) {
195 mode = RescaleNormalAttrib::M_rescale;
197 }
else if (cmp_nocase(word,
"normalize") == 0) {
198 mode = RescaleNormalAttrib::M_normalize;
200 }
else if (cmp_nocase(word,
"auto") == 0) {
201 mode = RescaleNormalAttrib::M_auto;
205 <<
"Invalid RescaleNormalAttrib::Mode value: " << word <<
"\n";
206 mode = RescaleNormalAttrib::M_none;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
get_mode
Returns the render mode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
CPT(RenderAttrib) RescaleNormalAttrib CPT(RenderAttrib) RescaleNormalAttrib
Constructs a new RescaleNormalAttrib object that specifies whether to rescale normals to compensate f...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static size_t add_hash(size_t start, const Key &key)
Adds the indicated key into a running hash.
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.
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 ...
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.
This class specializes ConfigVariable as an enumerated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
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 ...
static void register_with_read_factory()
Tells the BamReader how to create objects of type RescaleNormalAttrib.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.