Panda3D
eggVertexUV.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 eggVertexUV.I
10  * @author drose
11  * @date 2004-07-20
12  */
13 
14 /**
15  * Returns the actual name that should be set for a given name string.
16  * Usually this is the same string that is input, but for historical reasons
17  * the texture coordinate name "default" is mapped to the empty string.
18  */
19 INLINE std::string EggVertexUV::
20 filter_name(const std::string &name) {
21  if (name == "default") {
22  return std::string();
23  }
24  return name;
25 }
26 
27 /**
28  *
29  */
30 INLINE void EggVertexUV::
31 set_name(const std::string &name) {
32  Namable::set_name(filter_name(name));
33 }
34 
35 /**
36  * Returns the number of components of the texture coordinate set. This is
37  * either 2 (the normal case) or 3 (for a 3-d texture coordinate).
38  */
39 INLINE int EggVertexUV::
41  return has_w() ? 3 : 2;
42 }
43 
44 /**
45  * Returns true if the texture coordinate has a third, w component, false if
46  * it is just a normal 2-d texture coordinate.
47  */
48 INLINE bool EggVertexUV::
49 has_w() const {
50  return (_flags & F_has_w) != 0;
51 }
52 
53 /**
54  * Returns the texture coordinate pair, if get_num_dimensions() is 2.
55  */
56 INLINE LTexCoordd EggVertexUV::
57 get_uv() const {
58  nassertr(!has_w(), LTexCoordd::zero());
59  return LTexCoordd(_uvw[0], _uvw[1]);
60 }
61 
62 /**
63  * Returns the texture coordinate triple, if get_num_dimensions() is 3. This
64  * is also legal to call if get_num_dimensions() is 2 (but the last dimension
65  * will be zero).
66  */
67 INLINE const LTexCoord3d &EggVertexUV::
68 get_uvw() const {
69  return _uvw;
70 }
71 
72 /**
73  * Sets the texture coordinate pair. This makes the texture coordinate a 2-d
74  * texture coordinate, which is the usual case.
75  */
76 INLINE void EggVertexUV::
77 set_uv(const LTexCoordd &uv) {
78  _uvw.set(uv[0], uv[1], 0.0);
79  _flags &= ~F_has_w;
80 }
81 
82 /**
83  * Sets the texture coordinate triple. This makes the texture coordinate a
84  * 3-d texture coordinate.
85  */
86 INLINE void EggVertexUV::
87 set_uvw(const LTexCoord3d &uvw) {
88  _uvw = uvw;
89  _flags |= F_has_w;
90 }
91 
92 /**
93  *
94  */
95 INLINE bool EggVertexUV::
96 has_tangent() const {
97  return (_flags & F_has_tangent) != 0;
98 }
99 
100 /**
101  *
102  */
103 INLINE const LNormald &EggVertexUV::
104 get_tangent() const {
105  nassertr(has_tangent(), _tangent);
106  return _tangent;
107 }
108 
109 /**
110  *
111  */
112 INLINE void EggVertexUV::
113 set_tangent(const LNormald &tangent) {
114  _tangent = tangent;
115  _flags |= F_has_tangent;
116 }
117 
118 /**
119  *
120  */
121 INLINE void EggVertexUV::
122 clear_tangent() {
123  _flags &= ~F_has_tangent;
124 }
125 
126 /**
127  *
128  */
129 INLINE bool EggVertexUV::
130 has_binormal() const {
131  return (_flags & F_has_binormal) != 0;
132 }
133 
134 /**
135  *
136  */
137 INLINE const LNormald &EggVertexUV::
138 get_binormal() const {
139  nassertr(has_binormal(), _binormal);
140  return _binormal;
141 }
142 
143 /**
144  *
145  */
146 INLINE void EggVertexUV::
147 set_binormal(const LNormald &binormal) {
148  _binormal = binormal;
149  _flags |= F_has_binormal;
150 }
151 
152 /**
153  *
154  */
155 INLINE void EggVertexUV::
156 clear_binormal() {
157  _flags &= ~F_has_binormal;
158 }
const LTexCoord3d & get_uvw() const
Returns the texture coordinate triple, if get_num_dimensions() is 3.
Definition: eggVertexUV.I:68
LTexCoordd get_uv() const
Returns the texture coordinate pair, if get_num_dimensions() is 2.
Definition: eggVertexUV.I:57
int get_num_dimensions() const
Returns the number of components of the texture coordinate set.
Definition: eggVertexUV.I:40
bool has_w() const
Returns true if the texture coordinate has a third, w component, false if it is just a normal 2-d tex...
Definition: eggVertexUV.I:49
static std::string filter_name(const std::string &name)
Returns the actual name that should be set for a given name string.
Definition: eggVertexUV.I:20
void set_uv(const LTexCoordd &texCoord)
Sets the texture coordinate pair.
Definition: eggVertexUV.I:77
void set_uvw(const LTexCoord3d &texCoord)
Sets the texture coordinate triple.
Definition: eggVertexUV.I:87