Changeset View
Changeset View
Standalone View
Standalone View
source/blender/alembic/intern/abc_transform.cc
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| AbcTransformWriter::AbcTransformWriter(Object *ob, | AbcTransformWriter::AbcTransformWriter(Object *ob, | ||||
| const OObject &abc_parent, | const OObject &abc_parent, | ||||
| AbcTransformWriter *parent, | AbcTransformWriter *parent, | ||||
| unsigned int time_sampling, | unsigned int time_sampling, | ||||
| ExportSettings &settings) | ExportSettings &settings) | ||||
| : AbcObjectWriter(NULL, ob, time_sampling, settings, parent) | : AbcObjectWriter(NULL, ob, time_sampling, settings, parent) | ||||
| { | { | ||||
| m_is_animated = hasAnimation(m_object); | m_is_animated = hasAnimation(m_object); | ||||
| m_parent = NULL; | |||||
| if (!m_is_animated) { | if (!m_is_animated) { | ||||
| time_sampling = 0; | time_sampling = 0; | ||||
| } | } | ||||
| m_xform = OXform(abc_parent, get_id_name(m_object), time_sampling); | m_xform = OXform(abc_parent, get_id_name(m_object), time_sampling); | ||||
| m_schema = m_xform.getSchema(); | m_schema = m_xform.getSchema(); | ||||
| } | } | ||||
| void AbcTransformWriter::do_write() | void AbcTransformWriter::do_write() | ||||
| { | { | ||||
| if (m_first_frame) { | if (m_first_frame) { | ||||
| m_visibility = Alembic::AbcGeom::CreateVisibilityProperty(m_xform, m_xform.getSchema().getTimeSampling()); | m_visibility = Alembic::AbcGeom::CreateVisibilityProperty(m_xform, m_xform.getSchema().getTimeSampling()); | ||||
| } | } | ||||
| m_visibility.set(!(m_object->restrictflag & OB_RESTRICT_VIEW)); | m_visibility.set(!(m_object->restrictflag & OB_RESTRICT_VIEW)); | ||||
| if (!m_first_frame && !m_is_animated) { | if (!m_first_frame && !m_is_animated) { | ||||
| return; | return; | ||||
| } | } | ||||
| float mat[4][4]; | float yup_mat[4][4]; | ||||
| create_transform_matrix(m_object, mat); | create_transform_matrix(m_object, yup_mat); | ||||
| /* Only apply rotation to root camera, parenting will propagate it. */ | /* Only apply rotation to root camera, parenting will propagate it. */ | ||||
| if (m_object->type == OB_CAMERA && !has_parent_camera(m_object)) { | if (m_object->type == OB_CAMERA && !has_parent_camera(m_object)) { | ||||
| float rot_mat[4][4]; | float rot_mat[4][4]; | ||||
| axis_angle_to_mat4_single(rot_mat, 'X', -M_PI_2); | axis_angle_to_mat4_single(rot_mat, 'X', -M_PI_2); | ||||
| mul_m4_m4m4(mat, mat, rot_mat); | mul_m4_m4m4(yup_mat, yup_mat, rot_mat); | ||||
| } | } | ||||
| if (!m_object->parent) { | if (!m_object->parent) { | ||||
| /* Only apply scaling to root objects, parenting will propagate it. */ | /* Only apply scaling to root objects, parenting will propagate it. */ | ||||
| /* TODO Sybren: when we're exporting as "flat", i.e. non-hierarchial, | |||||
| * we should apply the scale even when the object has a parent | |||||
| * Blender Object. */ | |||||
| float scale_mat[4][4]; | float scale_mat[4][4]; | ||||
| scale_m4_fl(scale_mat, m_settings.global_scale); | scale_m4_fl(scale_mat, m_settings.global_scale); | ||||
| mul_m4_m4m4(mat, mat, scale_mat); | scale_mat[3][3] = m_settings.global_scale; /* also scale translation */ | ||||
| mul_v3_fl(mat[3], m_settings.global_scale); | mul_m4_m4m4(yup_mat, yup_mat, scale_mat); | ||||
| } | } | ||||
| m_matrix = convert_matrix(mat); | m_matrix = convert_matrix(yup_mat); | ||||
| m_sample.setMatrix(m_matrix); | m_sample.setMatrix(m_matrix); | ||||
| m_schema.set(m_sample); | m_schema.set(m_sample); | ||||
| } | } | ||||
| Imath::Box3d AbcTransformWriter::bounds() | Imath::Box3d AbcTransformWriter::bounds() | ||||
| { | { | ||||
| Imath::Box3d bounds; | Imath::Box3d bounds; | ||||
| Show All 11 Lines | bool AbcTransformWriter::hasAnimation(Object * /*ob*/) const | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* ************************************************************************** */ | /* ************************************************************************** */ | ||||
| AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettings &settings) | AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettings &settings) | ||||
| : AbcObjectReader(object, settings) | : AbcObjectReader(object, settings) | ||||
| { | { | ||||
| /* Empties have no data. It makes the import of Alembic files easier to | |||||
| * understand when we name the empty after its name in Alembic. */ | |||||
| m_object_name = object.getName(); | |||||
| Alembic::AbcGeom::IXform xform(object, Alembic::AbcGeom::kWrapExisting); | Alembic::AbcGeom::IXform xform(object, Alembic::AbcGeom::kWrapExisting); | ||||
| m_schema = xform.getSchema(); | m_schema = xform.getSchema(); | ||||
| get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); | get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); | ||||
| } | } | ||||
| bool AbcEmptyReader::valid() const | bool AbcEmptyReader::valid() const | ||||
| { | { | ||||
| return m_schema.valid(); | return m_schema.valid(); | ||||
| } | } | ||||
| void AbcEmptyReader::readObjectData(Main *bmain, float /*time*/) | void AbcEmptyReader::readObjectData(Main *bmain, float /*time*/) | ||||
| { | { | ||||
| m_object = BKE_object_add_only_object(bmain, OB_EMPTY, m_data_name.c_str()); | m_object = BKE_object_add_only_object(bmain, OB_EMPTY, | ||||
| m_object_name.c_str()); | |||||
dfelinto: use m_object_name instead | |||||
| m_object->data = NULL; | m_object->data = NULL; | ||||
| } | } | ||||
use m_object_name instead