Panda3D
 All Classes Functions Variables Enumerations
geomVertexAnimationSpec.I
1 // Filename: geomVertexAnimationSpec.I
2 // Created by: drose (29Mar05)
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: GeomVertexAnimationSpec::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE GeomVertexAnimationSpec::
22 GeomVertexAnimationSpec() :
23  _animation_type(AT_none),
24  _num_transforms(0),
25  _indexed_transforms(0)
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: GeomVertexAnimationSpec::Copy Constructor
31 // Access: Published
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE GeomVertexAnimationSpec::
35 GeomVertexAnimationSpec(const GeomVertexAnimationSpec &other) :
36  _animation_type(other._animation_type),
37  _num_transforms(other._num_transforms),
38  _indexed_transforms(other._indexed_transforms)
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: GeomVertexAnimationSpec::Copy Assignment Operator
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 INLINE void GeomVertexAnimationSpec::
48 operator = (const GeomVertexAnimationSpec &other) {
49  _animation_type = other._animation_type;
50  _num_transforms = other._num_transforms;
51  _indexed_transforms = other._indexed_transforms;
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: GeomVertexAnimationSpec::get_animation_type
56 // Access: Published
57 // Description: Returns the type of animation represented by this
58 // spec.
59 ////////////////////////////////////////////////////////////////////
60 INLINE GeomVertexAnimationSpec::AnimationType GeomVertexAnimationSpec::
62  return _animation_type;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: GeomVertexAnimationSpec::get_num_transforms
67 // Access: Published
68 // Description: This is only meaningful for animation_type
69 // AT_hardware. It specifies the maximum number of
70 // transforms that might be simultaneously applied to
71 // any one vertex by the data in this format.
72 ////////////////////////////////////////////////////////////////////
75  return _num_transforms;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: GeomVertexAnimationSpec::get_indexed_transforms
80 // Access: Published
81 // Description: This is only meaningful for animation_type
82 // AT_hardware. If true, it indicates that the format
83 // uses indexed animation tables. It is false if each
84 // vertex will reference the first _num_transforms
85 // table entries only.
86 ////////////////////////////////////////////////////////////////////
87 INLINE bool GeomVertexAnimationSpec::
89  return _indexed_transforms;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: GeomVertexAnimationSpec::set_none
94 // Access: Published
95 // Description: Specifies that no vertex animation is represented by
96 // this spec.
97 ////////////////////////////////////////////////////////////////////
98 INLINE void GeomVertexAnimationSpec::
100  _animation_type = AT_none;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: GeomVertexAnimationSpec::set_panda
105 // Access: Published
106 // Description: Specifies that vertex animation is to be performed by
107 // Panda. This is the most general setting and can
108 // handle any kind of vertex animation represented.
109 ////////////////////////////////////////////////////////////////////
110 INLINE void GeomVertexAnimationSpec::
112  _animation_type = AT_panda;
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: GeomVertexAnimationSpec::set_hardware
117 // Access: Published
118 // Description: Specifies that vertex animation is to be performed by
119 // the graphics hardware (or at least by the graphics
120 // backend API, which is actually still free to animate
121 // the vertices on the CPU).
122 //
123 // This is only legal if the graphics hardware can
124 // support the specified limits on number of transforms
125 // and/or indexed transforms. Also, no current graphics
126 // API's support morphing.
127 ////////////////////////////////////////////////////////////////////
128 INLINE void GeomVertexAnimationSpec::
129 set_hardware(int num_transforms, bool indexed_transforms) {
130  _animation_type = AT_hardware;
131  _num_transforms = num_transforms;
132  _indexed_transforms = indexed_transforms;
133 }
134 
135 ////////////////////////////////////////////////////////////////////
136 // Function: GeomVertexAnimationSpec::operator <
137 // Access: Public
138 // Description: Provides an arbitrary ordering between different
139 // animation specs.
140 ////////////////////////////////////////////////////////////////////
141 INLINE bool GeomVertexAnimationSpec::
143  return (compare_to(other) < 0);
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: GeomVertexAnimationSpec::operator ==
148 // Access: Public
149 // Description:
150 ////////////////////////////////////////////////////////////////////
151 INLINE bool GeomVertexAnimationSpec::
152 operator == (const GeomVertexAnimationSpec &other) const {
153  return (compare_to(other) == 0);
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: GeomVertexAnimationSpec::operator !=
158 // Access: Public
159 // Description:
160 ////////////////////////////////////////////////////////////////////
161 INLINE bool GeomVertexAnimationSpec::
162 operator != (const GeomVertexAnimationSpec &other) const {
163  return (compare_to(other) != 0);
164 }
165 
166 ////////////////////////////////////////////////////////////////////
167 // Function: GeomVertexAnimationSpec::compare_to
168 // Access: Public
169 // Description: Provides an arbitrary ordering between different
170 // animation specs.
171 ////////////////////////////////////////////////////////////////////
172 INLINE int GeomVertexAnimationSpec::
173 compare_to(const GeomVertexAnimationSpec &other) const {
174  if (_animation_type != other._animation_type) {
175  return (int)_animation_type - (int)other._animation_type;
176  }
177 
178  if (_animation_type == AT_hardware) {
179  if (_num_transforms != other._num_transforms) {
180  return _num_transforms - other._num_transforms;
181  }
182  if (_indexed_transforms != other._indexed_transforms) {
183  return (int)_indexed_transforms - (int)other._indexed_transforms;
184  }
185  }
186 
187  return 0;
188 }
189 
190 INLINE ostream &
191 operator << (ostream &out, const GeomVertexAnimationSpec &animation) {
192  animation.output(out);
193  return out;
194 }
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded...
void set_hardware(int num_transforms, bool indexed_transforms)
Specifies that vertex animation is to be performed by the graphics hardware (or at least by the graph...
void set_none()
Specifies that no vertex animation is represented by this spec.
AnimationType get_animation_type() const
Returns the type of animation represented by this spec.
void set_panda()
Specifies that vertex animation is to be performed by Panda.
bool operator<(const GeomVertexAnimationSpec &other) const
Provides an arbitrary ordering between different animation specs.
bool get_indexed_transforms() const
This is only meaningful for animation_type AT_hardware.
int compare_to(const GeomVertexAnimationSpec &other) const
Provides an arbitrary ordering between different animation specs.
int get_num_transforms() const
This is only meaningful for animation_type AT_hardware.