36 if (convert_from.has_order()) {
37 set_order(convert_from.get_order());
39 if (convert_from.has_fps()) {
40 set_fps(convert_from.
get_fps());
50 EggXfmSAnim::const_iterator ci;
51 for (ci = convert_from.begin(); ci != convert_from.end(); ++ci) {
52 if ((*ci)->is_of_type(EggSAnimData::get_class_type())) {
54 nassertv(sanim->get_name().length() == 1);
57 subtables.push_back(sanim);
58 _contents += sanim->get_name()[0];
65 for (
int row = 0; row < num_rows; row++) {
66 for (
int col = 0; col < (int)subtables.size(); col++) {
86 LVector3d scale(1.0, 1.0, 1.0);
87 LVector3d shear(0.0, 0.0, 0.0);
88 LVector3d hpr(0.0, 0.0, 0.0);
89 LVector3d translate(0.0, 0.0, 0.0);
94 switch (_contents[col]) {
132 translate[0] = value;
136 translate[1] = value;
140 translate[2] = value;
145 nassert_raise(
"invalid letter in contents string");
168 write(std::ostream &out,
int indent_level)
const {
172 indent(out, indent_level + 2)
173 <<
"<Scalar> fps { " <<
get_fps() <<
" }\n";
177 indent(out, indent_level + 2)
178 <<
"<Char*> order { " << get_order() <<
" }\n";
181 if (has_contents()) {
182 indent(out, indent_level + 2)
183 <<
"<Char*> contents { " << get_contents() <<
" }\n";
186 indent(out, indent_level + 2) <<
"<V> {\n";
189 indent(out, indent_level + 2) <<
"}\n";
190 indent(out, indent_level) <<
"}\n";
197 void EggXfmAnimData::
198 r_transform(
const LMatrix4d &mat,
const LMatrix4d &inv,
199 CoordinateSystem to_cs) {
202 LMatrix4d inv1 = inv;
203 inv1.set_row(3, LVector3d(0.0, 0.0, 0.0));
208 if (to_cs == CS_default) {
224 bool result = new_table.add_data(inv1 * orig_mat * mat);
228 <<
"Transform from " << _coordsys <<
" to " << to_cs
230 LVector3d scale, shear, hpr, trans;
231 bool d = decompose_matrix(orig_mat, scale, shear, hpr, trans, _coordsys);
233 <<
"orig:\n" << orig_mat
235 <<
"\n scale: " << scale
236 <<
"\n shear: " << shear
238 <<
"\n trans: " << trans <<
"\n";
240 LMatrix4d new_mat = inv1 * orig_mat * mat;
241 d = decompose_matrix(new_mat, scale, shear, hpr, trans, to_cs);
243 <<
"new:\n" << new_mat
245 <<
"\n scale: " << scale
246 <<
"\n shear: " << shear
248 <<
"\n trans: " << trans <<
"\n";
257 new_table.optimize();
261 (*this) = copy_table;
270 void EggXfmAnimData::
271 r_mark_coordsys(CoordinateSystem cs) {
static void compose_with_order(LMatrix4d &mat, const LVecBase3d &scale, const LVecBase3d &shear, const LVecBase3d &hpr, const LVecBase3d &trans, const std::string &order, CoordinateSystem cs)
Composes a matrix out of the nine individual components, respecting the order string.
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.
void write_header(std::ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
void add_data(double value)
Adds a single element to the table.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
double get_value(int row) const
Returns the value at the indicated row.
virtual void write(std::ostream &out, int indent_level) const
Writes the data to the indicated output stream in Egg format.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static const std::string & get_standard_order()
Returns the standard order of matrix component composition.
This is our own Panda specialization on the default STL vector.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
double get_value(int row, int col) const
Returns the value at the indicated row.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
double get_fps() const
This is only valid if has_fps() returns true.
A base class for EggSAnimData and EggXfmAnimData, which contain rows and columns of numbers.
void write_long_list(std::ostream &out, int indent_level, InputIterator ifirst, InputIterator ilast, std::string first_prefix="", std::string later_prefix="", int max_col=72)
Writes a list of things to the indicated output stream, with a space separating each item.
Corresponding to an <Xfm$Anim> entry, this stores a two-dimensional table with up to nine columns,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CoordinateSystem get_coordinate_system() const
Returns the coordinate system this table believes it is defined within.
int get_num_rows() const
Returns the effective number of rows in the table.
double get_fps() const
This is only valid if has_fps() returns true.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_anim_matrix() const
Returns true if this node represents a table of animation transformation data, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_rows() const
Returns the number of rows in the table.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.