Panda3D
 All Classes Functions Variables Enumerations
texMatrixAttrib.I
1 // Filename: texMatrixAttrib.I
2 // Created by: drose (14Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TexMatrixAttrib::Constructor
18 // Access: Protected
19 // Description: Use TexMatrixAttrib::make() to construct a new
20 // TexMatrixAttrib object.
21 ////////////////////////////////////////////////////////////////////
22 INLINE TexMatrixAttrib::
23 TexMatrixAttrib() {
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: TexMatrixAttrib::Copy Constructor
28 // Access: Protected
29 // Description: Use TexMatrixAttrib::make() to construct a new
30 // TexMatrixAttrib object.
31 ////////////////////////////////////////////////////////////////////
32 INLINE TexMatrixAttrib::
33 TexMatrixAttrib(const TexMatrixAttrib &copy) :
34  _stages(copy._stages)
35 {
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: TexMatrixAttrib::get_override
40 // Access: Published
41 // Description: Returns the override value associated with the
42 // indicated stage.
43 ////////////////////////////////////////////////////////////////////
44 INLINE int TexMatrixAttrib::
45 get_override(TextureStage *stage) const {
46  Stages::const_iterator si;
47  si = _stages.find(StageNode(stage));
48  if (si != _stages.end()) {
49  return (*si)._override;
50  }
51  nassert_raise("Specified TextureStage not included in attrib");
52  return 0;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: TexMatrixAttrib::get_geom_rendering
57 // Access: Published
58 // Description: Returns the union of the Geom::GeomRendering bits
59 // that will be required once this TexMatrixAttrib is
60 // applied to a geom which includes the indicated
61 // geom_rendering bits.
62 ////////////////////////////////////////////////////////////////////
63 INLINE int TexMatrixAttrib::
64 get_geom_rendering(int geom_rendering) const {
65  if ((geom_rendering & Geom::GR_point_sprite) != 0) {
66  if (!is_empty()) {
67  geom_rendering |= Geom::GR_point_sprite_tex_matrix;
68  }
69  }
70 
71  return geom_rendering;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: TexMatrixAttrib::StageNode::Constructor
76 // Access: Public
77 // Description:
78 ////////////////////////////////////////////////////////////////////
79 INLINE TexMatrixAttrib::StageNode::
80 StageNode(const TextureStage *stage) :
81  // Yeah, we cast away the constness here. Just too much trouble to
82  // deal with it properly.
83  _stage((TextureStage *)stage),
84  _override(0)
85 {
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: TexMatrixAttrib::StageNode::operator <
90 // Access: Public
91 // Description: Compares the full attributes of StageNodes (as
92 // opposed to just the pointer compared by
93 // CompareTextureStagePointer, below).
94 ////////////////////////////////////////////////////////////////////
95 INLINE bool TexMatrixAttrib::StageNode::
96 operator < (const TexMatrixAttrib::StageNode &other) const {
97  if (_stage != other._stage) {
98  return _stage < other._stage;
99  }
100  if (_transform != other._transform) {
101  return _transform < other._transform;
102  }
103  return _override < other._override;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: TexMatrixAttrib::CompareTextureStagePointer::operator ()
108 // Access: Public
109 // Description: This STL function object is used to sort a list of
110 // texture stages in order by pointer.
111 ////////////////////////////////////////////////////////////////////
112 INLINE bool TexMatrixAttrib::CompareTextureStagePointer::
113 operator () (const TexMatrixAttrib::StageNode &a,
114  const TexMatrixAttrib::StageNode &b) const {
115  return a._stage < b._stage;
116 }
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this TexMatrixAttrib is ...
bool is_empty() const
Returns true if no stages are defined in the TexMatrixAttrib, false if at least one is...
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
int get_override(TextureStage *stage) const
Returns the override value associated with the indicated stage.
Applies a transform matrix to UV&#39;s before they are rendered.
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38