Changeset View
Changeset View
Standalone View
Standalone View
source/blender/collada/AnimationExporter.cpp
| Show First 20 Lines • Show All 699 Lines • ▼ Show 20 Lines | case COLLADASW::InputSemantic::OUT_TANGENT: | ||||
| param.push_back("X"); | param.push_back("X"); | ||||
| param.push_back("Y"); | param.push_back("Y"); | ||||
| break; | break; | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_rotation, float *values, int *length) | void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length) | ||||
| { | { | ||||
| switch (semantic) { | switch (semantic) { | ||||
| case COLLADASW::InputSemantic::INPUT: | case COLLADASW::InputSemantic::INPUT: | ||||
| *length = 1; | *length = 1; | ||||
| values[0] = convert_time(bezt->vec[1][0]); | values[0] = convert_time(bezt->vec[1][0]); | ||||
| break; | break; | ||||
| case COLLADASW::InputSemantic::OUTPUT: | case COLLADASW::InputSemantic::OUTPUT: | ||||
| *length = 1; | *length = 1; | ||||
| if (is_rotation) { | if (is_angle) { | ||||
| values[0] = RAD2DEGF(bezt->vec[1][1]); | values[0] = RAD2DEGF(bezt->vec[1][1]); | ||||
| } | } | ||||
| 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: | ||||
| *length = 2; | *length = 2; | ||||
| values[0] = convert_time(bezt->vec[0][0]); | values[0] = convert_time(bezt->vec[0][0]); | ||||
| if (bezt->ipo != BEZT_IPO_BEZ) { | if (bezt->ipo != BEZT_IPO_BEZ) { | ||||
| // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data | // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data | ||||
| values[0] = 0; | values[0] = 0; | ||||
| values[1] = 0; | values[1] = 0; | ||||
| } | } | ||||
| else if (is_rotation) { | else if (is_angle) { | ||||
| values[1] = RAD2DEGF(bezt->vec[0][1]); | values[1] = RAD2DEGF(bezt->vec[0][1]); | ||||
| } | } | ||||
| 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: | ||||
| *length = 2; | *length = 2; | ||||
| values[0] = convert_time(bezt->vec[2][0]); | values[0] = convert_time(bezt->vec[2][0]); | ||||
| if (bezt->ipo != BEZT_IPO_BEZ) { | if (bezt->ipo != BEZT_IPO_BEZ) { | ||||
| // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data | // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data | ||||
| values[0] = 0; | values[0] = 0; | ||||
| values[1] = 0; | values[1] = 0; | ||||
| } | } | ||||
| else if (is_rotation) { | else if (is_angle) { | ||||
| values[1] = RAD2DEGF(bezt->vec[2][1]); | values[1] = RAD2DEGF(bezt->vec[2][1]); | ||||
| } | } | ||||
| else { | else { | ||||
| values[1] = bezt->vec[2][1]; | values[1] = bezt->vec[2][1]; | ||||
| } | } | ||||
| break; | break; | ||||
| default: | default: | ||||
| *length = 0; | *length = 0; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) | std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) | ||||
| { | { | ||||
| std::string source_id = anim_id + get_semantic_suffix(semantic); | std::string source_id = anim_id + get_semantic_suffix(semantic); | ||||
| //bool is_rotation = !strcmp(fcu->rna_path, "rotation"); | //bool is_angle = !strcmp(fcu->rna_path, "rotation"); | ||||
| bool is_angle = false; | bool is_angle = false; | ||||
| if (strstr(fcu->rna_path, "rotation")) is_angle = true; | if (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path,"spot_size")) is_angle = true; | ||||
| COLLADASW::FloatSourceF source(mSW); | COLLADASW::FloatSourceF source(mSW); | ||||
| source.setId(source_id); | source.setId(source_id); | ||||
| source.setArrayId(source_id + ARRAY_ID_SUFFIX); | source.setArrayId(source_id + ARRAY_ID_SUFFIX); | ||||
| source.setAccessorCount(fcu->totvert); | source.setAccessorCount(fcu->totvert); | ||||
| switch (semantic) { | switch (semantic) { | ||||
| case COLLADASW::InputSemantic::INPUT: | case COLLADASW::InputSemantic::INPUT: | ||||
| ▲ Show 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) | ||||
| return std::string(""); | return std::string(""); | ||||
| } | } | ||||
| // Assign sid of the animated parameter or transform | // Assign sid of the animated parameter or transform | ||||
| // for rotation, axis name is always appended and the value of append_axis is ignored | // for rotation, axis name is always appended and the value of append_axis is ignored | ||||
| std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) | std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) | ||||
| { | { | ||||
| std::string tm_name; | std::string tm_name; | ||||
| bool is_rotation = false; | bool is_angle = false; | ||||
| // when given rna_path, determine tm_type from it | // when given rna_path, determine tm_type from it | ||||
| if (rna_path) { | if (rna_path) { | ||||
| char *name = extract_transform_name(rna_path); | char *name = extract_transform_name(rna_path); | ||||
| if (!strcmp(name, "rotation_euler")) | if (!strcmp(name, "rotation_euler")) | ||||
| tm_type = 0; | tm_type = 0; | ||||
| else if (!strcmp(name, "rotation_quaternion")) | else if (!strcmp(name, "rotation_quaternion")) | ||||
| tm_type = 1; | tm_type = 1; | ||||
| Show All 15 Lines | if (rna_path) { | ||||
| else | else | ||||
| tm_type = -1; | tm_type = -1; | ||||
| } | } | ||||
| switch (tm_type) { | switch (tm_type) { | ||||
| case 0: | case 0: | ||||
| case 1: | case 1: | ||||
| tm_name = "rotation"; | tm_name = "rotation"; | ||||
| is_rotation = true; | is_angle = true; | ||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| tm_name = "scale"; | tm_name = "scale"; | ||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| tm_name = "location"; | tm_name = "location"; | ||||
| break; | break; | ||||
| case 4: | case 4: | ||||
| Show All 13 Lines | case 8: | ||||
| break; | break; | ||||
| default: | default: | ||||
| tm_name = ""; | tm_name = ""; | ||||
| break; | break; | ||||
| } | } | ||||
| if (tm_name.size()) { | if (tm_name.size()) { | ||||
| if (is_rotation) | if (is_angle) | ||||
| return tm_name + std::string(axis_name) + ".ANGLE"; | return tm_name + std::string(axis_name) + ".ANGLE"; | ||||
| else | else | ||||
| if (axis_name[0]) | if (axis_name[0]) | ||||
| return tm_name + "." + std::string(axis_name); | return tm_name + "." + std::string(axis_name); | ||||
| else | else | ||||
| return tm_name; | return tm_name; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 301 Lines • Show Last 20 Lines | |||||