Commit: bdbf89728f4c6a6c02814def54bc2b6060b9a7e6
Author: Kévin Dietrich
Date:   Wed Apr 6 16:38:39 2016 +0200
Branches: alembic_basic_io
https://developer.blender.org/rBbdbf89728f4c6a6c02814def54bc2b6060b9a7e6

Replace hard coded axis conversion with UI parrameters.

===================================================================

M       source/blender/alembic/ABC_alembic.h
M       source/blender/alembic/intern/abc_export_options.h
M       source/blender/alembic/intern/abc_hair.cc
M       source/blender/alembic/intern/abc_mesh.cc
M       source/blender/alembic/intern/abc_nurbs.cc
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 02b2880..30b8686 100644
--- a/source/blender/alembic/ABC_alembic.h
+++ b/source/blender/alembic/ABC_alembic.h
@@ -40,19 +40,19 @@ struct Scene;
 #define BL_ABC_UNKNOWN_ERROR 1
 
 int ABC_export(struct Scene *sce, const char *filename,
-                               double start, double end,
-                               double xformstep, double geomstep,
-                               double shutter_open, double shutter_close,
-                               int selected_only,
-                               int uvs, int normals,
-                               int vcolors,
-                               int force_meshes,
-                               int flatten_hierarchy,
-                               int custom_props_as_geodata,
-                               int vislayers, int renderable,
-                               int facesets, int matindices,
-                               int geogroups, bool ogawa,
-                               bool packuv);
+               double start, double end,
+               double xformstep, double geomstep,
+               double shutter_open, double shutter_close,
+               int selected_only,
+               int uvs, int normals,
+               int vcolors,
+               int force_meshes,
+               int flatten_hierarchy,
+               int custom_props_as_geodata,
+               int vislayers, int renderable,
+               int facesets, int matindices,
+               int geogroups, bool ogawa,
+               bool packuv, int to_forward, int to_up);
 
 void ABC_import(struct bContext *C, const char *filename, int from_forward, 
int from_up);
 
diff --git a/source/blender/alembic/intern/abc_export_options.h 
b/source/blender/alembic/intern/abc_export_options.h
index c1bcbd6..31409ac 100644
--- a/source/blender/alembic/intern/abc_export_options.h
+++ b/source/blender/alembic/intern/abc_export_options.h
@@ -60,6 +60,9 @@ struct AbcExportOptions {
        bool export_ogawa;
        bool pack_uv;
 
+       bool do_convert_axis;
+       float convert_matrix[3][3];
+
 private:
        Scene *m_scene;
 };
diff --git a/source/blender/alembic/intern/abc_hair.cc 
b/source/blender/alembic/intern/abc_hair.cc
index c03685b..0c40405 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -163,17 +163,19 @@ void AbcHairWriter::do_write()
 
                        int steps = path->segments + 1;
                        hvertices.push_back(steps);
-                       for (k=0; k < steps; k++) {
+
+                       for (k = 0; k < steps; ++k) {
                                float vert[3];
                                copy_v3_v3(vert, path->co);
                                mul_m4_v3(inv_mat, vert);
-                               if (m_rotate_matrix) {
-                                       
verts.push_back(Alembic::AbcGeom::V3f(vert[0], vert[2], -vert[1]));
-                               }
-                               else {
-                                       
verts.push_back(Alembic::AbcGeom::V3f(vert[0], vert[1], vert[2]));
+
+                               if (m_options.do_convert_axis) {
+                                       mul_m3_v3(m_options.convert_matrix, 
vert);
                                }
-                               path++;
+
+                               verts.push_back(Alembic::AbcGeom::V3f(vert[0], 
vert[1], vert[2]));
+
+                               ++path;
                        }
                }
 
diff --git a/source/blender/alembic/intern/abc_mesh.cc 
b/source/blender/alembic/intern/abc_mesh.cc
index 4cf67f6..12e039a 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -403,11 +403,12 @@ void AbcMeshWriter::getPoints(DerivedMesh *dm, 
std::vector<float> &points)
 
        MVert *verts = dm->getVertArray(dm);
 
-       if (m_rotate_matrix) {
+       if (m_options.do_convert_axis) {
+               float vert[3];
+
                for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) {
-                       points.push_back(verts[i].co[0]);
-                       points.push_back(verts[i].co[2]);
-                       points.push_back(-verts[i].co[1]);
+                       copy_v3_v3(vert, verts[i].co);
+                       mul_m3_v3(m_options.convert_matrix, vert);
                }
        }
        else {
@@ -837,11 +838,16 @@ void AbcMeshWriter::getVelocities(DerivedMesh *dm,
        if (fss->meshVelocities) {
                float *meshVels = reinterpret_cast<float 
*>(fss->meshVelocities);
 
-               if (m_rotate_matrix) {
+               if (m_options.do_convert_axis) {
+                       float vel[3];
+
                        for (int i = 0; i < totverts; ++i) {
-                               vels.push_back(meshVels[0]);
-                               vels.push_back(meshVels[2]);
-                               vels.push_back(-meshVels[1]);
+                               copy_v3_v3(vel, meshVels);
+                               mul_m3_v3(m_options.convert_matrix, vel);
+
+                               vels.push_back(vels[0]);
+                               vels.push_back(vels[1]);
+                               vels.push_back(vels[2]);
                                meshVels += 3;
                        }
                }
diff --git a/source/blender/alembic/intern/abc_nurbs.cc 
b/source/blender/alembic/intern/abc_nurbs.cc
index 4bb1310..5639888 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -32,6 +32,7 @@ extern "C" {
 #include "DNA_object_types.h"
 
 #include "BLI_listbase.h"
+#include "BLI_math.h"
 #include "BLI_string.h"
 
 #include "BKE_curve.h"
@@ -82,9 +83,12 @@ bool AbcNurbsWriter::isAnimated() const
        return (cu->key != NULL);
 }
 
-static
-void recompute_pnts_cyclic(const BPoint *bps, const int num_u, const int 
num_v, const int add_u, const int add_v,
-                                                  
std::vector<Alembic::Abc::V3f>& pos, std::vector<float>& posWeight, bool rotate)
+static void recompute_pnts_cyclic(const BPoint *bps,
+                                  const int num_u, const int num_v,
+                                  const int add_u, const int add_v,
+                                  std::vector<Alembic::Abc::V3f> &pos,
+                                  std::vector<float> &posWeight,
+                                  bool rotate, float rot_mat[3][3])
 {
        const int new_u = num_u;// + add_u;
        const int new_v = num_v;// + add_v;
@@ -98,19 +102,28 @@ void recompute_pnts_cyclic(const BPoint *bps, const int 
num_u, const int num_v,
        for (int u = 0; u < new_u; ++u) {
                pnts[u].resize(new_v);
 
-               for (int v = 0; v < new_v; ++v) {
-                       const BPoint& bp = bps[u + (v * new_u)];
-                       pnts[u][v] = Imath::Vec4<float>(bp.vec[0], bp.vec[1], 
bp.vec[2], bp.vec[3]);
+               if (rotate) {
+                       for (int v = 0; v < new_v; ++v) {
+                               const BPoint& bp = bps[u + (v * new_u)];
+                               float vert[3];
+                               copy_v3_v3(vert, bp.vec);
+                               mul_m3_v3(rot_mat, vert);
+
+                               pnts[u][v] = Imath::Vec4<float>(vert[0], 
vert[1], vert[2], bp.vec[3]);
+                       }
+               }
+               else {
+                       for (int v = 0; v < new_v; ++v) {
+                               const BPoint& bp = bps[u + (v * new_u)];
+                               pnts[u][v] = Imath::Vec4<float>(bp.vec[0], 
bp.vec[1], bp.vec[2], bp.vec[3]);
+                       }
                }
        }
 
        for (int u = 0; u < new_u; ++u) {
                for (int v = 0; v < new_v; ++v) {
                        Imath::Vec4<float>& pnt = pnts[u][v];
-                       if (!rotate)
-                               pos.push_back(Alembic::Abc::V3f(pnt.x, pnt.y, 
pnt.z));
-                       else
-                               pos.push_back(Alembic::Abc::V3f(pnt.x, pnt.z, 
-pnt.y));
+                       pos.push_back(Alembic::Abc::V3f(pnt.x, pnt.y, pnt.z));
                        posWeight.push_back(pnt.z);
                }
        }
@@ -163,7 +176,9 @@ void AbcNurbsWriter::do_write()
 
                std::vector<Alembic::Abc::V3f> sampPos;
                std::vector<float> sampPosWeights;
-               recompute_pnts_cyclic(nu->bp, nu->pntsu, nu->pntsv, add_u, 
add_v, sampPos, sampPosWeights, m_rotate_matrix);
+               recompute_pnts_cyclic(nu->bp, nu->pntsu, nu->pntsv, add_u, 
add_v,
+                                     sampPos, sampPosWeights,
+                                     m_options.do_convert_axis, 
m_options.convert_matrix);
 
                nuSamp.setPositions(sampPos);
                nuSamp.setPositionWeights(sampPosWeights);
diff --git a/source/blender/alembic/intern/abc_transform.cc 
b/source/blender/alembic/intern/abc_transform.cc
index 86c407e..7d0cac4 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -51,212 +51,9 @@ AbcTransformWriter::AbcTransformWriter(Object *obj, 
Abc::OObject abcParent, AbcT
                writerParent->addChild(this);
 }
 
-// recompute transform matrix of object in new coordinate system (from Z-Up to 
Y-Up)
-static void createTransformMatrix(float transform_mat[4][4], Object *obj)
-{
-    float rot_mat[3][3], rot[3][3], scale_mat[4][4], invmat[4][4], mat[4][4];
-    float rot_x_mat[3][3], rot_y_mat[3][3], rot_z_mat[3][3];
-    float loc[3], scale[3], euler[3];
-
-    zero_v3(loc);
-    zero_v3(scale);
-    zero_v3(euler);
-    unit_m3(rot);
-    unit_m3(rot_mat);
-    unit_m4(scale_mat);
-    unit_m4(transform_mat);
-    unit_m4(invmat);
-    unit_m4(mat);
-
-    // get local matrix
-    if (obj->parent) {
-        invert_m4_m4(invmat, obj->parent->obmat);
-        mul_m4_m4m4(mat, invmat, obj->obmat);
-    }
-    else {
-        copy_m4_m4(mat, obj->obmat);
-    }
-
-    // compute rotation matrix
-    switch(obj->rotmode) {
-        case ROT_MODE_AXISANGLE:
-        {
-            // get euler angles from axis angle rotation
-            axis_angle_to_eulO(euler, ROT_MODE_XYZ, obj->rotAxis, 
obj->rotAngle);
-
-            // create X, Y, Z rotation matrices from euler angles
-            rotate_m3_zup_yup(rot_x_mat, rot_y_mat, rot_z_mat, euler);
-
-            // concatenate rotation matrices
-            mul_m3_m3m3(rot_mat, rot_mat, rot_y_mat);
-            mul_m3_m3m3(rot_mat, rot_mat, rot_z_mat);
-            mul_m3_m3m3(rot_mat, rot_mat, rot_x_mat);
-
-            // extract location and scale from matrix
-            mat4_to_loc_rot_size(loc, rot, scale, mat);
-
-            break;
-        }
-
-        case ROT_MODE_QUAT:
-        {
-            float q[4];
-            copy_v4_v4(q, obj->quat);
-
-            // swap axis
-            q[2] = obj->quat[3];
-            q[3] = -obj->quat[2];
-
-            // compute rotation matrix from quaternion
-            quat_to_mat3(rot_mat, q);
-
-            // extract location and scale from matrix
-            mat4_to_loc_rot_size(loc, rot, scale, mat);
-
-            break;
-        }
-
-        case ROT_MODE_XYZ:
-        {
-            // extract location, rotation, and scale form matrix
-            mat4_to_loc_rot_size(loc, rot, scale, mat);
-
-            // get euler angles from rotation matrix
-            mat3_to_eulO(euler, ROT_MODE_XYZ, rot);
-
-            // create X, Y, Z rotation matrices from euler angles
-            rotate_m3_zup_yup(rot_x_mat, rot_y_mat, rot_z_mat, euler);
-
-            // concatenate rotation matrices
-            mul_m3_m3m3(rot_mat, rot_mat, rot_y_mat);
-            mul_m3_m3m3(rot_mat, rot_mat, rot_z_mat);
-            mul_m3_m3m3(rot_mat, rot_mat, rot_x_mat);
-
-            break;
-        }
-
-        case ROT_MODE_XZY:
-        {
-            // extract location, rotation, and scale form matrix
-            mat4_to_loc_rot_size(loc, rot, scale, mat);
-
-            // get euler angles from rotation matrix
-            mat3_to_eulO(euler, ROT_MODE_XZY, rot);
-
-            // create X, Y, Z rotation matrices from euler angles
-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to