Panda3D
eggXfmAnimData.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 eggXfmAnimData.I
10  * @author drose
11  * @date 1999-02-19
12  */
13 
14 /**
15  *
16  */
17 INLINE EggXfmAnimData::
18 EggXfmAnimData(const std::string &name, CoordinateSystem cs) : EggAnimData(name) {
19  _coordsys = cs;
20 }
21 
22 
23 /**
24  *
25  */
26 INLINE EggXfmAnimData::
27 EggXfmAnimData(const EggXfmAnimData &copy)
28  : EggAnimData(copy),
29  _order(copy._order),
30  _contents(copy._contents),
31  _coordsys(copy._coordsys) {
32 }
33 
34 
35 /**
36  *
37  */
38 INLINE EggXfmAnimData &EggXfmAnimData::
39 operator = (const EggXfmAnimData &copy) {
40  EggAnimData::operator = (copy);
41  _order = copy._order;
42  _contents = copy._contents;
43  _coordsys = copy._coordsys;
44 
45  return *this;
46 }
47 
48 
49 /**
50  *
51  */
52 INLINE void EggXfmAnimData::
53 set_order(const std::string &order) {
54  _order = order;
55 }
56 
57 /**
58  *
59  */
60 INLINE void EggXfmAnimData::
61 clear_order() {
62  _order = "";
63 }
64 
65 /**
66  *
67  */
68 INLINE bool EggXfmAnimData::
69 has_order() const {
70  return !_order.empty();
71 }
72 
73 /**
74  *
75  */
76 INLINE const std::string &EggXfmAnimData::
77 get_order() const {
78  if (has_order()) {
79  return _order;
80  } else {
81  return get_standard_order();
82  }
83 }
84 
85 /**
86  * Returns the standard order of matrix component composition. This is what
87  * the order string must be set to in order to use set_value() or add_data()
88  * successfully.
89  */
90 INLINE const std::string &EggXfmAnimData::
93 }
94 
95 
96 /**
97  *
98  */
99 INLINE void EggXfmAnimData::
100 set_contents(const std::string &contents) {
101  _contents = contents;
102 }
103 
104 /**
105  *
106  */
107 INLINE void EggXfmAnimData::
108 clear_contents() {
109  _contents = "";
110 }
111 
112 /**
113  *
114  */
115 INLINE bool EggXfmAnimData::
116 has_contents() const {
117  return !_contents.empty();
118 }
119 
120 /**
121  *
122  */
123 INLINE const std::string &EggXfmAnimData::
124 get_contents() const {
125  return _contents;
126 }
127 
128 /**
129  * Returns the coordinate system this table believes it is defined within.
130  * This should always match the coordinate system of the EggData structure
131  * that owns it. It is necessary to store it here because the meaning of the
132  * h, p, and r columns depends on the coordinate system.
133  */
134 INLINE CoordinateSystem EggXfmAnimData::
136  return _coordsys;
137 }
138 
139 
140 /**
141  * Returns the number of rows in the table.
142  */
143 INLINE int EggXfmAnimData::
144 get_num_rows() const {
145  if (get_num_cols() == 0) {
146  return 0;
147  }
148  return get_size() / get_num_cols();
149 }
150 
151 /**
152  * Returns the number of columns in the table. This is set according to the
153  * "contents" string, which defines the meaning of each column.
154  */
155 INLINE int EggXfmAnimData::
156 get_num_cols() const {
157  return _contents.length();
158 }
159 
160 
161 /**
162  * Returns the value at the indicated row. Row must be in the range 0 <= row
163  * < get_num_rows(); col must be in the range 0 <= col < get_num_cols().
164  */
165 INLINE double EggXfmAnimData::
166 get_value(int row, int col) const {
167  nassertr(get_num_cols() != 0, 0.0);
168  nassertr(row >= 0 && row < get_num_rows(), 0.0);
169  nassertr(col >= 0 && col < get_num_cols(), 0.0);
170  return _data[row * get_num_cols() + col];
171 }
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:107
static const std::string & get_standard_order()
Returns the standard order of matrix component composition.
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:30
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns,...
static const std::string & get_standard_order()
Returns the standard order of matrix component composition.
Definition: eggXfmSAnim.I:129