Panda3D

Loading...
Searching...
No Matches
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
38PUBLISHED:
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
92 typedef ov_set<StageNode, CompareTextureStagePointer> Stages;
93 Stages _stages;
94
95 static CPT(RenderAttrib) _empty_attrib;
96
97PUBLISHED:
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
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
RenderAttrib::write_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.
Definition renderAttrib.cxx:527
RenderAttrib::register_slot
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
TexMatrixAttrib::is_empty
bool is_empty() const
Returns true if no stages are defined in the TexMatrixAttrib, false if at least one is.
Definition texMatrixAttrib.cxx:124
TexMatrixAttrib::get_transform
ConstPointerTo< TransformState > get_transform(TextureStage *stage) const
Returns the transformation associated with the indicated texture stage, or identity matrix if nothing...
Definition texMatrixAttrib.cxx:172
TexMatrixAttrib::make
static ConstPointerTo< RenderAttrib > make()
Constructs a TexMatrixAttrib that applies no stages at all.
Definition texMatrixAttrib.cxx:38
TexMatrixAttrib::get_mat
const LMatrix4 & get_mat() const
Returns the transformation matrix associated with the default texture stage.
Definition texMatrixAttrib.cxx:115
TexMatrixAttrib::add_stage
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.
Definition texMatrixAttrib.cxx:89
TexMatrixAttrib::remove_stage
ConstPointerTo< RenderAttrib > remove_stage(TextureStage *stage) const
Returns a new TexMatrixAttrib just like this one, with the indicated stage removed.
Definition texMatrixAttrib.cxx:104
TexMatrixAttrib::has_stage
bool has_stage(TextureStage *stage) const
Returns true if there is a transform associated with the indicated stage, or false otherwise (in whic...
Definition texMatrixAttrib.cxx:134
TexMatrixAttrib::get_num_stages
get_num_stages
Returns the number of stages that are represented by this attrib.
Definition texMatrixAttrib.h:52
TexMatrixAttrib::get_override
int get_override(TextureStage *stage) const
Returns the override value associated with the indicated stage.
Definition texMatrixAttrib.I:34
TexMatrixAttrib::make_default
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
Definition texMatrixAttrib.cxx:79
TexMatrixAttrib::get_geom_rendering
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this TexMatrixAttrib is ...
Definition texMatrixAttrib.I:50
TexMatrixAttrib::get_stage
get_stage
Returns the nth stage that is represented by this attrib.
Definition texMatrixAttrib.h:52
TextureStage
Defines the properties of a named stage of the multitexture pipeline.
Definition textureStage.h:35
TransformState
Indicates a coordinate-system transform on vertices.
Definition transformState.h:54
TypedWritable::complete_pointers
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().
Definition typedWritable.cxx:81
geom.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
renderAttrib.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
texMatrixAttrib.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
textureStage.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
transformState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.