15 #include "eggXfmAnimData.h"
16 #include "eggXfmSAnim.h"
17 #include "eggSAnimData.h"
18 #include "eggMiscFuncs.h"
19 #include "config_egg.h"
24 #include "compose_matrix.h"
40 if (convert_from.has_order()) {
41 set_order(convert_from.get_order());
43 if (convert_from.has_fps()) {
44 set_fps(convert_from.
get_fps());
54 EggXfmSAnim::const_iterator ci;
55 for (ci = convert_from.begin(); ci != convert_from.end(); ++ci) {
56 if ((*ci)->is_of_type(EggSAnimData::get_class_type())) {
58 nassertv(sanim->get_name().length() == 1);
61 subtables.push_back(sanim);
62 _contents += sanim->get_name()[0];
69 for (
int row = 0; row < num_rows; row++) {
70 for (
int col = 0; col < (int)subtables.size(); col++) {
101 switch (_contents[col]) {
139 translate[0] = value;
143 translate[1] = value;
147 translate[2] = value;
179 write(ostream &out,
int indent_level)
const {
183 indent(out, indent_level + 2)
184 <<
"<Scalar> fps { " <<
get_fps() <<
" }\n";
188 indent(out, indent_level + 2)
189 <<
"<Char*> order { " << get_order() <<
" }\n";
192 if (has_contents()) {
193 indent(out, indent_level + 2)
194 <<
"<Char*> contents { " << get_contents() <<
" }\n";
197 indent(out, indent_level + 2) <<
"<V> {\n";
198 write_long_list(out, indent_level + 4, _data.begin(), _data.end(),
200 indent(out, indent_level + 2) <<
"}\n";
201 indent(out, indent_level) <<
"}\n";
211 void EggXfmAnimData::
213 CoordinateSystem to_cs) {
223 if (to_cs == CS_default) {
239 bool result = new_table.add_data(inv1 * orig_mat * mat);
243 <<
"Transform from " << _coordsys <<
" to " << to_cs
246 bool d = decompose_matrix(orig_mat, scale, shear, hpr, trans, _coordsys);
248 <<
"orig:\n" << orig_mat
250 <<
"\n scale: " << scale
251 <<
"\n shear: " << shear
253 <<
"\n trans: " << trans <<
"\n";
255 LMatrix4d new_mat = inv1 * orig_mat * mat;
256 d = decompose_matrix(new_mat, scale, shear, hpr, trans, to_cs);
258 <<
"new:\n" << new_mat
260 <<
"\n scale: " << scale
261 <<
"\n shear: " << shear
263 <<
"\n trans: " << trans <<
"\n";
273 new_table.optimize();
277 (*this) = copy_table;
289 void EggXfmAnimData::
290 r_mark_coordsys(CoordinateSystem cs) {
This is a 4-by-4 transform matrix.
void add_data(double value)
Adds a single element to the table.
void write_header(ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
int get_num_cols() const
Returns the number of columns in the table.
double get_value(int row, int col) const
Returns the value at the indicated row.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
double get_fps() const
This is only valid if has_fps() returns true.
void set_row(int row, const LVecBase4d &v)
Replaces the indicated row of the matrix.
int get_num_rows() const
Returns the effective number of rows in the table.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system this table believes it is defined within.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
A base class for EggSAnimData and EggXfmAnimData, which contain rows and columns of numbers...
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns...
int get_num_rows() const
Returns the number of rows in the table.
static void compose_with_order(LMatrix4d &mat, const LVecBase3d &scale, const LVecBase3d &shear, const LVecBase3d &hpr, const LVecBase3d &trans, const string &order, CoordinateSystem cs)
Composes a matrix out of the nine individual components, respecting the order string.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
static const string & get_standard_order()
Returns the standard order of matrix component composition.
virtual bool is_anim_matrix() const
Returns true if this node represents a table of animation transformation data, false otherwise...
double get_fps() const
This is only valid if has_fps() returns true.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void write(ostream &out, int indent_level) const
Writes the data to the indicated output stream in Egg format.
int get_num_rows() const
Returns the number of rows in the table.
double get_value(int row) const
Returns the value at the indicated row.