Panda3D
eggXfmAnimData.I
1 // Filename: eggXfmAnimData.I
2 // Created by: drose (19Feb99)
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: EggXfmAnimData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE EggXfmAnimData::
22 EggXfmAnimData(const string &name, CoordinateSystem cs) : EggAnimData(name) {
23  _coordsys = cs;
24 }
25 
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: EggXfmAnimData::Copy constructor
29 // Access: Public
30 // Description:
31 ////////////////////////////////////////////////////////////////////
32 INLINE EggXfmAnimData::
33 EggXfmAnimData(const EggXfmAnimData &copy)
34  : EggAnimData(copy),
35  _order(copy._order),
36  _contents(copy._contents),
37  _coordsys(copy._coordsys) {
38 }
39 
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: EggXfmAnimData::Copy assignment operator
43 // Access: Public
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE EggXfmAnimData &EggXfmAnimData::
47 operator = (const EggXfmAnimData &copy) {
48  EggAnimData::operator = (copy);
49  _order = copy._order;
50  _contents = copy._contents;
51  _coordsys = copy._coordsys;
52 
53  return *this;
54 }
55 
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: EggXfmAnimData::set_order
59 // Access: Public
60 // Description:
61 ////////////////////////////////////////////////////////////////////
62 INLINE void EggXfmAnimData::
63 set_order(const string &order) {
64  _order = order;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: EggXfmAnimData::clear_order
69 // Access: Public
70 // Description:
71 ////////////////////////////////////////////////////////////////////
72 INLINE void EggXfmAnimData::
73 clear_order() {
74  _order = "";
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: EggXfmAnimData::has_order
79 // Access: Public
80 // Description:
81 ////////////////////////////////////////////////////////////////////
82 INLINE bool EggXfmAnimData::
83 has_order() const {
84  return !_order.empty();
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: EggXfmAnimData::get_order
89 // Access: Public
90 // Description:
91 ////////////////////////////////////////////////////////////////////
92 INLINE const string &EggXfmAnimData::
93 get_order() const {
94  if (has_order()) {
95  return _order;
96  } else {
97  return get_standard_order();
98  }
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: EggXfmAnimData::get_standard_order
103 // Access: Public, Static
104 // Description: Returns the standard order of matrix component
105 // composition. This is what the order string must be
106 // set to in order to use set_value() or add_data()
107 // successfully.
108 ////////////////////////////////////////////////////////////////////
109 INLINE const string &EggXfmAnimData::
112 }
113 
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: EggXfmAnimData::set_contents
117 // Access: Public
118 // Description:
119 ////////////////////////////////////////////////////////////////////
120 INLINE void EggXfmAnimData::
121 set_contents(const string &contents) {
122  _contents = contents;
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: EggXfmAnimData::clear_contents
127 // Access: Public
128 // Description:
129 ////////////////////////////////////////////////////////////////////
130 INLINE void EggXfmAnimData::
131 clear_contents() {
132  _contents = "";
133 }
134 
135 ////////////////////////////////////////////////////////////////////
136 // Function: EggXfmAnimData::has_contents
137 // Access: Public
138 // Description:
139 ////////////////////////////////////////////////////////////////////
140 INLINE bool EggXfmAnimData::
141 has_contents() const {
142  return !_contents.empty();
143 }
144 
145 ////////////////////////////////////////////////////////////////////
146 // Function: EggXfmAnimData::get_contents
147 // Access: Public
148 // Description:
149 ////////////////////////////////////////////////////////////////////
150 INLINE const string &EggXfmAnimData::
151 get_contents() const {
152  return _contents;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: EggXfmAnimData::get_coordinate_system
157 // Access: Public
158 // Description: Returns the coordinate system this table believes it
159 // is defined within. This should always match the
160 // coordinate system of the EggData structure that owns
161 // it. It is necessary to store it here because the
162 // meaning of the h, p, and r columns depends on the
163 // coordinate system.
164 ////////////////////////////////////////////////////////////////////
165 INLINE CoordinateSystem EggXfmAnimData::
167  return _coordsys;
168 }
169 
170 
171 ////////////////////////////////////////////////////////////////////
172 // Function: EggXfmAnimData::get_num_rows
173 // Access: Public
174 // Description: Returns the number of rows in the table.
175 ////////////////////////////////////////////////////////////////////
176 INLINE int EggXfmAnimData::
177 get_num_rows() const {
178  if (get_num_cols() == 0) {
179  return 0;
180  }
181  return get_size() / get_num_cols();
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: EggXfmAnimData::get_num_cols
186 // Access: Public
187 // Description: Returns the number of columns in the table. This is
188 // set according to the "contents" string, which defines
189 // the meaning of each column.
190 ////////////////////////////////////////////////////////////////////
191 INLINE int EggXfmAnimData::
192 get_num_cols() const {
193  return _contents.length();
194 }
195 
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: EggXfmAnimData::get_value
199 // Access: Public
200 // Description: Returns the value at the indicated row. Row must be
201 // in the range 0 <= row < get_num_rows(); col must be
202 // in the range 0 <= col < get_num_cols().
203 ////////////////////////////////////////////////////////////////////
204 INLINE double EggXfmAnimData::
205 get_value(int row, int col) const {
206  nassertr(get_num_cols() != 0, 0.0);
207  nassertr(row >= 0 && row < get_num_rows(), 0.0);
208  nassertr(col >= 0 && col < get_num_cols(), 0.0);
209  return _data[row * get_num_cols() + col];
210 }
211 
212 
int get_num_cols() const
Returns the number of columns in the table.
int get_num_rows() const
Returns the number of rows in the table.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system this table believes it is defined within.
int get_size() const
Returns the number of elements in the table.
Definition: eggAnimData.I:128
static const string & get_standard_order()
Returns the standard order of matrix component composition.
Definition: eggXfmSAnim.I:156
double get_value(int row, int col) const
Returns the value at the indicated row.
A base class for EggSAnimData and EggXfmAnimData, which contain rows and columns of numbers...
Definition: eggAnimData.h:32
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns...
static const string & get_standard_order()
Returns the standard order of matrix component composition.