Added new option for storing bindpose matrix, see T50412
This commit is contained in:
parent
339d0170d1
commit
092d673689
@ -93,6 +93,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
||||
{
|
||||
float mat[4][4];
|
||||
float joint_inv_bind_mat[4][4];
|
||||
float joint_bind_mat[4][4];
|
||||
int chain_length = 0;
|
||||
|
||||
//Checking if bone is already made.
|
||||
@ -116,7 +117,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
||||
|
||||
// get original world-space matrix
|
||||
invert_m4_m4(mat, joint_inv_bind_mat);
|
||||
|
||||
copy_m4_m4(joint_bind_mat, mat);
|
||||
// And make local to armature
|
||||
Object *ob_arm = skin->BKE_armature_from_object();
|
||||
if (ob_arm) {
|
||||
@ -165,6 +166,14 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
||||
bone->roll = angle;
|
||||
}
|
||||
copy_v3_v3(bone->head, mat[3]);
|
||||
|
||||
if (bone_is_skinned)
|
||||
{
|
||||
float rest_mat[4][4];
|
||||
get_node_mat(rest_mat, node, NULL, NULL, NULL);
|
||||
bc_create_bindpose_properties(this->import_settings, bone, joint_bind_mat, rest_mat);
|
||||
}
|
||||
|
||||
add_v3_v3v3(bone->tail, bone->head, tail); //tail must be non zero
|
||||
|
||||
/* find smallest bone length in armature (used later for leaf bone length) */
|
||||
@ -266,7 +275,6 @@ void ArmatureImporter::fix_parent_connect(bArmature *armature, Bone *bone)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone, int clip)
|
||||
{
|
||||
BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature);
|
||||
@ -302,7 +310,6 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone
|
||||
EditBone *pebone = bc_get_edit_bone(armature, parentbone->name);
|
||||
EditBone *cebone = bc_get_edit_bone(armature, dominant_child->get_name());
|
||||
if (pebone && !(cebone->flag & BONE_CONNECTED)) {
|
||||
|
||||
float vec[3];
|
||||
sub_v3_v3v3(vec, cebone->head, pebone->head);
|
||||
|
||||
|
@ -51,7 +51,9 @@ public:
|
||||
bool use_blender_profile;
|
||||
bool sort_by_name;
|
||||
BC_export_transformation_type export_transformation_type;
|
||||
|
||||
bool open_sim;
|
||||
bool keep_bind_info;
|
||||
|
||||
char *filepath;
|
||||
LinkNode *export_set;
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
bool fix_orientation;
|
||||
int min_chain_length;
|
||||
char *filepath;
|
||||
bool keep_bind_info;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -48,7 +48,8 @@ int collada_import(bContext *C,
|
||||
int find_chains,
|
||||
int auto_connect,
|
||||
int fix_orientation,
|
||||
int min_chain_length)
|
||||
int min_chain_length,
|
||||
int keep_bind_info)
|
||||
{
|
||||
|
||||
ImportSettings import_settings;
|
||||
@ -58,6 +59,7 @@ int collada_import(bContext *C,
|
||||
import_settings.find_chains = find_chains != 0;
|
||||
import_settings.fix_orientation = fix_orientation != 0;
|
||||
import_settings.min_chain_length = min_chain_length;
|
||||
import_settings.keep_bind_info = keep_bind_info;
|
||||
|
||||
DocumentImporter imp(C, &import_settings);
|
||||
if (imp.import()) return 1;
|
||||
@ -87,7 +89,9 @@ int collada_export(Scene *sce,
|
||||
int use_blender_profile,
|
||||
int sort_by_name,
|
||||
BC_export_transformation_type export_transformation_type,
|
||||
int open_sim)
|
||||
int open_sim,
|
||||
|
||||
int keep_bind_info)
|
||||
{
|
||||
ExportSettings export_settings;
|
||||
|
||||
@ -113,6 +117,7 @@ int collada_export(Scene *sce,
|
||||
export_settings.export_transformation_type = export_transformation_type;
|
||||
export_settings.open_sim = open_sim != 0;
|
||||
|
||||
export_settings.keep_bind_info = keep_bind_info;
|
||||
|
||||
int includeFilter = OB_REL_NONE;
|
||||
if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
|
||||
|
@ -58,7 +58,9 @@ int collada_import(struct bContext *C,
|
||||
int find_chains,
|
||||
int auto_connect,
|
||||
int fix_orientation,
|
||||
int min_chain_length);
|
||||
int min_chain_length,
|
||||
|
||||
int keep_bind_info);
|
||||
|
||||
int collada_export(struct Scene *sce,
|
||||
const char *filepath,
|
||||
@ -81,9 +83,9 @@ int collada_export(struct Scene *sce,
|
||||
int use_blender_profile,
|
||||
int sort_by_name,
|
||||
BC_export_transformation_type export_transformation_type,
|
||||
int open_sim);
|
||||
|
||||
|
||||
int open_sim,
|
||||
int keep_bind_info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -97,7 +97,9 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
int use_blender_profile;
|
||||
int sort_by_name;
|
||||
int export_transformation_type;
|
||||
|
||||
int open_sim;
|
||||
int keep_bind_info;
|
||||
|
||||
int export_count;
|
||||
|
||||
@ -148,6 +150,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
export_transformation_type = RNA_enum_get(op->ptr, "export_transformation_type_selection");
|
||||
open_sim = RNA_boolean_get(op->ptr, "open_sim");
|
||||
|
||||
keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
|
||||
|
||||
/* get editmode results */
|
||||
ED_object_editmode_load(CTX_data_edit_object(C));
|
||||
|
||||
@ -172,7 +176,10 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
use_blender_profile,
|
||||
sort_by_name,
|
||||
export_transformation_type,
|
||||
open_sim);
|
||||
|
||||
open_sim,
|
||||
keep_bind_info
|
||||
);
|
||||
|
||||
if (export_count == 0) {
|
||||
BKE_report(op->reports, RPT_WARNING, "No objects selected -- Created empty export file");
|
||||
@ -269,6 +276,8 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemR(row, imfptr, "keep_bind_info", 0, NULL, ICON_NONE);
|
||||
|
||||
}
|
||||
|
||||
@ -386,6 +395,10 @@ void WM_OT_collada_export(wmOperatorType *ot)
|
||||
|
||||
RNA_def_boolean(func, "open_sim", 0, "Export to SL/OpenSim",
|
||||
"Compatibility mode for SL, OpenSim and other compatible online worlds");
|
||||
|
||||
RNA_def_boolean(func, "keep_bind_info", 0,
|
||||
"Keep Bind Info", "Store Bindpose information in custom bone properties for later use during Collada export");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -397,7 +410,9 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
|
||||
int find_chains;
|
||||
int auto_connect;
|
||||
int fix_orientation;
|
||||
int min_chain_length;
|
||||
int min_chain_length;
|
||||
|
||||
int keep_bind_info;
|
||||
|
||||
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No filename given");
|
||||
@ -409,6 +424,9 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
|
||||
find_chains = RNA_boolean_get(op->ptr, "find_chains");
|
||||
auto_connect = RNA_boolean_get(op->ptr, "auto_connect");
|
||||
fix_orientation = RNA_boolean_get(op->ptr, "fix_orientation");
|
||||
|
||||
keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
|
||||
|
||||
min_chain_length = RNA_int_get(op->ptr, "min_chain_length");
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", filename);
|
||||
@ -418,7 +436,8 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
|
||||
find_chains,
|
||||
auto_connect,
|
||||
fix_orientation,
|
||||
min_chain_length))
|
||||
min_chain_length,
|
||||
keep_bind_info) )
|
||||
{
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -455,6 +474,13 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemR(row, imfptr, "min_chain_length", 0, NULL, ICON_NONE);
|
||||
|
||||
box = uiLayoutBox(layout);
|
||||
row = uiLayoutRow(box, false);
|
||||
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemR(row, imfptr, "keep_bind_info", 0, NULL, ICON_NONE);
|
||||
|
||||
}
|
||||
|
||||
static void wm_collada_import_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
@ -510,5 +536,9 @@ void WM_OT_collada_import(wmOperatorType *ot)
|
||||
0,
|
||||
INT_MAX);
|
||||
|
||||
RNA_def_boolean(ot->srna,
|
||||
"keep_bind_info", 0, "Keep Bind Info",
|
||||
"Store Bindpose information in custom bone properties for later use during Collada export");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -284,32 +284,34 @@ static void rna_Scene_collada_export(
|
||||
int use_blender_profile,
|
||||
int sort_by_name,
|
||||
int export_transformation_type,
|
||||
int open_sim)
|
||||
int open_sim,
|
||||
int keep_bind_info)
|
||||
{
|
||||
collada_export(scene,
|
||||
filepath,
|
||||
collada_export(scene,
|
||||
filepath,
|
||||
|
||||
apply_modifiers,
|
||||
export_mesh_type,
|
||||
apply_modifiers,
|
||||
export_mesh_type,
|
||||
|
||||
selected,
|
||||
include_children,
|
||||
include_armatures,
|
||||
include_shapekeys,
|
||||
deform_bones_only,
|
||||
selected,
|
||||
include_children,
|
||||
include_armatures,
|
||||
include_shapekeys,
|
||||
deform_bones_only,
|
||||
|
||||
active_uv_only,
|
||||
include_uv_textures,
|
||||
include_material_textures,
|
||||
use_texture_copies,
|
||||
active_uv_only,
|
||||
include_uv_textures,
|
||||
include_material_textures,
|
||||
use_texture_copies,
|
||||
|
||||
triangulate,
|
||||
use_object_instantiation,
|
||||
use_blender_profile,
|
||||
sort_by_name,
|
||||
triangulate,
|
||||
use_object_instantiation,
|
||||
use_blender_profile,
|
||||
sort_by_name,
|
||||
|
||||
export_transformation_type,
|
||||
open_sim);
|
||||
export_transformation_type,
|
||||
open_sim,
|
||||
keep_bind_info);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -396,7 +398,6 @@ void RNA_api_scene(StructRNA *srna)
|
||||
RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only",
|
||||
"Only export deforming bones with armatures");
|
||||
|
||||
|
||||
RNA_def_boolean(func, "active_uv_only", 0, "Only Selected UV Map",
|
||||
"Export only the selected UV Map");
|
||||
|
||||
@ -409,7 +410,6 @@ void RNA_api_scene(StructRNA *srna)
|
||||
RNA_def_boolean(func, "use_texture_copies", 1, "Copy",
|
||||
"Copy textures to same folder where the .dae file is exported");
|
||||
|
||||
|
||||
RNA_def_boolean(func, "triangulate", 1, "Triangulate",
|
||||
"Export Polygons (Quads & NGons) as Triangles");
|
||||
|
||||
@ -427,6 +427,10 @@ void RNA_api_scene(StructRNA *srna)
|
||||
|
||||
RNA_def_boolean(func, "open_sim", 0, "Export to SL/OpenSim",
|
||||
"Compatibility mode for SL, OpenSim and other compatible online worlds");
|
||||
|
||||
RNA_def_boolean(func, "keep_bind_info", 0,
|
||||
"Keep Bind Info", "Store Bindpose information in custom bone properties for later use during Collada export");
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WITH_ALEMBIC
|
||||
|
Loading…
Reference in New Issue
Block a user