25 int TexMatrixAttrib::_attrib_slot;
41 if (_empty_attrib ==
nullptr) {
53 make(
const LMatrix4 &mat) {
55 <<
"Using deprecated TexMatrixAttrib interface.\n";
56 if (mat.is_identity()) {
60 return make(TextureStage::get_default(), transform);
90 Stages::iterator si = attrib->_stages.insert(StageNode(stage)).first;
91 (*si)._transform = transform;
92 (*si)._override =
override;
94 return return_new(attrib);
104 attrib->_stages.erase(StageNode(stage));
105 return return_new(attrib);
112 const LMatrix4 &TexMatrixAttrib::
114 return get_mat(TextureStage::get_default());
121 bool TexMatrixAttrib::
123 return _stages.
empty();
131 bool TexMatrixAttrib::
133 Stages::const_iterator mi = _stages.find(StageNode(stage));
134 return (mi != _stages.
end());
140 int TexMatrixAttrib::
141 get_num_stages()
const {
142 return _stages.
size();
150 get_stage(
int n)
const {
151 nassertr(n >= 0 && n < (
int)_stages.
size(),
nullptr);
152 return _stages[n]._stage;
160 const LMatrix4 &TexMatrixAttrib::
162 return get_transform(stage)->get_mat();
171 Stages::const_iterator mi = _stages.find(StageNode(stage));
172 if (mi != _stages.
end()) {
173 return (*mi)._transform;
175 return TransformState::make_identity();
181 void TexMatrixAttrib::
182 output(std::ostream &out)
const {
183 out << get_type() <<
":";
185 Stages::const_iterator mi;
186 for (mi = _stages.
begin(); mi != _stages.
end(); ++mi) {
187 const StageNode &sn = (*mi);
188 out <<
" " << sn._stage->
get_name() <<
"(" << *sn._transform <<
")";
189 if (sn._override != 0) {
190 out <<
"^" << sn._override;
207 int TexMatrixAttrib::
211 Stages::const_iterator ai, bi;
212 ai = _stages.
begin();
213 bi = ta->_stages.
begin();
214 while (ai != _stages.
end() && bi != ta->_stages.
end()) {
219 }
else if ((*bi) < (*ai)) {
230 if (bi != ta->_stages.
end()) {
235 if (ai != _stages.
end()) {
249 size_t TexMatrixAttrib::
250 get_hash_impl()
const {
252 Stages::const_iterator si;
253 for (si = _stages.
begin(); si != _stages.
end(); ++si) {
254 const StageNode &sn = (*si);
284 Stages::const_iterator ai, bi;
285 ai = _stages.
begin();
286 bi = ta->_stages.
begin();
287 while (ai != _stages.
end() && bi != ta->_stages.
end()) {
288 if ((*ai)._stage < (*bi)._stage) {
290 attrib->_stages.insert(attrib->_stages.
end(), *ai);
293 }
else if ((*bi)._stage < (*ai)._stage) {
295 attrib->_stages.insert(attrib->_stages.
end(), *bi);
300 if ((*ai)._override == (*bi)._override) {
302 CPT(
TransformState) new_transform = (*ai)._transform->compose((*bi)._transform);
303 StageNode sn((*ai)._stage);
304 sn._transform = new_transform;
305 sn._override = (*ai)._override;
306 attrib->_stages.insert(attrib->_stages.
end(), sn);
307 }
else if ((*ai)._override < (*bi)._override) {
309 attrib->_stages.insert(attrib->_stages.
end(), *bi);
312 attrib->_stages.insert(attrib->_stages.
end(), *ai);
320 while (ai != _stages.
end()) {
322 attrib->_stages.insert(attrib->_stages.
end(), *ai);
326 while (bi != ta->_stages.
end()) {
328 attrib->_stages.insert(attrib->_stages.
end(), *bi);
332 return return_new(attrib);
350 Stages::const_iterator ai, bi;
351 ai = _stages.
begin();
352 bi = ta->_stages.
begin();
353 while (ai != _stages.
end() && bi != ta->_stages.
end()) {
354 if ((*ai)._stage < (*bi)._stage) {
357 (*ai)._transform->invert_compose(TransformState::make_identity());
358 StageNode sn((*ai)._stage);
359 sn._transform = inv_a;
360 sn._override = (*ai)._override;
361 attrib->_stages.insert(attrib->_stages.
end(), sn);
364 }
else if ((*bi)._stage < (*ai)._stage) {
366 attrib->_stages.insert(attrib->_stages.
end(), *bi);
371 if ((*ai)._override == (*bi)._override) {
373 CPT(
TransformState) new_transform = (*ai)._transform->invert_compose((*bi)._transform);
374 StageNode sn((*ai)._stage);
375 sn._transform = new_transform;
376 sn._override = (*ai)._override;
377 attrib->_stages.insert(attrib->_stages.
end(), sn);
379 }
else if ((*ai)._override < (*bi)._override) {
381 attrib->_stages.insert(attrib->_stages.
end(), *bi);
386 (*ai)._transform->invert_compose(TransformState::make_identity());
387 StageNode sn((*ai)._stage);
388 sn._transform = inv_a;
389 sn._override = (*ai)._override;
390 attrib->_stages.insert(attrib->_stages.
end(), sn);
398 while (ai != _stages.
end()) {
401 (*ai)._transform->invert_compose(TransformState::make_identity());
402 StageNode sn((*ai)._stage);
403 sn._transform = inv_a;
404 sn._override = (*ai)._override;
405 attrib->_stages.insert(attrib->_stages.
end(), sn);
409 while (bi != ta->_stages.
end()) {
411 attrib->_stages.insert(attrib->_stages.
end(), *bi);
415 return return_new(attrib);
421 void TexMatrixAttrib::
422 register_with_read_factory() {
436 Stages::const_iterator si;
437 for (si = _stages.
begin(); si != _stages.
end(); ++si) {
438 const StageNode &sn = (*si);
457 for (
size_t sni = 0; sni < _stages.
size(); ++sni) {
464 StageNode &sn = _stages[sni];
466 sn._transform = transform;
485 attrib->fillin(scan, manager);
494 void TexMatrixAttrib::
496 RenderAttrib::fillin(scan, manager);
499 for (
size_t i = 0; i < num_stages; i++) {
507 StageNode sn(
nullptr);
508 sn._override =
override;
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.
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...
size_type_0 size() const
Returns the number of elements in the ordered vector.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
CPT(RenderAttrib) TexMatrixAttrib
Constructs a TexMatrixAttrib that applies no stages at all.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
int32_t get_int32()
Extracts a signed 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
get_name
Returns the name of the type.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
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_uint16(uint16_t value)
Adds an unsigned 16-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 int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
void sort()
Maps to sort_unique().
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
Applies a transform matrix to UV's before they are rendered.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from 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.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Defines the properties of a named stage of the multitexture pipeline.
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.
static TextureStage * get_stage(TextureStage *temp)
Returns a TextureStage pointer that represents the same TextureStage described by temp,...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.