From e8edda1ccf9e0a4650d12f3f444a509309d2eca7 Mon Sep 17 00:00:00 2001 From: lzwdgc Date: Sun, 1 Mar 2020 22:22:26 +0300 Subject: [PATCH] Allow to rotate data for .obj files. Add eWindows3DViewer axis system. --- src/mod_converter/mod_converter.cpp | 14 +++++++++++++- src/model/model.cpp | 10 +++++----- src/model/model.h | 3 +++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/mod_converter/mod_converter.cpp b/src/mod_converter/mod_converter.cpp index 99be997..e31c206 100644 --- a/src/mod_converter/mod_converter.cpp +++ b/src/mod_converter/mod_converter.cpp @@ -52,13 +52,25 @@ cl::opt AS(cl::desc("Choose axis system (.fbx only):"), cl::values( #define axisval(x, y) \ cl::OptionEnumValue{ #x, (int)AxisSystem::x, y } +#define axisalias(x, a) \ + cl::OptionEnumValue{ #x, (int)AxisSystem::a, "Same as " #a } axisval(eMayaZUp, "UpVector = ZAxis, FrontVector = -ParityOdd, CoordSystem = RightHanded ( also 3dsMax, Blender)\n" "(Blender: when importing, disable 'Use Pre/Post Rotation')"), + axisalias(eMax, eMayaZUp), + axisalias(eBlender, eMayaZUp), + axisval(eMayaYUp, "UpVector = YAxis, FrontVector = ParityOdd, CoordSystem = RightHanded (default, also MotionBuilder, OpenGL)"), - axisval(eDirectX, "UpVector = YAxis, FrontVector = ParityOdd, CoordSystem = LeftHanded ( also Lightwave)") + axisalias(eMotionbuilder, eMayaYUp), + axisalias(eOpenGL, eMayaYUp), + + axisval(eDirectX, "UpVector = YAxis, FrontVector = ParityOdd, CoordSystem = LeftHanded ( also Lightwave)"), + axisalias(eLightwave, eDirectX), + + axisval(eWindows3DViewer, "UpVector = ZAxis, FrontVector = ParityOdd, CoordSystem = RightHanded ( also Lightwave)") #undef axisval +#undef axisalias ) , cl::init(AxisSystem::Default) ); diff --git a/src/model/model.cpp b/src/model/model.cpp index c2c4c52..95367f8 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -99,6 +99,8 @@ static void load_translated(aim_vector3 &v, const buffer &b) READ(b, v.x); READ(b, v.z); v.y = -v.y; + + // after load we have eMayaYUp } void aim_vector4::load(const buffer &b, uint32_t flags) @@ -149,21 +151,19 @@ static String print_float(double v) return buf; }; -// input (AIM Coordinates) are in eMayaYUp template static aim_vector3 rotate(const aim_vector3 &in, AxisSystem rot_type) { - // it is not so simple - // we can change coords, but normals and other stuff require recalculation? - return in; + // input (AIM Coordinates) are in eMayaYUp aim_vector3 v = in; switch (rot_type) { case AxisSystem::eMayaZUp: + v.y = -v.y; + case AxisSystem::eWindows3DViewer: v.y = in.z; v.z = in.y; - v.y = -v.y; break; case AxisSystem::eDirectX: v.x = -v.x; diff --git a/src/model/model.h b/src/model/model.h index de4a203..14c1395 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -96,6 +96,9 @@ enum class AxisSystem eDirectX, eLightwave = eDirectX, + // UpVector = ZAxis, FrontVector = ParityOdd, CoordSystem = RightHanded + eWindows3DViewer, + // special Default = 0, };