diff options
Diffstat (limited to 'source/blender/collada/collada_internal.cpp')
-rw-r--r-- | source/blender/collada/collada_internal.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 67ee4818f7e..6f401c1856f 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -28,12 +28,38 @@ UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {} void UnitConverter::read_asset(const COLLADAFW::FileInfo* asset) { + unit = asset->getUnit(); + up_axis = asset->getUpAxisType(); } -// TODO -// convert vector vec from COLLADA format to Blender -void UnitConverter::convertVec3(float *vec) +UnitConverter::UnitSystem UnitConverter::isMetricSystem() { + switch(unit.getLinearUnitUnit()) { + case COLLADAFW::FileInfo::Unit::MILLIMETER: + case COLLADAFW::FileInfo::Unit::CENTIMETER: + case COLLADAFW::FileInfo::Unit::DECIMETER: + case COLLADAFW::FileInfo::Unit::METER: + case COLLADAFW::FileInfo::Unit::KILOMETER: + return UnitConverter::Metric; + case COLLADAFW::FileInfo::Unit::INCH: + case COLLADAFW::FileInfo::Unit::FOOT: + case COLLADAFW::FileInfo::Unit::YARD: + return UnitConverter::Imperial; + default: + return UnitConverter::None; + } +} + +float UnitConverter::getLinearMeter() +{ + return (float)unit.getLinearUnitMeter(); +} + +void UnitConverter::convertVector3(COLLADABU::Math::Vector3 &vec, float *v) +{ + v[0] = vec.x; + v[1] = vec.y; + v[2] = vec.z; } // TODO need also for angle conversion, time conversion... |