Panda3D
Loading...
Searching...
No Matches
texMatrixAttrib.I
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.I
10 * @author drose
11 * @date 2002-03-14
12 */
13
14/**
15 * Use TexMatrixAttrib::make() to construct a new TexMatrixAttrib object.
16 */
17INLINE TexMatrixAttrib::
18TexMatrixAttrib() {
19}
20
21/**
22 * Use TexMatrixAttrib::make() to construct a new TexMatrixAttrib object.
23 */
24INLINE TexMatrixAttrib::
25TexMatrixAttrib(const TexMatrixAttrib &copy) :
26 _stages(copy._stages)
27{
28}
29
30/**
31 * Returns the override value associated with the indicated stage.
32 */
34get_override(TextureStage *stage) const {
35 Stages::const_iterator si;
36 si = _stages.find(StageNode(stage));
37 if (si != _stages.end()) {
38 return (*si)._override;
39 }
40 nassert_raise("Specified TextureStage not included in attrib");
41 return 0;
42}
43
44/**
45 * Returns the union of the Geom::GeomRendering bits that will be required
46 * once this TexMatrixAttrib is applied to a geom which includes the indicated
47 * geom_rendering bits.
48 */
50get_geom_rendering(int geom_rendering) const {
51 if ((geom_rendering & Geom::GR_point_sprite) != 0) {
52 if (!is_empty()) {
53 geom_rendering |= Geom::GR_point_sprite_tex_matrix;
54 }
55 }
56
57 return geom_rendering;
58}
59
60/**
61 *
62 */
63INLINE TexMatrixAttrib::StageNode::
64StageNode(const TextureStage *stage) :
65 // Yeah, we cast away the constness here. Just too much trouble to deal
66 // with it properly.
67 _stage((TextureStage *)stage),
68 _override(0)
69{
70}
71
72/**
73 * Compares the full attributes of StageNodes (as opposed to just the pointer
74 * compared by CompareTextureStagePointer, below).
75 */
76INLINE bool TexMatrixAttrib::StageNode::
77operator < (const TexMatrixAttrib::StageNode &other) const {
78 if (_stage != other._stage) {
79 return _stage < other._stage;
80 }
81 if (_transform != other._transform) {
82 return _transform < other._transform;
83 }
84 return _override < other._override;
85}
86
87/**
88 * This STL function object is used to sort a list of texture stages in order
89 * by pointer.
90 */
91INLINE bool TexMatrixAttrib::CompareTextureStagePointer::
92operator () (const TexMatrixAttrib::StageNode &a,
93 const TexMatrixAttrib::StageNode &b) const {
94 return a._stage < b._stage;
95}
Applies a transform matrix to UV's before they are rendered.
int get_override(TextureStage *stage) const
Returns the override value associated with the indicated stage.
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this TexMatrixAttrib is ...
Defines the properties of a named stage of the multitexture pipeline.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.