diff options
-rw-r--r-- | cura/Layer.py | 5 | ||||
-rw-r--r-- | cura/LayerData.py | 4 | ||||
-rw-r--r-- | cura/LayerDataBuilder.py | 12 | ||||
-rw-r--r-- | cura/LayerPolygon.py | 3 | ||||
-rw-r--r-- | plugins/CuraEngineBackend/ProcessSlicedLayersJob.py | 10 | ||||
-rw-r--r-- | plugins/LayerView/layers.shader | 28 |
6 files changed, 22 insertions, 40 deletions
diff --git a/cura/Layer.py b/cura/Layer.py index 9fc744e9de..3103d1772e 100644 --- a/cura/Layer.py +++ b/cura/Layer.py @@ -53,11 +53,8 @@ class Layer: result_vertex_offset = vertex_offset result_index_offset = index_offset self._element_count = 0 - thickness = self._thickness / 1000 # micrometer to millimeter for polygon in self._polygons: - polygon.build(result_vertex_offset, result_index_offset, vertices, colors, line_dimensions, indices, thickness) - #polygon_normals = polygon.getNormals() # [numpy.where(numpy.logical_not(polygon.jumpMask))] - #normals[result_vertex_offset:result_vertex_offset+polygon.lineMeshVertexCount()] = polygon_normals[:polygon.lineMeshVertexCount()] + polygon.build(result_vertex_offset, result_index_offset, vertices, colors, line_dimensions, indices) result_vertex_offset += polygon.lineMeshVertexCount() result_index_offset += polygon.lineMeshElementCount() self._element_count += polygon.elementCount diff --git a/cura/LayerData.py b/cura/LayerData.py index ad5326373e..3fe550c297 100644 --- a/cura/LayerData.py +++ b/cura/LayerData.py @@ -6,9 +6,9 @@ from UM.Mesh.MeshData import MeshData # Immutable, use LayerDataBuilder to create one of these. class LayerData(MeshData): def __init__(self, vertices = None, normals = None, indices = None, colors = None, uvs = None, file_name = None, - center_position = None, layers=None, element_counts=None): + center_position = None, layers=None, element_counts=None, attributes=None): super().__init__(vertices=vertices, normals=normals, indices=indices, colors=colors, uvs=uvs, - file_name=file_name, center_position=center_position) + file_name=file_name, center_position=center_position, attributes=attributes) self._layers = layers self._element_counts = element_counts diff --git a/cura/LayerDataBuilder.py b/cura/LayerDataBuilder.py index 7ff8a3737a..41c7790102 100644 --- a/cura/LayerDataBuilder.py +++ b/cura/LayerDataBuilder.py @@ -56,7 +56,6 @@ class LayerDataBuilder(MeshBuilder): index_count += data.lineMeshElementCount() vertices = numpy.empty((vertex_count, 3), numpy.float32) - # normals = numpy.empty((vertex_count, 3), numpy.float32) line_dimensions = numpy.empty((vertex_count, 2), numpy.float32) colors = numpy.empty((vertex_count, 4), numpy.float32) indices = numpy.empty((index_count, 2), numpy.int32) @@ -70,10 +69,15 @@ class LayerDataBuilder(MeshBuilder): self.addVertices(vertices) self.addColors(colors) self.addIndices(indices.flatten()) - self._uvs = line_dimensions - #self._normals = normals + # self._uvs = line_dimensions + attributes = { + "line_dimensions": { + "value": line_dimensions, + "opengl_name": "a_line_dim", + "opengl_type": "vector2f"} + } return LayerData(vertices=self.getVertices(), normals=self.getNormals(), indices=self.getIndices(), colors=self.getColors(), uvs=self.getUVCoordinates(), file_name=self.getFileName(), center_position=self.getCenterPosition(), layers=self._layers, - element_counts=self._element_counts) + element_counts=self._element_counts, attributes=attributes) diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py index 858fa11c77..439146e6e2 100644 --- a/cura/LayerPolygon.py +++ b/cura/LayerPolygon.py @@ -67,7 +67,7 @@ class LayerPolygon: ## build # line_thicknesses: array with type as index and thickness as value - def build(self, vertex_offset, index_offset, vertices, colors, line_dimensions, indices, thickness): + def build(self, vertex_offset, index_offset, vertices, colors, line_dimensions, indices): if (self._build_cache_line_mesh_mask is None) or (self._build_cache_needed_points is None ): self.buildCache() @@ -85,6 +85,7 @@ class LayerPolygon: # Points are picked based on the index list to get the vertices needed. vertices[self._vertex_begin:self._vertex_end, :] = self._data[index_list, :] + # Create an array with colors for each vertex and remove the color data for the points that has been thrown away. colors[self._vertex_begin:self._vertex_end, :] = numpy.tile(self._colors, (1, 2)).reshape((-1, 4))[needed_points_list.ravel()] colors[self._vertex_begin:self._vertex_end, :] *= numpy.array([[0.5, 0.5, 0.5, 1.0]], numpy.float32) diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 7b814d99b4..be148e41f6 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -149,16 +149,6 @@ class ProcessSlicedLayersJob(Job): # We are done processing all the layers we got from the engine, now create a mesh out of the data layer_mesh = layer_data.build() - # Hack for adding line widths and heights: misuse u, v coordinates. - #uvs = numpy.zeros([layer_mesh.getVertexCount(), 2], dtype=numpy.float32) - #uvs[:, 0] = 0.175 - #uvs[:, 1] = 0.125 - - #from UM.Math import NumPyUtil - #layer_mesh._uvs = NumPyUtil.immutableNDArray(uvs) - # mesh._uvs = numpy.zeros([layer_mesh.getVertexCount(), 2]) - # mesh._uvs[:, 0] = 1.0 # width - # mesh._uvs[:, 1] = 0.1 # height if self._abort_requested: if self._progress: diff --git a/plugins/LayerView/layers.shader b/plugins/LayerView/layers.shader index 0cff84d233..cb34360226 100644 --- a/plugins/LayerView/layers.shader +++ b/plugins/LayerView/layers.shader @@ -10,13 +10,14 @@ vertex = attribute highp vec4 a_vertex; attribute lowp vec4 a_color; attribute highp vec4 a_normal; - attribute highp vec2 a_uvs; // misused here for width and height + attribute highp vec2 a_line_dim; // line width and thickness varying lowp vec4 v_color; varying highp vec3 v_vertex; varying highp vec3 v_normal; - varying lowp vec2 v_uvs; + //varying lowp vec2 v_uvs; + varying lowp vec2 v_line_dim; varying lowp vec4 f_color; varying highp vec3 f_vertex; @@ -25,7 +26,7 @@ vertex = void main() { vec4 v1_vertex = a_vertex; - v1_vertex.y -= a_uvs.y / 2; // half layer down + v1_vertex.y -= a_line_dim.y / 2; // half layer down vec4 world_space_vert = u_modelMatrix * v1_vertex; // gl_Position = u_viewProjectionMatrix * world_space_vert; gl_Position = world_space_vert; @@ -36,7 +37,7 @@ vertex = v_vertex = world_space_vert.xyz; v_normal = (u_normalMatrix * normalize(a_normal)).xyz; - v_uvs = a_uvs; + v_line_dim = a_line_dim; // for testing without geometry shader f_color = v_color; @@ -47,9 +48,7 @@ vertex = geometry = #version 410 - //uniform highp mat4 u_modelMatrix; uniform highp mat4 u_viewProjectionMatrix; - //uniform highp mat4 u_modelViewProjectionMatrix; layout(lines) in; layout(triangle_strip, max_vertices = 26) out; @@ -57,7 +56,7 @@ geometry = in vec4 v_color[]; in vec3 v_vertex[]; in vec3 v_normal[]; - in vec2 v_uvs[]; + in vec2 v_line_dim[]; out vec4 f_color; out vec3 f_normal; @@ -65,10 +64,6 @@ geometry = void main() { - //int i; - //vec3 g_normal; - //vec3 g_offset; - vec4 g_vertex_delta; vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position @@ -77,8 +72,8 @@ geometry = vec3 g_vertex_normal_horz_head; vec4 g_vertex_offset_horz_head; - float size_x = v_uvs[0].x / 2 + 0.01; // radius, and make it nicely overlapping - float size_y = v_uvs[0].y / 2 + 0.01; + float size_x = v_line_dim[0].x / 2 + 0.01; // radius, and make it nicely overlapping + float size_y = v_line_dim[0].y / 2 + 0.01; //g_vertex_normal_horz = normalize(v_normal[0]); //vec3(g_vertex_delta.z, g_vertex_delta.y, -g_vertex_delta.x); g_vertex_delta = gl_in[1].gl_Position - gl_in[0].gl_Position; @@ -89,7 +84,6 @@ geometry = g_vertex_offset_horz = vec4(g_vertex_normal_horz * size_x, 0.0); //size * g_vertex_normal_horz; g_vertex_normal_vert = vec3(0.0, 1.0, 0.0); - //g_vertex_offset_vert = vec3(g_vertex_normal_vert.x * 0.5f, g_vertex_normal_vert.y * 0.5f, g_vertex_normal_vert.z * 0.5f); //size * g_vertex_normal_vert; g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0); f_vertex = v_vertex[0]; @@ -243,10 +237,6 @@ geometry = EmitVertex(); EndPrimitive(); - - - - } fragment = @@ -327,4 +317,4 @@ u_lightPosition = light_0_position a_vertex = vertex a_color = color a_normal = normal -a_uvs = uv0 +a_line_dim = line_dim |