[Bf-blender-cvs] [fa1559e] alembic_basic_io: Add a scale parameter to the importer and exporter.
Kévin Dietrich
noreply at git.blender.org
Fri Apr 29 18:44:44 CEST 2016
Commit: fa1559e3c42f2a6b498aff8130dcd50905818051
Author: Kévin Dietrich
Date: Fri Apr 29 18:17:32 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBfa1559e3c42f2a6b498aff8130dcd50905818051
Add a scale parameter to the importer and exporter.
===================================================================
M source/blender/alembic/ABC_alembic.h
M source/blender/alembic/intern/abc_export_options.cc
M source/blender/alembic/intern/abc_export_options.h
M source/blender/alembic/intern/abc_object.cc
M source/blender/alembic/intern/abc_object.h
M source/blender/alembic/intern/abc_transform.cc
M source/blender/alembic/intern/alembic_capi.cc
M source/blender/editors/io/io_alembic.c
M source/blender/makesrna/intern/rna_scene_api.c
===================================================================
diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h
index edef0d2..65c2296 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -46,9 +46,9 @@ int ABC_export(struct Scene *sce, const char *filename,
int vislayers, int renderable,
int facesets, int matindices,
int geogroups, bool ogawa,
- bool packuv, int to_forward, int to_up);
+ bool packuv, int to_forward, int to_up, float scale);
-void ABC_import(struct bContext *C, const char *filename, int from_forward, int from_up);
+void ABC_import(struct bContext *C, const char *filename, int from_forward, int from_up, float scale);
void ABC_get_vertex_cache(const char *filepath, float time, void *verts, int max_verts, const char *sub_obj, int is_mvert);
diff --git a/source/blender/alembic/intern/abc_export_options.cc b/source/blender/alembic/intern/abc_export_options.cc
index e8d6d38..4375908 100644
--- a/source/blender/alembic/intern/abc_export_options.cc
+++ b/source/blender/alembic/intern/abc_export_options.cc
@@ -46,6 +46,7 @@ AbcExportOptions::AbcExportOptions(Scene *scene)
shape_frame_step = 1;
shutter_open = 0.0;
shutter_close = 1.0;
+ global_scale = 1.0f;
flatten_hierarchy = false;
diff --git a/source/blender/alembic/intern/abc_export_options.h b/source/blender/alembic/intern/abc_export_options.h
index 31409ac..1bccd64 100644
--- a/source/blender/alembic/intern/abc_export_options.h
+++ b/source/blender/alembic/intern/abc_export_options.h
@@ -43,6 +43,7 @@ struct AbcExportOptions {
double shape_frame_step;
double shutter_open;
double shutter_close;
+ float global_scale;
bool flatten_hierarchy;
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index 0de6873..078d9fb 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -337,7 +337,7 @@ Object *AbcObjectReader::object() const
return m_object;
}
-void AbcObjectReader::readObjectMatrix(const float time) const
+void AbcObjectReader::readObjectMatrix(const float time, const float scale) const
{
const Alembic::AbcGeom::MetaData &md = m_iobject.getParent().getMetaData();
@@ -355,7 +355,7 @@ void AbcObjectReader::readObjectMatrix(const float time) const
for (int i = 0; i < 3; ++i) {
m_object->loc[i] = xs.getTranslation()[i];
- m_object->size[i] = xs.getScale()[i];
+ m_object->size[i] = xs.getScale()[i] * scale;
}
m_object->rot[0] = xs.getXRotation();
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 105b3e0..4e05a8e 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -98,7 +98,7 @@ public:
virtual void readObjectData(Main *bmain, Scene *scene, float time) = 0;
- void readObjectMatrix(const float time) const;
+ void readObjectMatrix(const float time, const float scale) const;
};
#endif
diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc
index 1532242..d8f503c 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -91,6 +91,10 @@ void AbcTransformWriter::do_write()
copy_m4_m4(mat, m_object->obmat);
}
+ float smat[4][4];
+ scale_m4_fl(smat, m_options.global_scale);
+ mul_m4_m4m4(mat, smat, mat);
+
if (m_options.do_convert_axis) {
mul_m4_m3m4(mat, m_options.convert_matrix, mat);
}
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 431e7c8..072f634 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -231,7 +231,7 @@ int ABC_export(Scene *sce, const char *filename,
int vislayers, int renderable,
int facesets, int matindices,
int use_subdiv_schema, bool ogawa, bool packuv,
- int to_forward, int to_up)
+ int to_forward, int to_up, float scale)
{
try {
AbcExportOptions opts(sce);
@@ -256,6 +256,7 @@ int ABC_export(Scene *sce, const char *filename,
// Deprecated
opts.export_face_sets = facesets;
opts.export_mat_indices = matindices;
+ opts.global_scale = scale;
if (opts.startframe > opts.endframe) {
std::swap(opts.startframe, opts.endframe);
@@ -366,7 +367,7 @@ static void create_hierarchy(bContext *C, AbcObjectReader *root)
}
}
-void ABC_import(bContext *C, const char *filename, int from_forward, int from_up)
+void ABC_import(bContext *C, const char *filename, int from_forward, int from_up, float scale)
{
/* get objects strings */
IArchive archive = open_archive(filename);
@@ -385,7 +386,7 @@ void ABC_import(bContext *C, const char *filename, int from_forward, int from_up
if (reader->valid()) {
reader->readObjectData(CTX_data_main(C), CTX_data_scene(C), 0.0f);
- reader->readObjectMatrix(0.0f);
+ reader->readObjectMatrix(0.0f, scale);
}
}
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index 48d429f..cbacf4f 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -103,16 +103,17 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
bool packuv = RNA_boolean_get(op->ptr, "packuv");
const int to_forward = RNA_enum_get(op->ptr, "to_forward");
const int to_up = RNA_enum_get(op->ptr, "to_up");
+ const float scale = RNA_float_get(op->ptr, "scale");
int result = ABC_export(CTX_data_scene(C), filename,
start, end,
- (double) 1.0 / xsamples,
- (double) 1.0 / gsamples,
+ 1.0 / (double)xsamples,
+ 1.0 / (double)gsamples,
sh_open, sh_close,
selected, uvs, normals, vcolors,
forcemeshes, flatten, geoprops,
vislayers, renderable, facesets, matindices,
- subdiv_schem, ogawa, packuv, to_forward, to_up);
+ subdiv_schem, ogawa, packuv, to_forward, to_up, scale);
switch (result) {
case BL_ABC_UNKNOWN_ERROR:
@@ -142,6 +143,9 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "to_up", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(box, false);
+ uiItemR(row, imfptr, "scale", 0, NULL, ICON_NONE);
+
/* Scene Options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
@@ -297,6 +301,8 @@ void WM_OT_alembic_export(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "ogawa", 0, "Export Ogawa",
"Export as Ogawa archive type");
+
+ RNA_def_float(ot->srna, "scale", 1.0f, 0.0f, 1000.0f, "Scale", "", 0.0f, 1000.0f);
}
static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr)
@@ -310,6 +316,9 @@ static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr)
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "from_up", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(box, false);
+ uiItemR(row, imfptr, "scale", 0, NULL, ICON_NONE);
}
static void wm_alembic_import_draw(bContext *UNUSED(C), wmOperator *op)
@@ -327,15 +336,14 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- Scene *scene = CTX_data_scene(C);
-
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
const int from_forward = RNA_enum_get(op->ptr, "from_forward");
const int from_up = RNA_enum_get(op->ptr, "from_up");
+ const float scale = RNA_float_get(op->ptr, "scale");
- ABC_import(C, filename, from_forward, from_up);
+ ABC_import(C, filename, from_forward, from_up, scale);
return OPERATOR_FINISHED;
}
@@ -358,6 +366,8 @@ void WM_OT_alembic_import(wmOperatorType *ot)
RNA_def_enum(ot->srna, "from_up", rna_enum_object_axis_items, OB_POSY,
"Up Axis", "Up axis of the objects in the .abc archive");
+
+ RNA_def_float(ot->srna, "scale", 1.0f, 0.0f, 1000.0f, "Scale", "", 0.0f, 1000.0f);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index e517e48..8b31c60 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -200,7 +200,8 @@ static void rna_Scene_alembic_export(
int ogawa,
int packuv,
int to_forward,
- int to_up)
+ int to_up,
+ float scale)
{
// We have to enable allow_threads, because we may change scene frame number during export
#ifdef WITH_PYTHON
@@ -212,7 +213,7 @@ static void rna_Scene_alembic_export(
selected_only, uvs, normals, vcolors,
force_meshes, flatten_hierarchy, custom_props_as_geodata,
vislayers, renderable, facesets, matindices, subdiv_schema,
- ogawa, packuv, to_forward, to_up);
+ ogawa, packuv, to_forward, to_up, scale);
#ifdef WITH_PYTHON
BPy_END_ALLOW_THREADS;
@@ -373,6 +374,7 @@ void RNA_api_scene(StructRNA *srna)
RNA_def_boolean(func, "packuv" , 0, "Export with packed UV islands", "Export with packed UV islands");
RNA_def_enum(func, "to_forward", rna_enum_object_axis_items, 0, "Forward Axis", "");
RNA_def_enum(func, "to_up", rna_enum_object_axis_items, 0, "Up Axis", "");
+ RNA_def_float(func, "scale", 1.0f, 0.0f, 1000.0f, "Scale", "", 0.0f, 1000.0f);
#endif
}
More information about the Bf-blender-cvs
mailing list