11#include "COLLADAFWAnimation.h"
12#include "COLLADAFWAnimationCurve.h"
13#include "COLLADAFWAnimationList.h"
14#include "COLLADAFWCamera.h"
15#include "COLLADAFWEffect.h"
16#include "COLLADAFWLight.h"
17#include "COLLADAFWNode.h"
18#include "COLLADAFWRotate.h"
19#include "COLLADAFWUniqueId.h"
47 const std::string &
id = node->getName();
48 return id.empty() ? node->getOriginalId().c_str() :
id.c_str();
72FCurve *AnimationImporter::create_fcurve(
int array_index,
const char *rna_path)
81void AnimationImporter::add_bezt(
FCurve *fcu,
89 bez.
vec[1][0] = frame;
90 bez.
vec[1][1] = value;
98void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
100 COLLADAFW::FloatOrDoubleArray &
input = curve->getInputValues();
101 COLLADAFW::FloatOrDoubleArray &
output = curve->getOutputValues();
103 float fps = float(
FPS);
104 size_t dim = curve->getOutDimension();
107 std::vector<FCurve *> &fcurves = curve_map[curve->getUniqueId()];
115 for (
i = 0;
i < dim;
i++) {
122 for (
uint j = 0; j < curve->getKeyCount(); j++) {
131 if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
132 curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP)
134 COLLADAFW::FloatOrDoubleArray &intan = curve->getInTangentValues();
135 COLLADAFW::FloatOrDoubleArray &outtan = curve->getOutTangentValues();
138 uint index = 2 * (j * dim +
i);
145 if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) {
166 fcurves.push_back(fcu);
167 unused_curves.push_back(fcu);
173 "Output dimension of %d is not yet supported (animation id = %s)\n",
175 curve->getOriginalId().c_str());
179void AnimationImporter::fcurve_deg_to_rad(
FCurve *cu)
189void AnimationImporter::fcurve_scale(
FCurve *cu,
int scale)
199void AnimationImporter::fcurve_is_used(
FCurve *fcu)
201 unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu),
202 unused_curves.end());
208 for (
FCurve *unused_curve : unused_curves) {
212 if (!unused_curves.empty()) {
213 fprintf(stderr,
"removed %d unused curves\n",
int(unused_curves.size()));
219 if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
220 COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
224 if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
225 fprintf(stderr,
"Inputs physical dimension is not time.\n");
231 COLLADAFW::AnimationCurve::InterpolationType
interp = curve->getInterpolationType();
233 if (
interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
235 case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR:
236 case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER:
237 case COLLADAFW::AnimationCurve::INTERPOLATION_STEP:
238 animation_to_fcurves(curve);
243 "CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n");
249 fprintf(stderr,
"MIXED anim interpolation type is not supported yet.\n");
253 fprintf(stderr,
"FORMULA animation type is not supported yet.\n");
261 const COLLADAFW::UniqueId &animlist_id = animlist->getUniqueId();
262 animlist_map[animlist_id] = animlist;
267 if (uid_animated_map.find(animlist_id) == uid_animated_map.end()) {
289 const char *rna_path,
293 std::vector<FCurve *>::iterator it;
295 for (it = curves->begin(),
i = 0; it != curves->end(); it++,
i++) {
299 if (array_index == -1) {
307 fcurve_scale(fcu, scale);
317 std::vector<FCurve *>::iterator it;
318 for (it = curves->begin(); it != curves->end(); it++) {
326 std::vector<FCurve *>::iterator iter;
327 for (iter = curves->begin(); iter != curves->end(); iter++) {
332 float fra = fcu->
bezt[k].
vec[1][0];
334 if (std::find(frames->begin(), frames->end(), fra) == frames->end()) {
335 frames->push_back(fra);
344 if (COLLADABU::Math::Vector3::UNIT_X == axis) {
347 else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
350 else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
361 const COLLADAFW::AnimationList::AnimationBinding *binding,
362 std::vector<FCurve *> *curves,
366 COLLADAFW::Transformation::TransformationType tm_type =
transform->getTransformationType();
367 bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
368 bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
372 (
ELEM(tm_type, COLLADAFW::Transformation::TRANSLATE, COLLADAFW::Transformation::SCALE) &&
373 binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
375 if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) {
376 fprintf(stderr,
"expected %d curves, got %d\n", xyz ? 3 : 1,
int(curves->size()));
383 case COLLADAFW::Transformation::TRANSLATE:
384 case COLLADAFW::Transformation::SCALE: {
385 bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE;
387 SNPRINTF(rna_path,
"%s.%s", joint_path, loc ?
"location" :
"scale");
390 STRNCPY(rna_path, loc ?
"location" :
"scale");
393 switch (binding->animationClass) {
394 case COLLADAFW::AnimationList::POSITION_X:
397 case COLLADAFW::AnimationList::POSITION_Y:
400 case COLLADAFW::AnimationList::POSITION_Z:
403 case COLLADAFW::AnimationList::POSITION_XYZ:
409 "AnimationClass %d is not supported for %s.\n",
410 binding->animationClass,
411 loc ?
"TRANSLATE" :
"SCALE");
416 case COLLADAFW::Transformation::ROTATE: {
418 SNPRINTF(rna_path,
"%s.rotation_euler", joint_path);
421 STRNCPY(rna_path,
"rotation_euler");
423 std::vector<FCurve *>::iterator iter;
424 for (iter = curves->begin(); iter != curves->end(); iter++) {
429 fcurve_deg_to_rad(fcu);
432 const COLLADAFW::Rotate *
rot = (COLLADAFW::Rotate *)
transform;
433 const COLLADABU::Math::Vector3 &axis =
rot->getRotationAxis();
435 switch (binding->animationClass) {
436 case COLLADAFW::AnimationList::ANGLE: {
438 if (axis_index >= 0) {
446 case COLLADAFW::AnimationList::AXISANGLE:
451 "AnimationClass %d is not supported for ROTATE transformation.\n",
452 binding->animationClass);
457 case COLLADAFW::Transformation::MATRIX:
460 COLLADAFW::Matrix *mat = (COLLADAFW::Matrix *)
transform;
461 COLLADABU::Math::Matrix4 mat4 = mat->getMatrix();
462 switch (binding->animationClass) {
463 case COLLADAFW::AnimationList::TRANSFORM:
469 case COLLADAFW::Transformation::SKEW:
470 case COLLADAFW::Transformation::LOOKAT:
472 fprintf(stderr,
"Animation of SKEW and LOOKAT transformations is not supported yet.\n");
479 const char *anim_type)
486 const COLLADAFW::AnimationList *animlist = animlist_map[listid];
487 if (animlist ==
nullptr) {
489 "Collada: No animlist found for ID: %s of type %s\n",
490 listid.toAscii().c_str(),
495 const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
497 std::vector<FCurve *> animcurves;
498 for (
uint j = 0; j < bindings.getCount(); j++) {
499 animcurves = curve_map[bindings[j].animation];
501 switch (bindings[j].animationClass) {
502 case COLLADAFW::AnimationList::COLOR_R:
505 case COLLADAFW::AnimationList::COLOR_G:
508 case COLLADAFW::AnimationList::COLOR_B:
511 case COLLADAFW::AnimationList::COLOR_RGB:
512 case COLLADAFW::AnimationList::COLOR_RGBA:
519 "AnimationClass %d is not supported for %s.\n",
520 bindings[j].animationClass,
524 std::vector<FCurve *>::iterator iter;
526 for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
537 const char *anim_type)
542 if (animlist_map.find(listid) == animlist_map.end()) {
547 const COLLADAFW::AnimationList *animlist = animlist_map[listid];
548 const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
550 std::vector<FCurve *> animcurves;
551 for (
uint j = 0; j < bindings.getCount(); j++) {
552 animcurves = curve_map[bindings[j].animation];
556 std::vector<FCurve *>::iterator iter;
558 for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
562 if (
STREQ(
"spot_size", anim_type)) {
566 if (this->import_from_version.empty() ||
569 fcurve_deg_to_rad(fcu);
587 float xfov = (fov_type == CAMERA_YFOV) ?
597 const char *anim_type,
603 if (animlist_map.find(listid) == animlist_map.end()) {
608 const COLLADAFW::AnimationList *animlist = animlist_map[listid];
609 const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
611 std::vector<FCurve *> animcurves;
612 for (
uint j = 0; j < bindings.getCount(); j++) {
613 animcurves = curve_map[bindings[j].animation];
618 std::vector<FCurve *>::iterator iter;
620 for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
640 std::vector<FCurve *> &animcurves,
641 COLLADAFW::Node *root,
642 COLLADAFW::Node *node,
643 COLLADAFW::Transformation *tm)
645 bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
647 char joint_path[200];
649 armature_importer->get_rna_path_for_joint(node, joint_path,
sizeof(joint_path));
652 std::vector<float> frames;
655 float irest_dae[4][4];
656 float rest[4][4], irest[4][4];
664 fprintf(stderr,
"cannot find bone \"%s\"\n", bone_name);
675 const char *tm_str =
nullptr;
677 for (
int i = 0;
i < totcu;
i++) {
682 tm_str =
"rotation_quaternion";
695 SNPRINTF(rna_path,
"%s.%s", joint_path, tm_str);
700 newcu[
i] = create_fcurve(axis, rna_path);
704 if (frames.empty()) {
708 std::sort(frames.begin(), frames.end());
710 std::vector<float>::iterator it;
713 for (it = frames.begin(); it != frames.end(); it++) {
730 float temp[4][4], par[4][4];
743 float rot[4], loc[3], scale[3];
747 for (
int i = 0;
i < totcu;
i++) {
749 add_bezt(newcu[
i], fra,
rot[
i]);
752 add_bezt(newcu[
i], fra, loc[
i - 4]);
755 add_bezt(newcu[
i], fra, scale[
i - 7]);
764 for (
int i = 0;
i < totcu;
i++) {
773 fcurve_is_used(newcu[
i]);
798 double aspect = camera->getAspectRatio().getValue();
801 const double yfov = camera->getYFov().getValue();
807 const double xfov = camera->getXFov().getValue();
812 aspect = xfov / yfov;
820 COLLADAFW::Node *node,
821 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &root_map,
822 std::multimap<COLLADAFW::UniqueId, Object *> &object_map,
823 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map,
824 std::map<COLLADAFW::UniqueId, Material *> uid_material_map)
826 bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
827 COLLADAFW::UniqueId uid = node->getUniqueId();
828 COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid];
832 ob = armature_importer->get_armature_for_joint(root);
835 ob = object_map.find(uid) == object_map.end() ?
nullptr : object_map.find(uid)->second;
839 fprintf(stderr,
"cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str());
846 if ((animType->transform) != 0) {
848 char joint_path[200];
851 armature_importer->get_rna_path_for_joint(node, joint_path,
sizeof(joint_path));
856 const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
859 for (
uint i = 0;
i < nodeTransforms.getCount();
i++) {
860 COLLADAFW::Transformation *
transform = nodeTransforms[
i];
861 COLLADAFW::Transformation::TransformationType tm_type =
transform->getTransformationType();
863 bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
864 bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
866 const COLLADAFW::UniqueId &listid =
transform->getAnimationList();
869 if (animlist_map.find(listid) == animlist_map.end()) {
874 const COLLADAFW::AnimationList *animlist = animlist_map[listid];
875 const COLLADAFW::AnimationList::AnimationBindings &bindings =
876 animlist->getAnimationBindings();
878 std::vector<FCurve *> animcurves;
879 for (
uint j = 0; j < bindings.getCount(); j++) {
880 animcurves = curve_map[bindings[j].animation];
889 std::vector<FCurve *>::iterator iter;
891 for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
900 if (is_rotation && !(is_joint || is_matrix)) {
906 if ((animType->light) != 0) {
910 const COLLADAFW::InstanceLightPointerArray &nodeLights = node->getInstanceLights();
912 for (
uint i = 0;
i < nodeLights.getCount();
i++) {
913 const COLLADAFW::Light *light = (COLLADAFW::Light *)
914 FW_object_map[nodeLights[
i]->getInstanciatedObjectId()];
916 if ((animType->light & LIGHT_COLOR) != 0) {
917 const COLLADAFW::Color *
col = &light->getColor();
918 const COLLADAFW::UniqueId &listid =
col->getAnimationList();
922 if ((animType->light & LIGHT_FOA) != 0) {
923 const COLLADAFW::AnimatableFloat *foa = &light->getFallOffAngle();
924 const COLLADAFW::UniqueId &listid = foa->getAnimationList();
928 if ((animType->light & LIGHT_FOE) != 0) {
929 const COLLADAFW::AnimatableFloat *foe = &light->getFallOffExponent();
930 const COLLADAFW::UniqueId &listid = foe->getAnimationList();
937 if (animType->camera != 0) {
942 const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras();
944 for (
uint i = 0;
i < nodeCameras.getCount();
i++) {
945 const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
946 FW_object_map[nodeCameras[
i]->getInstanciatedObjectId()];
948 if ((animType->camera & CAMERA_XFOV) != 0) {
949 const COLLADAFW::AnimatableFloat *xfov = &camera->getXFov();
950 const COLLADAFW::UniqueId &listid = xfov->getAnimationList();
955 else if ((animType->camera & CAMERA_YFOV) != 0) {
956 const COLLADAFW::AnimatableFloat *yfov = &camera->getYFov();
957 const COLLADAFW::UniqueId &listid = yfov->getAnimationList();
962 else if ((animType->camera & CAMERA_XMAG) != 0) {
963 const COLLADAFW::AnimatableFloat *xmag = &camera->getXMag();
964 const COLLADAFW::UniqueId &listid = xmag->getAnimationList();
968 else if ((animType->camera & CAMERA_YMAG) != 0) {
969 const COLLADAFW::AnimatableFloat *ymag = &camera->getYMag();
970 const COLLADAFW::UniqueId &listid = ymag->getAnimationList();
974 if ((animType->camera & CAMERA_ZFAR) != 0) {
975 const COLLADAFW::AnimatableFloat *zfar = &camera->getFarClippingPlane();
976 const COLLADAFW::UniqueId &listid = zfar->getAnimationList();
980 if ((animType->camera & CAMERA_ZNEAR) != 0) {
981 const COLLADAFW::AnimatableFloat *znear = &camera->getNearClippingPlane();
982 const COLLADAFW::UniqueId &listid = znear->getAnimationList();
987 if (animType->material != 0) {
988 const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries();
989 for (
uint i = 0;
i < nodeGeoms.getCount();
i++) {
990 const COLLADAFW::MaterialBindingArray &matBinds = nodeGeoms[
i]->getMaterialBindings();
991 for (
uint j = 0; j < matBinds.getCount(); j++) {
992 const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial();
993 const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]);
995 Material *ma = uid_material_map[matuid];
998 "Collada: Node %s refers to undefined material\n",
999 node->getName().c_str());
1004 const COLLADAFW::CommonEffectPointerArray &commonEffects = ef->getCommonEffects();
1005 COLLADAFW::EffectCommon *efc = commonEffects[0];
1006 if ((animType->material & MATERIAL_SHININESS) != 0) {
1007 const COLLADAFW::FloatOrParam *shin = &efc->getShininess();
1008 const COLLADAFW::UniqueId &listid = shin->getAnimationList();
1012 if ((animType->material & MATERIAL_IOR) != 0) {
1013 const COLLADAFW::FloatOrParam *ior = &efc->getIndexOfRefraction();
1014 const COLLADAFW::UniqueId &listid = ior->getAnimationList();
1018 if ((animType->material & MATERIAL_SPEC_COLOR) != 0) {
1019 const COLLADAFW::ColorOrTexture *cot = &efc->getSpecular();
1020 const COLLADAFW::UniqueId &listid = cot->getColor().getAnimationList();
1024 if ((animType->material & MATERIAL_DIFF_COLOR) != 0) {
1025 const COLLADAFW::ColorOrTexture *cot = &efc->getDiffuse();
1026 const COLLADAFW::UniqueId &listid = cot->getColor().getAnimationList();
1038 const COLLADAFW::Node *node,
1039 std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
1041 AnimMix *
types =
new AnimMix();
1043 const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
1046 for (
uint i = 0;
i < nodeTransforms.getCount();
i++) {
1047 COLLADAFW::Transformation *
transform = nodeTransforms[
i];
1048 const COLLADAFW::UniqueId &listid =
transform->getAnimationList();
1051 if (animlist_map.find(listid) == animlist_map.end()) {
1055 types->transform =
types->transform | BC_NODE_TRANSFORM;
1058 const COLLADAFW::InstanceLightPointerArray &nodeLights = node->getInstanceLights();
1060 for (
uint i = 0;
i < nodeLights.getCount();
i++) {
1061 const COLLADAFW::Light *light = (COLLADAFW::Light *)
1062 FW_object_map[nodeLights[
i]->getInstanciatedObjectId()];
1067 if (
types->light != 0) {
1072 const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras();
1073 for (
uint i = 0;
i < nodeCameras.getCount();
i++) {
1074 const COLLADAFW::Camera *camera = (COLLADAFW::Camera *)
1075 FW_object_map[nodeCameras[
i]->getInstanciatedObjectId()];
1076 if (camera ==
nullptr) {
1081 const bool is_perspective_type = camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE;
1084 const COLLADAFW::Animatable *mag;
1085 const COLLADAFW::UniqueId listid = camera->getYMag().getAnimationList();
1086 if (animlist_map.find(listid) != animlist_map.end()) {
1087 mag = &camera->getYMag();
1088 addition = (is_perspective_type) ? CAMERA_YFOV : CAMERA_YMAG;
1091 mag = &camera->getXMag();
1092 addition = (is_perspective_type) ? CAMERA_XFOV : CAMERA_XMAG;
1099 if (
types->camera != 0) {
1104 const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries();
1105 for (
uint i = 0;
i < nodeGeoms.getCount();
i++) {
1106 const COLLADAFW::MaterialBindingArray &matBinds = nodeGeoms[
i]->getMaterialBindings();
1107 for (
uint j = 0; j < matBinds.getCount(); j++) {
1108 const COLLADAFW::UniqueId &matuid = matBinds[j].getReferencedMaterial();
1109 const COLLADAFW::Effect *ef = (COLLADAFW::Effect *)(FW_object_map[matuid]);
1110 if (ef !=
nullptr) {
1111 const COLLADAFW::CommonEffectPointerArray &commonEffects = ef->getCommonEffects();
1112 if (!commonEffects.empty()) {
1113 COLLADAFW::EffectCommon *efc = commonEffects[0];
1115 &efc->getShininess(), (
types->material), MATERIAL_SHININESS);
1117 &efc->getSpecular().getColor(), (
types->material), MATERIAL_SPEC_COLOR);
1119 &efc->getDiffuse().getColor(), (
types->material), MATERIAL_DIFF_COLOR);
1124 &efc->getIndexOfRefraction(), (
types->material), MATERIAL_IOR);
1135 const COLLADAFW::UniqueId &listid = prop->getAnimationList();
1136 if (animlist_map.find(listid) != animlist_map.end()) {
1137 anim_type =
types | addition;
1147 COLLADAFW::Node *node,
1150 const COLLADAFW::TransformationPointerArray &tms = node->getTransformations();
1154 for (
uint i = 0;
i < tms.getCount();
i++) {
1155 COLLADAFW::Transformation *tm = tms[
i];
1156 COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
1161 std::string nodename = node->getName().empty() ? node->getOriginalId() : node->getName();
1164 case COLLADAFW::Transformation::ROTATE:
1167 case COLLADAFW::Transformation::TRANSLATE:
1170 case COLLADAFW::Transformation::SCALE:
1173 case COLLADAFW::Transformation::MATRIX:
1177 fprintf(stderr,
"unsupported transformation type %d\n", type);
1189 const COLLADAFW::AnimationList::AnimationClass animclass,
1190 const COLLADAFW::Transformation::TransformationType type)
1192 if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
1193 fprintf(stderr,
"%s: UNKNOWN animation class\n", path);
1197 "%s: animation class %d is not supported yet for transformation type %d\n",
1207 const char *node_id)
1209 const COLLADAFW::UniqueId &listid = tm->getAnimationList();
1210 COLLADAFW::Transformation::TransformationType type = tm->getTransformationType();
1213 COLLADAFW::Transformation::ROTATE,
1214 COLLADAFW::Transformation::SCALE,
1215 COLLADAFW::Transformation::TRANSLATE,
1216 COLLADAFW::Transformation::MATRIX))
1218 fprintf(stderr,
"animation of transformation %d is not supported yet\n", type);
1222 if (animlist_map.find(listid) == animlist_map.end()) {
1226 const COLLADAFW::AnimationList *animlist = animlist_map[listid];
1227 const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
1229 if (bindings.getCount()) {
1232 bool is_scale = (type == COLLADAFW::Transformation::SCALE);
1233 bool is_translate = (type == COLLADAFW::Transformation::TRANSLATE);
1238 else if (is_translate) {
1242 for (
uint index = 0; index < bindings.getCount(); index++) {
1243 const COLLADAFW::AnimationList::AnimationBinding &binding = bindings[index];
1244 std::vector<FCurve *> &curves = curve_map[binding.animation];
1245 COLLADAFW::AnimationList::AnimationClass animclass = binding.animationClass;
1249 case COLLADAFW::Transformation::ROTATE:
1250 SNPRINTF(path,
"%s.rotate (binding %u)", node_id, index);
1252 case COLLADAFW::Transformation::SCALE:
1253 SNPRINTF(path,
"%s.scale (binding %u)", node_id, index);
1255 case COLLADAFW::Transformation::TRANSLATE:
1256 SNPRINTF(path,
"%s.translate (binding %u)", node_id, index);
1258 case COLLADAFW::Transformation::MATRIX:
1259 SNPRINTF(path,
"%s.matrix (binding %u)", node_id, index);
1265 if (type == COLLADAFW::Transformation::ROTATE) {
1266 if (curves.size() != 1) {
1267 fprintf(stderr,
"expected 1 curve, got %d\n",
int(curves.size()));
1272 if (animclass != COLLADAFW::AnimationList::ANGLE) {
1277 COLLADABU::Math::Vector3 &axis = ((COLLADAFW::Rotate *)tm)->getRotationAxis();
1279 float ax[3] = {float(axis[0]), float(axis[1]), float(axis[2])};
1285 if (is_scale || is_translate) {
1286 bool is_xyz = animclass == COLLADAFW::AnimationList::POSITION_XYZ;
1288 if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) {
1290 fprintf(stderr,
"%s: expected 3 curves, got %d\n", path,
int(curves.size()));
1293 fprintf(stderr,
"%s: expected 1 curve, got %d\n", path,
int(curves.size()));
1298 switch (animclass) {
1299 case COLLADAFW::AnimationList::POSITION_X:
1302 case COLLADAFW::AnimationList::POSITION_Y:
1305 case COLLADAFW::AnimationList::POSITION_Z:
1308 case COLLADAFW::AnimationList::POSITION_XYZ:
1318 else if (type == COLLADAFW::Transformation::MATRIX) {
1321 if (curves.size() != 16) {
1322 fprintf(stderr,
"%s: expected 16 curves, got %d\n", path,
int(curves.size()));
1326 COLLADABU::Math::Matrix4 matrix;
1329 for (
const FCurve *curve : curves) {
1349 return is_scale || is_translate;
1356 COLLADAFW::Node *root,
1357 COLLADAFW::Node *node)
1361 if (!armature_importer->get_joint_bind_mat(mat, node)) {
1362 float par[4][4], m[4][4];
1372 COLLADAFW::Node *node,
1373 COLLADAFW::Node *end)
1383 if (!armature_importer->get_joint_bind_mat(m, node)) {
1394 COLLADAFW::NodePointerArray &children = node->getChildNodes();
1395 for (
uint i = 0;
i < children.getCount();
i++) {
1416 this->import_from_version = import_from_version;
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
Functions to work with AnimData.
Functions to modify FCurves.
static const char * bc_get_joint_name(T *node)
static void report_class_type_unsupported(const char *path, const COLLADAFW::AnimationList::AnimationClass animclass, const COLLADAFW::Transformation::TransformationType type)
static double get_aspect_ratio(const COLLADAFW::Camera *camera)
static void ensure_action_and_slot_for_id(Main *bmain, ID &id)
static int get_animation_axis_index(const COLLADABU::Math::Vector3 &axis)
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
Bone * BKE_armature_find_bone_name(bArmature *arm, const char *name)
Main * CTX_data_main(const bContext *C)
FCurve * BKE_fcurve_create()
void BKE_fcurve_handles_recalc(FCurve *fcu)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_fcurve_free(FCurve *fcu)
General operations, lookup, etc. for blender objects.
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void mat4_decompose(float loc[3], float quat[4], float size[3], const float wmat[4][4])
void size_to_mat4(float R[4][4], const float size[3])
#define mul_m4_series(...)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
bool invert_m4(float mat[4][4])
void unit_m4(float m[4][4])
void axis_angle_to_mat4(float R[4][4], const float axis[3], float angle)
float fov_to_focallength(float hfov, float sensor)
MINLINE void copy_v3_v3(float r[3], const float a[3])
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
#define UNUSED_VARS_NDEBUG(...)
struct BezTriple BezTriple
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
void get_joint_rest_mat(float mat[4][4], COLLADAFW::Node *root, COLLADAFW::Node *node)
float convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx)
void find_frames(std::vector< float > *frames, std::vector< FCurve * > *curves)
bool evaluate_animation(COLLADAFW::Transformation *tm, float mat[4][4], float fra, const char *node_id)
void read_node_transform(COLLADAFW::Node *node, Object *ob)
void Assign_transform_animations(COLLADAFW::Transformation *transform, const COLLADAFW::AnimationList::AnimationBinding *binding, std::vector< FCurve * > *curves, bool is_joint, char *joint_path)
int setAnimType(const COLLADAFW::Animatable *prop, int type, int addition)
void Assign_float_animations(const COLLADAFW::UniqueId &listid, AnimData &adt, const char *anim_type)
bool write_animation_list(const COLLADAFW::AnimationList *animlist)
AnimMix * get_animation_type(const COLLADAFW::Node *node, std::map< COLLADAFW::UniqueId, const COLLADAFW::Object * > FW_object_map)
void unused_fcurve(std::vector< FCurve * > *curves)
void Assign_color_animations(const COLLADAFW::UniqueId &listid, AnimData &adt, const char *anim_type)
void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu)
void modify_fcurve(std::vector< FCurve * > *curves, const char *rna_path, int array_index, int scale=1)
bool calc_joint_parent_mat_rest(float mat[4][4], float par[4][4], COLLADAFW::Node *node, COLLADAFW::Node *end)
void evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra)
void apply_matrix_curves(Object *ob, std::vector< FCurve * > &animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
void Assign_lens_animations(const COLLADAFW::UniqueId &listid, AnimData &adt, double aspect, const Camera *cam, const char *anim_type, int fov_type)
void translate_Animations(COLLADAFW::Node *Node, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &root_map, std::multimap< COLLADAFW::UniqueId, Object * > &object_map, std::map< COLLADAFW::UniqueId, const COLLADAFW::Object * > FW_object_map, std::map< COLLADAFW::UniqueId, Material * > uid_material_map)
bool write_animation(const COLLADAFW::Animation *anim)
void set_import_from_version(std::string import_from_version)
static void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4 &in)
float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, uint index)
ccl_device_inline float interp(const float a, const float b, const float t)
bool action_treat_as_legacy(const bAction &action)
void action_fcurve_attach(Action &action, slot_handle_t action_slot, FCurve &fcurve_to_attach, std::optional< StringRefNull > group_name)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
bAction * id_action_ensure(Main *bmain, ID *id)
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
Lesser Key-framing API call.
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
ObjectRuntimeHandle * runtime