25int TexGenAttrib::_attrib_slot;
41 if (_empty_attrib ==
nullptr) {
42 _empty_attrib = return_new(
new TexGenAttrib);
53 return DCAST(TexGenAttrib,
make())->add_stage(stage, mode);
62 return return_new(
new TexGenAttrib);
72 nassertr(mode != M_constant,
this);
75 TexGenAttrib *attrib =
new TexGenAttrib(*DCAST(TexGenAttrib, removed));
77 ModeDef &mode_def = attrib->_stages[stage];
78 mode_def._mode = mode;
79 attrib->record_stage(stage, mode_def);
81 return return_new(attrib);
94 const LTexCoord3 &constant_value)
const {
95 nassertr(mode == M_constant,
this);
98 TexGenAttrib *attrib =
new TexGenAttrib(*DCAST(TexGenAttrib, removed));
100 ModeDef &mode_def = attrib->_stages[stage];
101 mode_def._mode = mode;
102 mode_def._constant_value = constant_value;
103 attrib->record_stage(stage, mode_def);
105 return return_new(attrib);
114 Stages::const_iterator si;
115 si = _stages.find(stage);
116 if (si == _stages.end()) {
120 Mode mode = (*si).second._mode;
121 TexGenAttrib *attrib =
new TexGenAttrib(*
this);
122 attrib->_stages.erase(stage);
123 attrib->_no_texcoords.erase(stage);
124 if (mode == M_point_sprite) {
125 attrib->_num_point_sprites--;
126 if (attrib->_num_point_sprites == 0) {
127 attrib->_point_geom_rendering &=
~Geom::GR_point_sprite;
130 return return_new(attrib);
139 return _stages.empty();
148 Stages::const_iterator mi = _stages.find(stage);
149 return (mi != _stages.end());
158 Stages::const_iterator mi = _stages.find(stage);
159 if (mi != _stages.end()) {
160 return (*mi).second._mode;
172 NoTexCoordStages::const_iterator mi = _no_texcoords.find(stage);
173 return (mi != _no_texcoords.end());
182 Stages::const_iterator mi = _stages.find(stage);
183 if (mi != _stages.end()) {
184 return (*mi).second._constant_value;
186 return LTexCoord3::zero();
193output(std::ostream &out)
const {
194 out << get_type() <<
":";
196 Stages::const_iterator mi;
197 for (mi = _stages.begin(); mi != _stages.end(); ++mi) {
199 const ModeDef &mode_def = (*mi).second;
200 out <<
" " << stage->
get_name() <<
"(";
201 switch (mode_def._mode) {
206 case M_eye_sphere_map:
207 out <<
"eye_sphere_map";
210 case M_world_cube_map:
211 out <<
"world_cube_map";
214 out <<
"eye_cube_map";
218 out <<
"world_normal";
224 case M_world_position:
225 out <<
"world_position";
228 out <<
"eye_position";
232 out <<
"point_sprite";
236 out <<
"constant: " << mode_def._constant_value;
260 const TexGenAttrib *ta = (
const TexGenAttrib *)other;
262 Stages::const_iterator ai, bi;
263 ai = _stages.begin();
264 bi = ta->_stages.begin();
265 while (ai != _stages.end() && bi != ta->_stages.end()) {
266 if ((*ai).first < (*bi).first) {
270 }
else if ((*bi).first < (*ai).first) {
276 int compare = (*ai).second.compare_to((*bi).second);
285 if (bi != ta->_stages.end()) {
290 if (ai != _stages.end()) {
305get_hash_impl()
const {
307 Stages::const_iterator ri;
308 for (ri = _stages.begin(); ri != _stages.end(); ++ri) {
309 const TextureStage *stage = (*ri).first;
310 const ModeDef &mode_def = (*ri).second;
315 hash = mode_def._light.add_hash(hash);
316 hash = mode_def._constant_value.add_hash(hash);
335 const TexGenAttrib *ta = (
const TexGenAttrib *)other;
340 TexGenAttrib *attrib =
new TexGenAttrib;
342 Stages::const_iterator ai, bi;
343 ai = _stages.begin();
344 bi = ta->_stages.begin();
345 while (ai != _stages.end() && bi != ta->_stages.end()) {
346 if ((*ai).first < (*bi).first) {
348 attrib->_stages.insert(attrib->_stages.end(), *ai);
351 }
else if ((*bi).first < (*ai).first) {
353 attrib->_stages.insert(attrib->_stages.end(), *bi);
358 attrib->_stages.insert(attrib->_stages.end(), *bi);
364 while (ai != _stages.end()) {
366 attrib->_stages.insert(attrib->_stages.end(), *ai);
370 while (bi != ta->_stages.end()) {
372 attrib->_stages.insert(attrib->_stages.end(), *bi);
376 attrib->filled_stages();
378 return return_new(attrib);
389 const TexGenAttrib *ta = (
const TexGenAttrib *)other;
394 TexGenAttrib *attrib =
new TexGenAttrib;
396 Stages::const_iterator ai, bi;
397 ai = _stages.begin();
398 bi = ta->_stages.begin();
399 while (ai != _stages.end() && bi != ta->_stages.end()) {
400 if ((*ai).first < (*bi).first) {
402 attrib->_stages.insert(attrib->_stages.end(), Stages::value_type((*ai).first, ModeDef()));
405 }
else if ((*bi).first < (*ai).first) {
407 attrib->_stages.insert(attrib->_stages.end(), *bi);
412 attrib->_stages.insert(attrib->_stages.end(), *bi);
418 while (ai != _stages.end()) {
420 attrib->_stages.insert(attrib->_stages.end(), Stages::value_type((*ai).first, ModeDef()));
424 while (bi != ta->_stages.end()) {
426 attrib->_stages.insert(attrib->_stages.end(), *bi);
430 attrib->filled_stages();
432 return return_new(attrib);
444 for (ri = _stages.begin(); ri != _stages.end(); ++ri) {
445 TextureStage *stage = (*ri).first;
446 ModeDef &mode_def = (*ri).second;
447 record_stage(stage, mode_def);
456record_stage(
TextureStage *stage, TexGenAttrib::ModeDef &mode_def) {
457 switch (mode_def._mode) {
459 _no_texcoords.insert(stage);
460 _point_geom_rendering |= Geom::GR_point_sprite;
461 _num_point_sprites++;
468 _no_texcoords.insert(stage);
490 Stages::const_iterator si;
491 for (si = _stages.begin(); si != _stages.end(); ++si) {
493 Mode mode = (*si).second._mode;
508 pvector<Mode>::const_iterator mi;
509 for (mi = _read_modes.begin(); mi != _read_modes.end(); ++mi) {
513 _stages[stage]._mode = mode;
533 attrib->fillin(scan, manager);
544 RenderAttrib::fillin(scan, manager);
552 _read_modes.reserve(num_stages);
553 for (
size_t i = 0; i < num_stages; i++) {
556 _read_modes.push_back(mode);
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...
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
A class to retrieve the individual data elements previously stored in a Datagram.
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
void add_uint16(uint16_t value)
Adds an unsigned 16-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 container for geometry primitives.
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.
Computes texture coordinates for geometry automatically based on vertex position and/or normal.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
bool has_gen_texcoord_stage(TextureStage *stage) const
Returns true if the indicated TextureStage will have texture coordinates generated for it automatical...
ConstPointerTo< RenderAttrib > remove_stage(TextureStage *stage) const
Returns a new TexGenAttrib just like this one, with the indicated stage removed.
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
bool has_stage(TextureStage *stage) const
Returns true if there is a mode associated with the indicated stage, or false otherwise (in which cas...
Mode get_mode(TextureStage *stage) const
Returns the generation mode associated with the named texture stage, or M_off if nothing is associate...
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexGenAttrib.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
bool is_empty() const
Returns true if no stages are defined in the TexGenAttrib, false if at least one is.
static ConstPointerTo< RenderAttrib > make()
Constructs a TexGenAttrib that generates no stages at all.
ConstPointerTo< RenderAttrib > add_stage(TextureStage *stage, Mode mode) const
Returns a new TexGenAttrib just like this one, with the indicated generation mode for the given stage...
const LTexCoord3 & get_constant_value(TextureStage *stage) const
Returns the constant value associated with the named texture stage.
Defines the properties of a named stage of the multitexture pipeline.
get_name
Returns the name of this texture stage.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
static size_t add_hash(size_t start, const int &key)
static size_t add_hash(size_t start, const void *key)
Adds the indicated key into a running hash.
static size_t add_hash(size_t start, const std::string &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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.