Panda3D
geomVertexAnimationSpec.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 geomVertexAnimationSpec.I
10  * @author drose
11  * @date 2005-03-29
12  */
13 
14 /**
15  *
16  */
17 INLINE GeomVertexAnimationSpec::
18 GeomVertexAnimationSpec() :
19  _animation_type(AT_none),
20  _num_transforms(0),
21  _indexed_transforms(0)
22 {
23 }
24 
25 /**
26  *
27  */
28 INLINE GeomVertexAnimationSpec::
29 GeomVertexAnimationSpec(const GeomVertexAnimationSpec &other) :
30  _animation_type(other._animation_type),
31  _num_transforms(other._num_transforms),
32  _indexed_transforms(other._indexed_transforms)
33 {
34 }
35 
36 /**
37  *
38  */
39 INLINE void GeomVertexAnimationSpec::
40 operator = (const GeomVertexAnimationSpec &other) {
41  _animation_type = other._animation_type;
42  _num_transforms = other._num_transforms;
43  _indexed_transforms = other._indexed_transforms;
44 }
45 
46 /**
47  * Returns the type of animation represented by this spec.
48  */
49 INLINE GeomVertexAnimationSpec::AnimationType GeomVertexAnimationSpec::
50 get_animation_type() const {
51  return _animation_type;
52 }
53 
54 /**
55  * This is only meaningful for animation_type AT_hardware. It specifies the
56  * maximum number of transforms that might be simultaneously applied to any
57  * one vertex by the data in this format.
58  */
59 INLINE int GeomVertexAnimationSpec::
60 get_num_transforms() const {
61  return _num_transforms;
62 }
63 
64 /**
65  * This is only meaningful for animation_type AT_hardware. If true, it
66  * indicates that the format uses indexed animation tables. It is false if
67  * each vertex will reference the first _num_transforms table entries only.
68  */
69 INLINE bool GeomVertexAnimationSpec::
70 get_indexed_transforms() const {
71  return _indexed_transforms;
72 }
73 
74 /**
75  * Specifies that no vertex animation is represented by this spec.
76  */
77 INLINE void GeomVertexAnimationSpec::
79  _animation_type = AT_none;
80 }
81 
82 /**
83  * Specifies that vertex animation is to be performed by Panda. This is the
84  * most general setting and can handle any kind of vertex animation
85  * represented.
86  */
87 INLINE void GeomVertexAnimationSpec::
89  _animation_type = AT_panda;
90 }
91 
92 /**
93  * Specifies that vertex animation is to be performed by the graphics hardware
94  * (or at least by the graphics backend API, which is actually still free to
95  * animate the vertices on the CPU).
96  *
97  * This is only legal if the graphics hardware can support the specified
98  * limits on number of transforms and/or indexed transforms. Also, no current
99  * graphics API's support morphing.
100  */
101 INLINE void GeomVertexAnimationSpec::
102 set_hardware(int num_transforms, bool indexed_transforms) {
103  _animation_type = AT_hardware;
104  _num_transforms = num_transforms;
105  _indexed_transforms = indexed_transforms;
106 }
107 
108 /**
109  * Provides an arbitrary ordering between different animation specs.
110  */
111 INLINE bool GeomVertexAnimationSpec::
113  return (compare_to(other) < 0);
114 }
115 
116 /**
117  *
118  */
119 INLINE bool GeomVertexAnimationSpec::
120 operator == (const GeomVertexAnimationSpec &other) const {
121  return (compare_to(other) == 0);
122 }
123 
124 /**
125  *
126  */
127 INLINE bool GeomVertexAnimationSpec::
128 operator != (const GeomVertexAnimationSpec &other) const {
129  return (compare_to(other) != 0);
130 }
131 
132 /**
133  * Provides an arbitrary ordering between different animation specs.
134  */
135 INLINE int GeomVertexAnimationSpec::
136 compare_to(const GeomVertexAnimationSpec &other) const {
137  if (_animation_type != other._animation_type) {
138  return (int)_animation_type - (int)other._animation_type;
139  }
140 
141  if (_animation_type == AT_hardware) {
142  if (_num_transforms != other._num_transforms) {
143  return _num_transforms - other._num_transforms;
144  }
145  if (_indexed_transforms != other._indexed_transforms) {
146  return (int)_indexed_transforms - (int)other._indexed_transforms;
147  }
148  }
149 
150  return 0;
151 }
152 
153 INLINE std::ostream &
154 operator << (std::ostream &out, const GeomVertexAnimationSpec &animation) {
155  animation.output(out);
156  return out;
157 }
int compare_to(const GeomVertexAnimationSpec &other) const
Provides an arbitrary ordering between different animation specs.
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.
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.