Panda3D
texMatrixAttrib.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file texMatrixAttrib.h
10  * @author drose
11  * @date 2002-03-14
12  */
13 
14 #ifndef TEXMATRIXATTRIB_H
15 #define TEXMATRIXATTRIB_H
16 
17 #include "pandabase.h"
18 
19 #include "geom.h"
20 #include "renderAttrib.h"
21 #include "textureStage.h"
22 #include "transformState.h"
23 #include "pointerTo.h"
24 
25 class FactoryParams;
26 
27 /**
28  * Applies a transform matrix to UV's before they are rendered.
29  */
30 class EXPCL_PANDA_PGRAPH TexMatrixAttrib : public RenderAttrib {
31 protected:
32  INLINE TexMatrixAttrib();
33  INLINE TexMatrixAttrib(const TexMatrixAttrib &copy);
34 
35 public:
36  virtual ~TexMatrixAttrib();
37 
38 PUBLISHED:
39  static CPT(RenderAttrib) make();
40  static CPT(RenderAttrib) make(const LMatrix4 &mat);
41  static CPT(RenderAttrib) make(TextureStage *stage, const TransformState *transform);
42  static CPT(RenderAttrib) make_default();
43 
44  CPT(RenderAttrib) add_stage(TextureStage *stage, const TransformState *transform, int override = 0) const;
45  CPT(RenderAttrib) remove_stage(TextureStage *stage) const;
46 
47  bool is_empty() const;
48  bool has_stage(TextureStage *stage) const;
49 
50  int get_num_stages() const;
51  TextureStage *get_stage(int n) const;
52  MAKE_SEQ(get_stages, get_num_stages, get_stage);
53 
54  const LMatrix4 &get_mat() const;
55  const LMatrix4 &get_mat(TextureStage *stage) const;
56 
57  CPT(TransformState) get_transform(TextureStage *stage) const;
58  INLINE int get_override(TextureStage *stage) const;
59 
60  INLINE int get_geom_rendering(int geom_rendering) const;
61 
62 public:
63  virtual void output(std::ostream &out) const;
64 
65 protected:
66  virtual int compare_to_impl(const RenderAttrib *other) const;
67  virtual size_t get_hash_impl() const;
68  virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
69  virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
70 
71 private:
72  INLINE void check_stage_list() const;
73  void rebuild_stage_list();
74 
75 private:
76  class StageNode {
77  public:
78  INLINE StageNode(const TextureStage *stage);
79 
80  INLINE bool operator < (const StageNode &other) const;
81 
82  PT(TextureStage) _stage;
83  CPT(TransformState) _transform;
84  int _override;
85  };
86 
87  class CompareTextureStagePointer {
88  public:
89  INLINE bool operator () (const TexMatrixAttrib::StageNode &a, const TexMatrixAttrib::StageNode &b) const;
90  };
91 
93  Stages _stages;
94 
95  static CPT(RenderAttrib) _empty_attrib;
96 
97 PUBLISHED:
98  static int get_class_slot() {
99  return _attrib_slot;
100  }
101  virtual int get_slot() const {
102  return get_class_slot();
103  }
104  MAKE_PROPERTY(class_slot, get_class_slot);
105 
106 public:
107  static void register_with_read_factory();
108  virtual void write_datagram(BamWriter *manager, Datagram &dg);
109  virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
110 
111 protected:
112  static TypedWritable *make_from_bam(const FactoryParams &params);
113  void fillin(DatagramIterator &scan, BamReader *manager);
114 
115 public:
116  static TypeHandle get_class_type() {
117  return _type_handle;
118  }
119  static void init_type() {
120  RenderAttrib::init_type();
121  register_type(_type_handle, "TexMatrixAttrib",
122  RenderAttrib::get_class_type());
123  _attrib_slot = register_slot(_type_handle, 100, new TexMatrixAttrib);
124  }
125  virtual TypeHandle get_type() const {
126  return get_class_type();
127  }
128  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
129 
130 private:
131  static TypeHandle _type_handle;
132  static int _attrib_slot;
133 };
134 
135 #include "texMatrixAttrib.I"
136 
137 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:51
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 ...
Definition: renderAttrib.I:101
Applies a transform matrix to UV's before they are rendered.
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:35
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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().
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
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.