Panda3D
 All Classes Functions Variables Enumerations
eggVertexUV.I
1 // Filename: eggVertexUV.I
2 // Created by: drose (20Jul04)
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: EggVertexUV::filter_name
18 // Access: Published, Static
19 // Description: Returns the actual name that should be set for a
20 // given name string. Usually this is the same string
21 // that is input, but for historical reasons the texture
22 // coordinate name "default" is mapped to the empty
23 // string.
24 ////////////////////////////////////////////////////////////////////
25 INLINE string EggVertexUV::
26 filter_name(const string &name) {
27  if (name == "default") {
28  return string();
29  }
30  return name;
31 }
32 
33 ////////////////////////////////////////////////////////////////////
34 // Function: EggVertexUV::set_name
35 // Access: Published
36 // Description:
37 ////////////////////////////////////////////////////////////////////
38 INLINE void EggVertexUV::
39 set_name(const string &name) {
40  Namable::set_name(filter_name(name));
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: EggVertexUV::get_num_dimensions
45 // Access: Published
46 // Description: Returns the number of components of the texture
47 // coordinate set. This is either 2 (the normal case)
48 // or 3 (for a 3-d texture coordinate).
49 ////////////////////////////////////////////////////////////////////
50 INLINE int EggVertexUV::
52  return has_w() ? 3 : 2;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: EggVertexUV::has_w
57 // Access: Published
58 // Description: Returns true if the texture coordinate has a third, w
59 // component, false if it is just a normal 2-d texture
60 // coordinate.
61 ////////////////////////////////////////////////////////////////////
62 INLINE bool EggVertexUV::
63 has_w() const {
64  return (_flags & F_has_w) != 0;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: EggVertexUV::get_uv
69 // Access: Published
70 // Description: Returns the texture coordinate pair, if
71 // get_num_dimensions() is 2.
72 ////////////////////////////////////////////////////////////////////
74 get_uv() const {
75  nassertr(!has_w(), LTexCoordd::zero());
76  return LTexCoordd(_uvw[0], _uvw[1]);
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: EggVertexUV::get_uvw
81 // Access: Published
82 // Description: Returns the texture coordinate triple, if
83 // get_num_dimensions() is 3. This is also legal to
84 // call if get_num_dimensions() is 2 (but the last
85 // dimension will be zero).
86 ////////////////////////////////////////////////////////////////////
87 INLINE const LTexCoord3d &EggVertexUV::
88 get_uvw() const {
89  return _uvw;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: EggVertexUV::set_uv
94 // Access: Published
95 // Description: Sets the texture coordinate pair. This makes the
96 // texture coordinate a 2-d texture coordinate, which is
97 // the usual case.
98 ////////////////////////////////////////////////////////////////////
99 INLINE void EggVertexUV::
100 set_uv(const LTexCoordd &uv) {
101  _uvw.set(uv[0], uv[1], 0.0);
102  _flags &= ~F_has_w;
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: EggVertexUV::set_uvw
107 // Access: Published
108 // Description: Sets the texture coordinate triple. This makes the
109 // texture coordinate a 3-d texture coordinate.
110 ////////////////////////////////////////////////////////////////////
111 INLINE void EggVertexUV::
112 set_uvw(const LTexCoord3d &uvw) {
113  _uvw = uvw;
114  _flags |= F_has_w;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: EggVertexUV::has_tangent
119 // Access: Published
120 // Description:
121 ////////////////////////////////////////////////////////////////////
122 INLINE bool EggVertexUV::
123 has_tangent() const {
124  return (_flags & F_has_tangent) != 0;
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: EggVertexUV::get_tangent
129 // Access: Published
130 // Description:
131 ////////////////////////////////////////////////////////////////////
132 INLINE const LNormald &EggVertexUV::
133 get_tangent() const {
134  nassertr(has_tangent(), _tangent);
135  return _tangent;
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: EggVertexUV::set_tangent
140 // Access: Published
141 // Description:
142 ////////////////////////////////////////////////////////////////////
143 INLINE void EggVertexUV::
144 set_tangent(const LNormald &tangent) {
145  _tangent = tangent;
146  _flags |= F_has_tangent;
147 }
148 
149 ////////////////////////////////////////////////////////////////////
150 // Function: EggVertexUV::clear_tangent
151 // Access: Published
152 // Description:
153 ////////////////////////////////////////////////////////////////////
154 INLINE void EggVertexUV::
155 clear_tangent() {
156  _flags &= ~F_has_tangent;
157 }
158 
159 ////////////////////////////////////////////////////////////////////
160 // Function: EggVertexUV::has_binormal
161 // Access: Published
162 // Description:
163 ////////////////////////////////////////////////////////////////////
164 INLINE bool EggVertexUV::
165 has_binormal() const {
166  return (_flags & F_has_binormal) != 0;
167 }
168 
169 ////////////////////////////////////////////////////////////////////
170 // Function: EggVertexUV::get_binormal
171 // Access: Published
172 // Description:
173 ////////////////////////////////////////////////////////////////////
174 INLINE const LNormald &EggVertexUV::
175 get_binormal() const {
176  nassertr(has_binormal(), _binormal);
177  return _binormal;
178 }
179 
180 ////////////////////////////////////////////////////////////////////
181 // Function: EggVertexUV::set_binormal
182 // Access: Published
183 // Description:
184 ////////////////////////////////////////////////////////////////////
185 INLINE void EggVertexUV::
186 set_binormal(const LNormald &binormal) {
187  _binormal = binormal;
188  _flags |= F_has_binormal;
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: EggVertexUV::clear_binormal
193 // Access: Published
194 // Description:
195 ////////////////////////////////////////////////////////////////////
196 INLINE void EggVertexUV::
197 clear_binormal() {
198  _flags &= ~F_has_binormal;
199 }
static const LPoint2d & zero()
Returns a zero-length point.
Definition: lpoint2.h:543
int get_num_dimensions() const
Returns the number of components of the texture coordinate set.
Definition: eggVertexUV.I:51
static string filter_name(const string &name)
Returns the actual name that should be set for a given name string.
Definition: eggVertexUV.I:26
This is a two-component point in space.
Definition: lpoint2.h:411
LTexCoordd get_uv() const
Returns the texture coordinate pair, if get_num_dimensions() is 2.
Definition: eggVertexUV.I:74
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:63
const LTexCoord3d & get_uvw() const
Returns the texture coordinate triple, if get_num_dimensions() is 3.
Definition: eggVertexUV.I:88
void set_uv(const LTexCoordd &texCoord)
Sets the texture coordinate pair.
Definition: eggVertexUV.I:100
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:746
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:531
void set_uvw(const LTexCoord3d &texCoord)
Sets the texture coordinate triple.
Definition: eggVertexUV.I:112