25int TexMatrixAttrib::_attrib_slot;
41 if (_empty_attrib ==
nullptr) {
42 _empty_attrib = return_new(
new TexMatrixAttrib);
55make(
const LMatrix4 &mat) {
57 <<
"Using deprecated TexMatrixAttrib interface.\n";
58 if (mat.is_identity()) {
71 return DCAST(TexMatrixAttrib,
make())->add_stage(stage, transform);
80 return return_new(
new TexMatrixAttrib);
91 TexMatrixAttrib *attrib =
new TexMatrixAttrib(*
this);
92 Stages::iterator si = attrib->_stages.insert(StageNode(stage)).first;
93 (*si)._transform = transform;
94 (*si)._override =
override;
96 return return_new(attrib);
105 TexMatrixAttrib *attrib =
new TexMatrixAttrib(*
this);
106 attrib->_stages.erase(StageNode(stage));
107 return return_new(attrib);
125 return _stages.empty();
135 Stages::const_iterator mi = _stages.find(StageNode(stage));
136 return (mi != _stages.end());
144 return _stages.
size();
153 nassertr(n >= 0 && n < (
int)_stages.size(),
nullptr);
154 return _stages[n]._stage;
173 Stages::const_iterator mi = _stages.find(StageNode(stage));
174 if (mi != _stages.end()) {
175 return (*mi)._transform;
177 return TransformState::make_identity();
183void TexMatrixAttrib::
184output(std::ostream &out)
const {
185 out << get_type() <<
":";
187 Stages::const_iterator mi;
188 for (mi = _stages.
begin(); mi != _stages.
end(); ++mi) {
189 const StageNode &sn = (*mi);
190 out <<
" " << sn._stage->get_name() <<
"(" << *sn._transform <<
")";
191 if (sn._override != 0) {
192 out <<
"^" << sn._override;
211 const TexMatrixAttrib *ta = (
const TexMatrixAttrib *)other;
213 Stages::const_iterator ai, bi;
214 ai = _stages.begin();
215 bi = ta->_stages.
begin();
216 while (ai != _stages.end() && bi != ta->_stages.
end()) {
221 }
else if ((*bi) < (*ai)) {
232 if (bi != ta->_stages.
end()) {
237 if (ai != _stages.end()) {
251size_t TexMatrixAttrib::
252get_hash_impl()
const {
254 Stages::const_iterator si;
255 for (si = _stages.begin(); si != _stages.end(); ++si) {
256 const StageNode &sn = (*si);
279 const TexMatrixAttrib *ta = (
const TexMatrixAttrib *)other;
284 TexMatrixAttrib *attrib =
new TexMatrixAttrib;
286 Stages::const_iterator ai, bi;
287 ai = _stages.begin();
288 bi = ta->_stages.
begin();
289 while (ai != _stages.end() && bi != ta->_stages.
end()) {
290 if ((*ai)._stage < (*bi)._stage) {
292 attrib->_stages.insert(attrib->_stages.
end(), *ai);
295 }
else if ((*bi)._stage < (*ai)._stage) {
297 attrib->_stages.insert(attrib->_stages.
end(), *bi);
302 if ((*ai)._override == (*bi)._override) {
304 CPT(
TransformState) new_transform = (*ai)._transform->compose((*bi)._transform);
305 StageNode sn((*ai)._stage);
306 sn._transform = new_transform;
307 sn._override = (*ai)._override;
308 attrib->_stages.insert(attrib->_stages.
end(), sn);
309 }
else if ((*ai)._override < (*bi)._override) {
311 attrib->_stages.insert(attrib->_stages.
end(), *bi);
314 attrib->_stages.insert(attrib->_stages.
end(), *ai);
322 while (ai != _stages.end()) {
324 attrib->_stages.insert(attrib->_stages.
end(), *ai);
328 while (bi != ta->_stages.
end()) {
330 attrib->_stages.insert(attrib->_stages.
end(), *bi);
334 return return_new(attrib);
345 const TexMatrixAttrib *ta = (
const TexMatrixAttrib *)other;
350 TexMatrixAttrib *attrib =
new TexMatrixAttrib;
352 Stages::const_iterator ai, bi;
353 ai = _stages.begin();
354 bi = ta->_stages.
begin();
355 while (ai != _stages.end() && bi != ta->_stages.
end()) {
356 if ((*ai)._stage < (*bi)._stage) {
359 (*ai)._transform->invert_compose(TransformState::make_identity());
360 StageNode sn((*ai)._stage);
361 sn._transform = inv_a;
362 sn._override = (*ai)._override;
363 attrib->_stages.insert(attrib->_stages.
end(), sn);
366 }
else if ((*bi)._stage < (*ai)._stage) {
368 attrib->_stages.insert(attrib->_stages.
end(), *bi);
373 if ((*ai)._override == (*bi)._override) {
375 CPT(
TransformState) new_transform = (*ai)._transform->invert_compose((*bi)._transform);
376 StageNode sn((*ai)._stage);
377 sn._transform = new_transform;
378 sn._override = (*ai)._override;
379 attrib->_stages.insert(attrib->_stages.
end(), sn);
381 }
else if ((*ai)._override < (*bi)._override) {
383 attrib->_stages.insert(attrib->_stages.
end(), *bi);
388 (*ai)._transform->invert_compose(TransformState::make_identity());
389 StageNode sn((*ai)._stage);
390 sn._transform = inv_a;
391 sn._override = (*ai)._override;
392 attrib->_stages.insert(attrib->_stages.
end(), sn);
400 while (ai != _stages.end()) {
403 (*ai)._transform->invert_compose(TransformState::make_identity());
404 StageNode sn((*ai)._stage);
405 sn._transform = inv_a;
406 sn._override = (*ai)._override;
407 attrib->_stages.insert(attrib->_stages.
end(), sn);
411 while (bi != ta->_stages.
end()) {
413 attrib->_stages.insert(attrib->_stages.
end(), *bi);
417 return return_new(attrib);
438 Stages::const_iterator si;
439 for (si = _stages.begin(); si != _stages.end(); ++si) {
440 const StageNode &sn = (*si);
459 for (
size_t sni = 0; sni < _stages.size(); ++sni) {
466 StageNode &sn = _stages[sni];
468 sn._transform = transform;
487 attrib->fillin(scan, manager);
496void TexMatrixAttrib::
498 RenderAttrib::fillin(scan, manager);
501 for (
size_t i = 0; i < num_stages; i++) {
509 StageNode sn(
nullptr);
510 sn._override =
override;
511 _stages.push_back(sn);
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.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
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.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
int32_t get_int32()
Extracts a signed 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_int32(int32_t value)
Adds a signed 32-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.
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.
Applies a transform matrix to UV's before they are rendered.
static void register_with_read_factory()
Tells the BamReader how to create objects of type TexMatrixAttrib.
bool is_empty() const
Returns true if no stages are defined in the TexMatrixAttrib, false if at least one is.
ConstPointerTo< TransformState > get_transform(TextureStage *stage) const
Returns the transformation associated with the indicated texture stage, or identity matrix if nothing...
static ConstPointerTo< RenderAttrib > make()
Constructs a TexMatrixAttrib that applies no stages at all.
const LMatrix4 & get_mat() const
Returns the transformation matrix associated with the default texture stage.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
ConstPointerTo< RenderAttrib > add_stage(TextureStage *stage, const TransformState *transform, int override=0) const
Returns a new TexMatrixAttrib just like this one, with the indicated transform for the given stage.
ConstPointerTo< RenderAttrib > remove_stage(TextureStage *stage) const
Returns a new TexMatrixAttrib just like this one, with the indicated stage removed.
bool has_stage(TextureStage *stage) const
Returns true if there is a transform associated with the indicated stage, or false otherwise (in whic...
get_num_stages
Returns the number of stages that are represented by this attrib.
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
get_stage
Returns the nth stage that is represented by this attrib.
static TextureStage * get_stage(TextureStage *temp)
Returns a TextureStage pointer that represents the same TextureStage described by temp,...
Defines the properties of a named stage of the multitexture pipeline.
get_default
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
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)
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
size_type_0 size() const
Returns the number of elements in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
static size_t add_hash(size_t start, const void *key)
Adds the indicated key into a running hash.
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.