mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Started setting layer height and line width in layer view
This commit is contained in:
parent
2b37bde630
commit
c12e6da3ac
5 changed files with 37 additions and 15 deletions
|
@ -49,14 +49,14 @@ class Layer:
|
|||
|
||||
return result
|
||||
|
||||
def build(self, vertex_offset, index_offset, vertices, colors, indices, normals):
|
||||
def build(self, vertex_offset, index_offset, vertices, colors, indices):
|
||||
result_vertex_offset = vertex_offset
|
||||
result_index_offset = index_offset
|
||||
self._element_count = 0
|
||||
for polygon in self._polygons:
|
||||
polygon.build(result_vertex_offset, result_index_offset, vertices, colors, indices)
|
||||
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_normals = polygon.getNormals() # [numpy.where(numpy.logical_not(polygon.jumpMask))]
|
||||
#normals[result_vertex_offset:result_vertex_offset+polygon.lineMeshVertexCount()] = polygon_normals[:polygon.lineMeshVertexCount()]
|
||||
result_vertex_offset += polygon.lineMeshVertexCount()
|
||||
result_index_offset += polygon.lineMeshElementCount()
|
||||
self._element_count += polygon.elementCount
|
||||
|
|
|
@ -56,7 +56,7 @@ class LayerDataBuilder(MeshBuilder):
|
|||
index_count += data.lineMeshElementCount()
|
||||
|
||||
vertices = numpy.empty((vertex_count, 3), numpy.float32)
|
||||
normals = numpy.empty((vertex_count, 3), numpy.float32)
|
||||
# normals = numpy.empty((vertex_count, 3), numpy.float32)
|
||||
# line_widths = numpy.empty((vertex_count, 3), numpy.float32) # strictly taken you need 1 less
|
||||
colors = numpy.empty((vertex_count, 4), numpy.float32)
|
||||
indices = numpy.empty((index_count, 2), numpy.int32)
|
||||
|
@ -64,13 +64,13 @@ class LayerDataBuilder(MeshBuilder):
|
|||
vertex_offset = 0
|
||||
index_offset = 0
|
||||
for layer, data in self._layers.items():
|
||||
( vertex_offset, index_offset ) = data.build( vertex_offset, index_offset, vertices, colors, indices, normals)
|
||||
( vertex_offset, index_offset ) = data.build( vertex_offset, index_offset, vertices, colors, indices)
|
||||
self._element_counts[layer] = data.elementCount
|
||||
|
||||
self.addVertices(vertices)
|
||||
self.addColors(colors)
|
||||
self.addIndices(indices.flatten())
|
||||
self._normals = normals
|
||||
#self._normals = normals
|
||||
|
||||
return LayerData(vertices=self.getVertices(), normals=self.getNormals(), indices=self.getIndices(),
|
||||
colors=self.getColors(), uvs=self.getUVCoordinates(), file_name=self.getFileName(),
|
||||
|
|
|
@ -145,6 +145,16 @@ 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:
|
||||
|
|
|
@ -10,11 +10,13 @@ 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
|
||||
|
||||
varying lowp vec4 v_color;
|
||||
|
||||
varying highp vec3 v_vertex;
|
||||
varying highp vec3 v_normal;
|
||||
varying lowp vec2 v_uvs;
|
||||
|
||||
varying lowp vec4 f_color;
|
||||
varying highp vec3 f_vertex;
|
||||
|
@ -32,6 +34,7 @@ vertex =
|
|||
|
||||
v_vertex = world_space_vert.xyz;
|
||||
v_normal = (u_normalMatrix * normalize(a_normal)).xyz;
|
||||
v_uvs = a_uvs;
|
||||
|
||||
// for testing without geometry shader
|
||||
f_color = v_color;
|
||||
|
@ -47,14 +50,12 @@ geometry =
|
|||
//uniform highp mat4 u_modelViewProjectionMatrix;
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 28) out;
|
||||
/*layout(std140) uniform Matrices {
|
||||
mat4 u_modelViewProjectionMatrix;
|
||||
};*/
|
||||
layout(triangle_strip, max_vertices = 26) out;
|
||||
|
||||
in vec4 v_color[];
|
||||
in vec3 v_vertex[];
|
||||
in vec3 v_normal[];
|
||||
in vec2 v_uvs[];
|
||||
|
||||
out vec4 f_color;
|
||||
out vec3 f_normal;
|
||||
|
@ -74,8 +75,8 @@ geometry =
|
|||
vec3 g_vertex_normal_horz_head;
|
||||
vec4 g_vertex_offset_horz_head;
|
||||
|
||||
const float size_x = 0.2;
|
||||
const float size_y = 0.1;
|
||||
float size_x = v_uvs[0].x;
|
||||
float size_y = v_uvs[0].y;
|
||||
|
||||
//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;
|
||||
|
@ -90,25 +91,29 @@ geometry =
|
|||
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_normal = g_vertex_normal_horz;
|
||||
f_color = v_color[0];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
@ -116,23 +121,27 @@ geometry =
|
|||
f_vertex = v_vertex[0];
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
f_color = v_color[0];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = -g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[0];
|
||||
f_color = v_color[0];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = -g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = -g_vertex_normal_vert;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
|
||||
EmitVertex();
|
||||
|
@ -140,11 +149,13 @@ geometry =
|
|||
f_vertex = v_vertex[0];
|
||||
f_normal = g_vertex_normal_horz;
|
||||
f_color = v_color[0];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
||||
f_vertex = v_vertex[1];
|
||||
f_color = v_color[1];
|
||||
//f_color = vec4(v_uvs[0], 0.0, 1.0);
|
||||
f_normal = g_vertex_normal_horz;
|
||||
gl_Position = u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
|
||||
EmitVertex();
|
||||
|
@ -314,3 +325,4 @@ u_lightPosition = light_0_position
|
|||
a_vertex = vertex
|
||||
a_color = color
|
||||
a_normal = normal
|
||||
a_uvs = uv0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue