mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Fix transformation
The transformation from UM to savitar in the 3MFWriter does not invert the transformation in the 3MFReader. This usually doesn't cause any problems as the center mesh extension is zero and the resulting matrix the identity. However if the extent is not zero the final transformation is incorrect.
This commit is contained in:
parent
9351096803
commit
be4d4d404f
1 changed files with 9 additions and 7 deletions
|
@ -114,22 +114,24 @@ class ThreeMFWriter(MeshWriter):
|
||||||
|
|
||||||
mesh_data = um_node.getMeshData()
|
mesh_data = um_node.getMeshData()
|
||||||
|
|
||||||
|
node_matrix = um_node.getLocalTransformation()
|
||||||
|
node_matrix.preMultiply(transformation)
|
||||||
|
|
||||||
if center_mesh:
|
if center_mesh:
|
||||||
node_matrix = Matrix()
|
center_matrix = Matrix()
|
||||||
# compensate for original center position, if object(s) is/are not around its zero position
|
# compensate for original center position, if object(s) is/are not around its zero position
|
||||||
if mesh_data is not None:
|
if mesh_data is not None:
|
||||||
extents = mesh_data.getExtents()
|
extents = mesh_data.getExtents()
|
||||||
if extents is not None:
|
if extents is not None:
|
||||||
# We use a different coordinate space while writing, so flip Z and Y
|
# We use a different coordinate space while writing, so flip Z and Y
|
||||||
center_vector = Vector(extents.center.x, extents.center.y, extents.center.z)
|
center_vector = Vector(-extents.center.x, -extents.center.y, -extents.center.z)
|
||||||
node_matrix.setByTranslation(center_vector)
|
center_matrix.setByTranslation(center_vector)
|
||||||
node_matrix.multiply(um_node.getLocalTransformation())
|
node_matrix.preMultiply(center_matrix)
|
||||||
else:
|
|
||||||
node_matrix = um_node.getLocalTransformation()
|
|
||||||
|
|
||||||
matrix_string = ThreeMFWriter._convertMatrixToString(node_matrix.preMultiply(transformation))
|
matrix_string = ThreeMFWriter._convertMatrixToString(node_matrix)
|
||||||
|
|
||||||
savitar_node.setTransformation(matrix_string)
|
savitar_node.setTransformation(matrix_string)
|
||||||
|
|
||||||
if mesh_data is not None:
|
if mesh_data is not None:
|
||||||
savitar_node.getMeshData().setVerticesFromBytes(mesh_data.getVerticesAsByteArray())
|
savitar_node.getMeshData().setVerticesFromBytes(mesh_data.getVerticesAsByteArray())
|
||||||
indices_array = mesh_data.getIndicesAsByteArray()
|
indices_array = mesh_data.getIndicesAsByteArray()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue