diff options
Diffstat (limited to 'source/blender/collada/AnimationImporter.cpp')
-rw-r--r-- | source/blender/collada/AnimationImporter.cpp | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 8ef2235b6fb..8e691c6da67 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -138,7 +138,8 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) bez.ipo = BEZT_IPO_CONST; //bez.h1 = bez.h2 = HD_AUTO; } - else { + else + { bez.h1 = bez.h2 = HD_AUTO; bez.ipo = BEZT_IPO_LIN; } @@ -438,6 +439,16 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , const char* } } +void AnimationImporter::unused_fcurve(std::vector<FCurve*>* curves) +{ + // when an error happens and we can't actually use curve remove it from unused_curves + std::vector<FCurve*>::iterator it; + for (it = curves->begin(); it != curves->end(); it++) { + FCurve *fcu = *it; + unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end()); + } +} + void AnimationImporter::find_frames( std::vector<float>* frames , std::vector<FCurve*>* curves) { std::vector<FCurve*>::iterator iter; @@ -499,6 +510,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * modify_fcurve(curves, rna_path, -1 ); break; default: + unused_fcurve(curves); fprintf(stderr, "AnimationClass %d is not supported for %s.\n", binding->animationClass, loc ? "TRANSLATE" : "SCALE"); } @@ -534,10 +546,13 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { modify_fcurve(curves, rna_path, 2 ); } + else + unused_fcurve(curves); break; case COLLADAFW::AnimationList::AXISANGLE: // TODO convert axis-angle to quat? or XYZ? default: + unused_fcurve(curves); fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", binding->animationClass); } @@ -553,9 +568,11 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * } }*/ + unused_fcurve(curves); break; case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: + unused_fcurve(curves); fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n"); break; } @@ -591,6 +608,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list break; default: + unused_fcurve(&animcurves); fprintf(stderr, "AnimationClass %d is not supported for %s.\n", bindings[j].animationClass, "COLOR" ); } @@ -788,15 +806,17 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bool is_joint = node->getType() == COLLADAFW::Node::JOINT; COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()]; Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map[node->getUniqueId()]; - if (!ob) { + if (!ob) + { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); return; } bAction * act; - if ( (animType->transform) != 0 ) { - /* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */ + if ( (animType->transform) != 0 ) + { + const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; char joint_path[200]; if ( is_joint ) @@ -864,7 +884,8 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } - if ((animType->light) != 0) { + if ((animType->light) != 0) + { Lamp * lamp = (Lamp*) ob->data; if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1); @@ -876,19 +897,22 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , for (unsigned int i = 0; i < nodeLights.getCount(); i++) { const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()]; - if ((animType->light & LIGHT_COLOR) != 0) { + if ((animType->light & LIGHT_COLOR) != 0) + { const COLLADAFW::Color *col = &(light->getColor()); const COLLADAFW::UniqueId& listid = col->getAnimationList(); Assign_color_animations(listid, AnimCurves, "color"); } - if ((animType->light & LIGHT_FOA) != 0 ) { + if ((animType->light & LIGHT_FOA) != 0 ) + { const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle()); const COLLADAFW::UniqueId& listid = foa->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "spot_size"); } - if ( (animType->light & LIGHT_FOE) != 0 ) { + if ( (animType->light & LIGHT_FOE) != 0 ) + { const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent()); const COLLADAFW::UniqueId& listid = foe->getAnimationList(); @@ -898,7 +922,8 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } - if ( (animType->camera) != 0) { + if ( (animType->camera) != 0) + { Camera * camera = (Camera*) ob->data; if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1); @@ -910,25 +935,29 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; - if ((animType->camera & CAMERA_XFOV) != 0 ) { + if ((animType->camera & CAMERA_XFOV) != 0 ) + { const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov()); const COLLADAFW::UniqueId& listid = xfov->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "lens"); } - else if ((animType->camera & CAMERA_XMAG) != 0 ) { + else if ((animType->camera & CAMERA_XMAG) != 0 ) + { const COLLADAFW::AnimatableFloat *xmag = &(camera->getXMag()); const COLLADAFW::UniqueId& listid = xmag->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "ortho_scale"); } - if ((animType->camera & CAMERA_ZFAR) != 0 ) { + if ((animType->camera & CAMERA_ZFAR) != 0 ) + { const COLLADAFW::AnimatableFloat *zfar = &(camera->getFarClippingPlane()); const COLLADAFW::UniqueId& listid = zfar->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "clip_end"); } - if ((animType->camera & CAMERA_ZNEAR) != 0 ) { + if ((animType->camera & CAMERA_ZNEAR) != 0 ) + { const COLLADAFW::AnimatableFloat *znear = &(camera->getNearClippingPlane()); const COLLADAFW::UniqueId& listid = znear->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "clip_start"); @@ -1150,10 +1179,12 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; - if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) { + if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) + { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); } - else { + else + { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG); } types->camera = setAnimType(&(camera->getFarClippingPlane()),(types->camera), CAMERA_ZFAR); @@ -1627,7 +1658,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate*)tm)->getRotationAxis(); - float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]}; + float ax[3] = {axis[0], axis[1], axis[2]}; float angle = evaluate_fcurve(curves[0], fra); axis_angle_to_mat4(mat, ax, angle); @@ -1753,9 +1784,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4] Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job) { if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) { - Object *job = add_object(scene, OB_EMPTY); - - rename_id((ID*)&job->id, (char*)get_joint_name(node)); + Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node)); job->lay = object_in_scene(job, scene)->lay = 2; |