straighten out -TT on animation tables
This commit is contained in:
parent
e702ea203d
commit
6526538d65
|
|
@ -971,7 +971,7 @@ adjust_under() {
|
|||
void EggGroup::
|
||||
r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
||||
CoordinateSystem to_cs) {
|
||||
if (has_transform()) {
|
||||
if (has_transform() || get_group_type() == GT_joint) {
|
||||
// Since we want to apply this transform to all matrices,
|
||||
// including nested matrices, we can't simply premult it in and
|
||||
// leave it, because that would leave the rotational component in
|
||||
|
|
|
|||
|
|
@ -778,6 +778,31 @@ has_primitives() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::joint_has_primitives
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns true if there are any primitives
|
||||
// (e.g. polygons) defined within this group or below,
|
||||
// but the search does not include nested joints.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggGroupNode::
|
||||
joint_has_primitives() const {
|
||||
Children::const_iterator ci;
|
||||
for (ci = _children.begin();
|
||||
ci != _children.end();
|
||||
++ci) {
|
||||
EggNode *child = (*ci);
|
||||
|
||||
if (!child->is_joint()) {
|
||||
if (child->joint_has_primitives()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::update_under
|
||||
// Access: Protected, Virtual
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ PUBLISHED:
|
|||
int remove_unused_vertices();
|
||||
int remove_invalid_primitives();
|
||||
virtual bool has_primitives() const;
|
||||
virtual bool joint_has_primitives() const;
|
||||
|
||||
protected:
|
||||
virtual void update_under(int depth_offset);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,17 @@ is_joint() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggNode::is_anim_matrix
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this node represents a table of
|
||||
// animation transformation data, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggNode::
|
||||
is_anim_matrix() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggNode::determine_alpha_mode
|
||||
// Access: Public, Virtual
|
||||
|
|
@ -323,6 +334,18 @@ has_primitives() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggNode::joint_has_primitives
|
||||
// Access: Protected, Virtual
|
||||
// Description: Returns true if there are any primitives
|
||||
// (e.g. polygons) defined within this group or below,
|
||||
// but the search does not include nested joints.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggNode::
|
||||
joint_has_primitives() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggNode::r_transform
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ PUBLISHED:
|
|||
void apply_texmats();
|
||||
|
||||
virtual bool is_joint() const;
|
||||
virtual bool is_anim_matrix() const;
|
||||
|
||||
virtual EggRenderMode *determine_alpha_mode();
|
||||
virtual EggRenderMode *determine_depth_write_mode();
|
||||
|
|
@ -101,6 +102,7 @@ protected:
|
|||
virtual void update_under(int depth_offset);
|
||||
virtual void adjust_under();
|
||||
virtual bool has_primitives() const;
|
||||
virtual bool joint_has_primitives() const;
|
||||
|
||||
virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
||||
CoordinateSystem to_cs);
|
||||
|
|
@ -145,7 +147,8 @@ public:
|
|||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
friend class EggGroupNode;
|
||||
friend class EggGroupNode;
|
||||
friend class EggTable;
|
||||
};
|
||||
|
||||
#include "eggNode.I"
|
||||
|
|
|
|||
|
|
@ -344,6 +344,18 @@ has_primitives() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggPrimitive::joint_has_primitives
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns true if there are any primitives
|
||||
// (e.g. polygons) defined within this group or below,
|
||||
// but the search does not include nested joints.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggPrimitive::
|
||||
joint_has_primitives() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggPrimitive::erase
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ PUBLISHED:
|
|||
void remove_doubled_verts(bool closed);
|
||||
void remove_nonunique_verts();
|
||||
virtual bool has_primitives() const;
|
||||
virtual bool joint_has_primitives() const;
|
||||
|
||||
|
||||
// The EggPrimitive itself appears to be an STL container of
|
||||
|
|
|
|||
|
|
@ -18,11 +18,31 @@
|
|||
|
||||
#include "eggTable.h"
|
||||
|
||||
#include <string_utils.h>
|
||||
#include <indent.h>
|
||||
#include "string_utils.h"
|
||||
#include "indent.h"
|
||||
|
||||
TypeHandle EggTable::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTable::has_transform
|
||||
// Access: Public
|
||||
// Description: Returns true if the table contains a transform
|
||||
// description, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggTable::
|
||||
has_transform() const {
|
||||
const_iterator ci;
|
||||
|
||||
for (ci = begin(); ci != end(); ++ci) {
|
||||
EggNode *child = (*ci);
|
||||
if (child->is_anim_matrix()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTable::write
|
||||
// Access: Public, Virtual
|
||||
|
|
@ -70,6 +90,66 @@ string_table_type(const string &string) {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTable::r_transform
|
||||
// Access: Protected, Virtual
|
||||
// Description: This is called from within the egg code by
|
||||
// transform(). It applies a transformation matrix
|
||||
// to the current node in some sensible way, then
|
||||
// continues down the tree.
|
||||
//
|
||||
// The first matrix is the transformation to apply; the
|
||||
// second is its inverse. The third parameter is the
|
||||
// coordinate system we are changing to, or CS_default
|
||||
// if we are not changing coordinate systems.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void EggTable::
|
||||
r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
||||
CoordinateSystem to_cs) {
|
||||
// We need to duplicate the logic in EggGroup: if we have a matrix
|
||||
// transform witin this table, apply the transformation to it, but
|
||||
// then apply only the scale/rotational part of the transformation
|
||||
// to any children.
|
||||
|
||||
// On the other hand, if we have no matrix transform within this
|
||||
// table, pass the transformation through.
|
||||
|
||||
// This logic is complicated by the fact that matrix transforms with
|
||||
// a <Table> group are not stored within the table itself, but
|
||||
// rather within a child named "xform". Fortunately,
|
||||
// has_transform() abstracts out this detail for us.
|
||||
|
||||
if (has_transform()) {
|
||||
// At least one child of this table represents an animation matrix
|
||||
// transform: that child gets the real matrix, while all other
|
||||
// children get the truncated matrix.
|
||||
|
||||
LMatrix4d mat1 = mat;
|
||||
LMatrix4d inv1 = inv;
|
||||
|
||||
// If we have a translation component, we should only apply
|
||||
// it to the top matrix. All subsequent matrices get just the
|
||||
// rotational component.
|
||||
mat1.set_row(3, LVector3d(0.0, 0.0, 0.0));
|
||||
inv1.set_row(3, LVector3d(0.0, 0.0, 0.0));
|
||||
|
||||
iterator ci;
|
||||
for (ci = begin(); ci != end(); ++ci) {
|
||||
EggNode *child = (*ci);
|
||||
if (child->is_anim_matrix()) {
|
||||
child->r_transform(mat, inv, to_cs);
|
||||
} else {
|
||||
child->r_transform(mat1, inv1, to_cs);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// No children of this table represent an animation matrix
|
||||
// transform: all children get the real matrix.
|
||||
EggGroupNode::r_transform(mat, inv, to_cs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TableType output operator
|
||||
|
|
|
|||
|
|
@ -47,10 +47,15 @@ PUBLISHED:
|
|||
INLINE void set_table_type(TableType type);
|
||||
INLINE TableType get_table_type() const;
|
||||
|
||||
bool has_transform() const;
|
||||
virtual void write(ostream &out, int indent_level) const;
|
||||
|
||||
static TableType string_table_type(const string &string);
|
||||
|
||||
protected:
|
||||
virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
||||
CoordinateSystem to_cs);
|
||||
|
||||
private:
|
||||
TableType _type;
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,17 @@ get_value(int row, LMatrix4d &mat) const {
|
|||
_coordsys);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggXfmAnimData::is_anim_matrix
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this node represents a table of
|
||||
// animation transformation data, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggXfmAnimData::
|
||||
is_anim_matrix() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggXfmAnimData::write
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ PUBLISHED:
|
|||
|
||||
void get_value(int row, LMatrix4d &mat) const;
|
||||
|
||||
virtual bool is_anim_matrix() const;
|
||||
virtual void write(ostream &out, int indent_level) const;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -150,6 +150,17 @@ normalize() {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggXfmSAnim::is_anim_matrix
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns true if this node represents a table of
|
||||
// animation transformation data, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool EggXfmSAnim::
|
||||
is_anim_matrix() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggXfmSAnim::write
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ PUBLISHED:
|
|||
void add_component_data(const string &component_name, double value);
|
||||
void add_component_data(int component, double value);
|
||||
|
||||
virtual bool is_anim_matrix() const;
|
||||
virtual void write(ostream &out, int indent_level) const;
|
||||
|
||||
static void compose_with_order(LMatrix4d &mat,
|
||||
|
|
|
|||
Loading…
Reference in New Issue