forked from bartvdbraak/blender
Reverted Exporter unit conversion modifications.
Animation Importer Code Cleanup.
This commit is contained in:
parent
6aa524f357
commit
d240733ae2
@ -428,7 +428,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
|
|
||||||
float AnimationExporter::convert_angle(float angle)
|
float AnimationExporter::convert_angle(float angle)
|
||||||
{
|
{
|
||||||
return COLLADABU::Math::Utils::degToRadF(angle);
|
return COLLADABU::Math::Utils::radToDegF(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
|
std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
|
||||||
@ -491,12 +491,12 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
break;
|
break;
|
||||||
case COLLADASW::InputSemantic::OUTPUT:
|
case COLLADASW::InputSemantic::OUTPUT:
|
||||||
*length = 1;
|
*length = 1;
|
||||||
/*if (rotation) {
|
if (rotation) {
|
||||||
values[0] = convert_angle(bezt->vec[1][1]);
|
values[0] = (bezt->vec[1][1]) * 180.0f/M_PI;
|
||||||
}
|
}
|
||||||
else {*/
|
else {
|
||||||
values[0] = bezt->vec[1][1];
|
values[0] = bezt->vec[1][1];
|
||||||
//}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLLADASW::InputSemantic::IN_TANGENT:
|
case COLLADASW::InputSemantic::IN_TANGENT:
|
||||||
@ -507,11 +507,11 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
values[0] = 0;
|
values[0] = 0;
|
||||||
values[1] = 0;
|
values[1] = 0;
|
||||||
}
|
}
|
||||||
/* else if (rotation) {
|
else if (rotation) {
|
||||||
values[1] = convert_angle(bezt->vec[0][1]);
|
values[1] = (bezt->vec[0][1]) * 180.0f/M_PI;
|
||||||
} else {*/
|
} else {
|
||||||
values[1] = bezt->vec[0][1];
|
values[1] = bezt->vec[0][1];
|
||||||
//}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLLADASW::InputSemantic::OUT_TANGENT:
|
case COLLADASW::InputSemantic::OUT_TANGENT:
|
||||||
@ -522,11 +522,11 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
values[0] = 0;
|
values[0] = 0;
|
||||||
values[1] = 0;
|
values[1] = 0;
|
||||||
}
|
}
|
||||||
/* else if (rotation) {
|
else if (rotation) {
|
||||||
values[1] = convert_angle(bezt->vec[2][1]);
|
values[1] = (bezt->vec[0][1]) * 180.0f/M_PI;
|
||||||
} else {*/
|
} else {
|
||||||
values[1] = bezt->vec[2][1];
|
values[1] = bezt->vec[2][1];
|
||||||
//}
|
}
|
||||||
break;
|
break;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -601,7 +601,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
// val = convert_time(val);
|
// val = convert_time(val);
|
||||||
//else
|
//else
|
||||||
if (is_rot)
|
if (is_rot)
|
||||||
val = convert_angle(val);
|
val *= 180.0f / M_PI;
|
||||||
source.appendValues(val);
|
source.appendValues(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,16 +535,6 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Object *AnimationImporter::translate_animation(COLLADAFW::Node *node,
|
|
||||||
// std::map<COLLADAFW::UniqueId, Object*>& object_map,
|
|
||||||
// std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
|
|
||||||
// COLLADAFW::Transformation::TransformationType tm_type,
|
|
||||||
// Object *par_job)
|
|
||||||
//{
|
|
||||||
// bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
|
||||||
// //bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//sets the rna_path and array index to curve
|
//sets the rna_path and array index to curve
|
||||||
void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , char* rna_path , int array_index )
|
void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , char* rna_path , int array_index )
|
||||||
@ -567,11 +557,7 @@ void AnimationImporter::find_frames( std::vector<float>* frames , std::vector<FC
|
|||||||
std::vector<FCurve*>::iterator iter;
|
std::vector<FCurve*>::iterator iter;
|
||||||
for (iter = curves->begin(); iter != curves->end(); iter++) {
|
for (iter = curves->begin(); iter != curves->end(); iter++) {
|
||||||
FCurve *fcu = *iter;
|
FCurve *fcu = *iter;
|
||||||
//
|
|
||||||
////if transform is rotation the fcurves values must be turned in to radian.
|
|
||||||
//if (is_rotation)
|
|
||||||
// fcurve_deg_to_rad(fcu);
|
|
||||||
|
|
||||||
for (unsigned int k = 0; k < fcu->totvert; k++) {
|
for (unsigned int k = 0; k < fcu->totvert; k++) {
|
||||||
//get frame value from bezTriple
|
//get frame value from bezTriple
|
||||||
float fra = fcu->bezt[k].vec[1][0];
|
float fra = fcu->bezt[k].vec[1][0];
|
||||||
@ -589,32 +575,10 @@ void AnimationImporter:: Assign_transform_animations(std::vector<float>* frames,
|
|||||||
const COLLADAFW::AnimationList::AnimationBinding * binding,
|
const COLLADAFW::AnimationList::AnimationBinding * binding,
|
||||||
std::vector<FCurve*>* curves, bool is_joint, char * joint_path)
|
std::vector<FCurve*>* curves, bool is_joint, char * joint_path)
|
||||||
{
|
{
|
||||||
//bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
|
|
||||||
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
|
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
|
||||||
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
||||||
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
||||||
//Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
|
|
||||||
|
|
||||||
//char joint_path[100];
|
|
||||||
|
|
||||||
/*if ( is_joint )
|
|
||||||
armature_importer->get_rna_path_for_joint(animated.node, joint_path, sizeof(joint_path));*/
|
|
||||||
|
|
||||||
//bAction * act;
|
|
||||||
|
|
||||||
//if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
|
|
||||||
//else act = ob->adt->action;
|
|
||||||
//
|
|
||||||
////Get the list of animation curves of the object
|
|
||||||
// ListBase *AnimCurves = act->curves;
|
|
||||||
//
|
|
||||||
|
|
||||||
// char* tm_str;
|
|
||||||
// int array_index;
|
|
||||||
|
|
||||||
//curves belonging to the animation
|
|
||||||
//std::vector<FCurve*> curves = curve_map[bindings[j].animation];
|
|
||||||
|
|
||||||
//to check if the no of curves are valid
|
//to check if the no of curves are valid
|
||||||
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
|
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
|
||||||
|
|
||||||
@ -644,19 +608,15 @@ void AnimationImporter:: Assign_transform_animations(std::vector<float>* frames,
|
|||||||
switch (binding->animationClass) {
|
switch (binding->animationClass) {
|
||||||
case COLLADAFW::AnimationList::POSITION_X:
|
case COLLADAFW::AnimationList::POSITION_X:
|
||||||
modify_fcurve(curves, rna_path, 0 );
|
modify_fcurve(curves, rna_path, 0 );
|
||||||
//add_fcurves_to_object(ob, curves, rna_path, 0, &animated);
|
|
||||||
break;
|
break;
|
||||||
case COLLADAFW::AnimationList::POSITION_Y:
|
case COLLADAFW::AnimationList::POSITION_Y:
|
||||||
modify_fcurve(curves, rna_path, 1 );
|
modify_fcurve(curves, rna_path, 1 );
|
||||||
//add_fcurves_to_object(ob, curves, rna_path, 1, &animated);
|
|
||||||
break;
|
break;
|
||||||
case COLLADAFW::AnimationList::POSITION_Z:
|
case COLLADAFW::AnimationList::POSITION_Z:
|
||||||
modify_fcurve(curves, rna_path, 2 );
|
modify_fcurve(curves, rna_path, 2 );
|
||||||
//add_fcurves_to_object(ob, curves, rna_path, 2, &animated);
|
|
||||||
break;
|
break;
|
||||||
case COLLADAFW::AnimationList::POSITION_XYZ:
|
case COLLADAFW::AnimationList::POSITION_XYZ:
|
||||||
modify_fcurve(curves, rna_path, -1 );
|
modify_fcurve(curves, rna_path, -1 );
|
||||||
//add_fcurves_to_object(ob, curves, rna_path, -1, &animated);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
|
fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
|
||||||
@ -687,15 +647,12 @@ void AnimationImporter:: Assign_transform_animations(std::vector<float>* frames,
|
|||||||
case COLLADAFW::AnimationList::ANGLE:
|
case COLLADAFW::AnimationList::ANGLE:
|
||||||
if (COLLADABU::Math::Vector3::UNIT_X == axis) {
|
if (COLLADABU::Math::Vector3::UNIT_X == axis) {
|
||||||
modify_fcurve(curves, rna_path, 0 );
|
modify_fcurve(curves, rna_path, 0 );
|
||||||
//add_fcurves_to_object(ob, fcurves, rna_path, 0, &animated);
|
|
||||||
}
|
}
|
||||||
else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
|
else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
|
||||||
modify_fcurve(curves, rna_path, 1 );
|
modify_fcurve(curves, rna_path, 1 );
|
||||||
//add_fcurves_to_object(ob, fcurves, rna_path, 1, &animated);
|
|
||||||
}
|
}
|
||||||
else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
|
else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
|
||||||
modify_fcurve(curves, rna_path, 2 );
|
modify_fcurve(curves, rna_path, 2 );
|
||||||
//add_fcurves_to_object(ob, fcurves, rna_path, 2, &animated);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COLLADAFW::AnimationList::AXISANGLE:
|
case COLLADAFW::AnimationList::AXISANGLE:
|
||||||
@ -713,8 +670,7 @@ void AnimationImporter:: Assign_transform_animations(std::vector<float>* frames,
|
|||||||
fprintf(stderr, "Animation of MATRIX, SKEW and LOOKAT transformations is not supported yet.\n");
|
fprintf(stderr, "Animation of MATRIX, SKEW and LOOKAT transformations is not supported yet.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//BLI_addtail(&AnimCurves, curves);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
||||||
@ -727,7 +683,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
|
Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
|
||||||
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
|
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
|
||||||
|
|
||||||
if ( ! is_object_animated(ob,node) ) return ;
|
if ( ! is_object_animated(node) ) return ;
|
||||||
|
|
||||||
char joint_path[200];
|
char joint_path[200];
|
||||||
|
|
||||||
@ -749,7 +705,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float irest_dae[4][4];
|
/*float irest_dae[4][4];
|
||||||
float rest[4][4], irest[4][4];
|
float rest[4][4], irest[4][4];
|
||||||
|
|
||||||
if (is_joint) {
|
if (is_joint) {
|
||||||
@ -765,7 +721,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
unit_m4(rest);
|
unit_m4(rest);
|
||||||
copy_m4_m4(rest, bone->arm_mat);
|
copy_m4_m4(rest, bone->arm_mat);
|
||||||
invert_m4_m4(irest, rest);
|
invert_m4_m4(irest, rest);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
||||||
|
|
||||||
@ -776,14 +732,12 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
|
|
||||||
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
||||||
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
||||||
|
|
||||||
|
|
||||||
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
|
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
|
||||||
|
|
||||||
//might not be needed, let's see
|
//might not be needed
|
||||||
std::vector<float> frames;
|
std::vector<float> frames;
|
||||||
//all the curves belonging to the transform
|
|
||||||
|
|
||||||
//check if transformation has animations
|
//check if transformation has animations
|
||||||
if (animlist_map.find(listid) == animlist_map.end()) continue ;
|
if (animlist_map.find(listid) == animlist_map.end()) continue ;
|
||||||
else
|
else
|
||||||
@ -795,11 +749,10 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
std::vector<FCurve*> animcurves;
|
std::vector<FCurve*> animcurves;
|
||||||
for (unsigned int j = 0; j < bindings.getCount(); j++) {
|
for (unsigned int j = 0; j < bindings.getCount(); j++) {
|
||||||
animcurves = curve_map[bindings[j].animation];
|
animcurves = curve_map[bindings[j].animation];
|
||||||
|
|
||||||
//calculate rnapaths and array index of fcurves according to transformation and animation class
|
//calculate rnapaths and array index of fcurves according to transformation and animation class
|
||||||
|
Assign_transform_animations(&frames,transform, &bindings[j], &animcurves, is_joint, joint_path );
|
||||||
Assign_transform_animations(&frames,transform, &bindings[j], &animcurves, is_joint, joint_path );
|
|
||||||
std::vector<FCurve*>::iterator iter;
|
std::vector<FCurve*>::iterator iter;
|
||||||
//Add the curves of the current animation to the object
|
//Add the curves of the current animation to the object
|
||||||
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
|
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
|
||||||
FCurve * fcu = *iter;
|
FCurve * fcu = *iter;
|
||||||
@ -826,7 +779,8 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationImporter::is_object_animated ( const Object *ob , const COLLADAFW::Node * node )
|
//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
|
||||||
|
bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node )
|
||||||
{
|
{
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
||||||
@ -847,7 +801,8 @@ bool AnimationImporter::is_object_animated ( const Object *ob , const COLLADAFW:
|
|||||||
|
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//XXX Is not used anymore.
|
||||||
void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node , COLLADAFW::Transformation::TransformationType tm_type)
|
void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node , COLLADAFW::Transformation::TransformationType tm_type)
|
||||||
{
|
{
|
||||||
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
||||||
|
@ -99,7 +99,7 @@ public:
|
|||||||
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
|
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
|
||||||
std::map<COLLADAFW::UniqueId, Object*>& object_map );
|
std::map<COLLADAFW::UniqueId, Object*>& object_map );
|
||||||
|
|
||||||
bool is_object_animated ( const Object *ob , const COLLADAFW::Node * node ) ;
|
bool is_object_animated ( const COLLADAFW::Node * node ) ;
|
||||||
|
|
||||||
|
|
||||||
void Assign_transform_animations(std::vector<float>* frames,
|
void Assign_transform_animations(std::vector<float>* frames,
|
||||||
|
Loading…
Reference in New Issue
Block a user