mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
3mf files are now placed in their own worldspace
CURA-382
This commit is contained in:
parent
28eb4297c6
commit
e1ebd3e225
@ -54,10 +54,6 @@ class ThreeMFReader(MeshReader):
|
|||||||
vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")])
|
vertex_list.append([vertex.get("x"), vertex.get("y"), vertex.get("z")])
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
# If this object has no vertices and just one child, just return the child.
|
|
||||||
if len(vertex_list) == 0 and len(node.getChildren()) == 1:
|
|
||||||
return node.getChildren()[0]
|
|
||||||
|
|
||||||
if len(node.getChildren()) > 0:
|
if len(node.getChildren()) > 0:
|
||||||
group_decorator = GroupDecorator()
|
group_decorator = GroupDecorator()
|
||||||
node.addDecorator(group_decorator)
|
node.addDecorator(group_decorator)
|
||||||
@ -76,20 +72,10 @@ class ThreeMFReader(MeshReader):
|
|||||||
|
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
# Rotate the model; We use a different coordinate frame.
|
|
||||||
rotation = Matrix()
|
|
||||||
rotation.setByRotationAxis(-0.5 * math.pi, Vector(1, 0, 0))
|
|
||||||
flip_matrix = Matrix()
|
|
||||||
|
|
||||||
flip_matrix._data[1, 1] = 0
|
|
||||||
flip_matrix._data[1, 2] = 1
|
|
||||||
flip_matrix._data[2, 1] = 1
|
|
||||||
flip_matrix._data[2, 2] = 0
|
|
||||||
|
|
||||||
# TODO: We currently do not check for normals and simply recalculate them.
|
# TODO: We currently do not check for normals and simply recalculate them.
|
||||||
mesh_builder.calculateNormals()
|
mesh_builder.calculateNormals()
|
||||||
mesh_builder.setFileName(name)
|
mesh_builder.setFileName(name)
|
||||||
mesh_data = mesh_builder.build().getTransformed(flip_matrix)
|
mesh_data = mesh_builder.build()
|
||||||
|
|
||||||
if len(mesh_data.getVertices()):
|
if len(mesh_data.getVertices()):
|
||||||
node.setMeshData(mesh_data)
|
node.setMeshData(mesh_data)
|
||||||
@ -122,13 +108,6 @@ class ThreeMFReader(MeshReader):
|
|||||||
temp_mat._data[1, 3] = splitted_transformation[10]
|
temp_mat._data[1, 3] = splitted_transformation[10]
|
||||||
temp_mat._data[2, 3] = splitted_transformation[11]
|
temp_mat._data[2, 3] = splitted_transformation[11]
|
||||||
|
|
||||||
flip_matrix = Matrix()
|
|
||||||
flip_matrix._data[1, 1] = 0
|
|
||||||
flip_matrix._data[1, 2] = 1
|
|
||||||
flip_matrix._data[2, 1] = 1
|
|
||||||
flip_matrix._data[2, 2] = 0
|
|
||||||
temp_mat.multiply(flip_matrix)
|
|
||||||
|
|
||||||
return temp_mat
|
return temp_mat
|
||||||
|
|
||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
@ -158,9 +137,14 @@ class ThreeMFReader(MeshReader):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
|
flip_matrix = Matrix()
|
||||||
|
flip_matrix._data[1, 1] = 0
|
||||||
|
flip_matrix._data[1, 2] = 1
|
||||||
|
flip_matrix._data[2, 1] = 1
|
||||||
|
flip_matrix._data[2, 2] = 0
|
||||||
|
result.setTransformation(flip_matrix)
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
translation = Vector(x=-global_container_stack.getProperty("machine_width", "value") / 2, y=0,
|
translation = Vector(x=-global_container_stack.getProperty("machine_width", "value") / 2, z=0,
|
||||||
z=global_container_stack.getProperty("machine_depth", "value") / 2)
|
y=global_container_stack.getProperty("machine_depth", "value") / 2)
|
||||||
result.translate(translation, SceneNode.TransformSpace.World)
|
result.translate(translation)
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user