Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
41f3721f
Commit
41f3721f
authored
Mar 30, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specify normals in heavy model
parent
5684c83e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
13 deletions
+40
-13
actors.py
printrun/gl/libtatlin/actors.py
+40
-13
No files found.
printrun/gl/libtatlin/actors.py
View file @
41f3721f
...
@@ -314,6 +314,7 @@ class GcodeModel(Model):
...
@@ -314,6 +314,7 @@ class GcodeModel(Model):
count_print_vertices
=
[
0
]
count_print_vertices
=
[
0
]
travel_vertex_list
=
[]
travel_vertex_list
=
[]
vertex_list
=
[]
vertex_list
=
[]
normal_list
=
[]
index_list
=
[]
index_list
=
[]
color_list
=
[]
color_list
=
[]
self
.
layer_idxs_map
=
{}
self
.
layer_idxs_map
=
{}
...
@@ -360,6 +361,7 @@ class GcodeModel(Model):
...
@@ -360,6 +361,7 @@ class GcodeModel(Model):
new_indices
=
[]
new_indices
=
[]
new_vertices
=
[]
new_vertices
=
[]
new_normals
=
[]
if
prev_is_extruding
:
if
prev_is_extruding
:
# Store previous vertices indices
# Store previous vertices indices
prev_id
=
len
(
vertex_list
)
/
3
-
4
prev_id
=
len
(
vertex_list
)
/
3
-
4
...
@@ -380,10 +382,14 @@ class GcodeModel(Model):
...
@@ -380,10 +382,14 @@ class GcodeModel(Model):
p2x
=
prev_pos
[
0
]
+
path_halfwidth
*
avg_move_normal_x
p2x
=
prev_pos
[
0
]
+
path_halfwidth
*
avg_move_normal_x
p1y
=
prev_pos
[
1
]
-
path_halfwidth
*
avg_move_normal_y
p1y
=
prev_pos
[
1
]
-
path_halfwidth
*
avg_move_normal_y
p2y
=
prev_pos
[
1
]
+
path_halfwidth
*
avg_move_normal_y
p2y
=
prev_pos
[
1
]
+
path_halfwidth
*
avg_move_normal_y
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
prev_pos
[
0
],
prev_pos
[
1
],
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
prev_pos
[
0
],
prev_pos
[
1
],
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]))
new_normals
.
extend
((
0
,
0
,
1
))
new_normals
.
extend
((
-
move_normal_x
,
-
move_normal_y
,
0
))
new_normals
.
extend
((
0
,
0
,
-
1
))
new_normals
.
extend
((
move_normal_x
,
move_normal_y
,
0
))
first
=
len
(
vertex_list
)
/
3
first
=
len
(
vertex_list
)
/
3
# Link to previous
# Link to previous
new_indices
+=
triangulate_box
(
prev_id
,
prev_id
+
1
,
new_indices
+=
triangulate_box
(
prev_id
,
prev_id
+
1
,
...
@@ -396,10 +402,14 @@ class GcodeModel(Model):
...
@@ -396,10 +402,14 @@ class GcodeModel(Model):
p2x
=
prev_pos
[
0
]
+
path_halfwidth
*
move_normal_x
p2x
=
prev_pos
[
0
]
+
path_halfwidth
*
move_normal_x
p1y
=
prev_pos
[
1
]
-
path_halfwidth
*
move_normal_y
p1y
=
prev_pos
[
1
]
-
path_halfwidth
*
move_normal_y
p2y
=
prev_pos
[
1
]
+
path_halfwidth
*
move_normal_y
p2y
=
prev_pos
[
1
]
+
path_halfwidth
*
move_normal_y
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
prev_pos
[
0
],
prev_pos
[
1
],
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
prev_pos
[
2
]))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
prev_pos
[
0
],
prev_pos
[
1
],
prev_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
prev_pos
[
2
]))
new_normals
.
extend
((
0
,
0
,
1
))
new_normals
.
extend
((
-
move_normal_x
,
-
move_normal_y
,
0
))
new_normals
.
extend
((
0
,
0
,
-
1
))
new_normals
.
extend
((
move_normal_x
,
move_normal_y
,
0
))
first
=
len
(
vertex_list
)
/
3
first
=
len
(
vertex_list
)
/
3
new_indices
=
triangulate_rectangle
(
first
,
first
+
1
,
new_indices
=
triangulate_rectangle
(
first
,
first
+
1
,
first
+
2
,
first
+
3
)
first
+
2
,
first
+
3
)
...
@@ -410,10 +420,14 @@ class GcodeModel(Model):
...
@@ -410,10 +420,14 @@ class GcodeModel(Model):
p2x
=
current_pos
[
0
]
+
path_halfwidth
*
move_normal_x
p2x
=
current_pos
[
0
]
+
path_halfwidth
*
move_normal_x
p1y
=
current_pos
[
1
]
-
path_halfwidth
*
move_normal_y
p1y
=
current_pos
[
1
]
-
path_halfwidth
*
move_normal_y
p2y
=
current_pos
[
1
]
+
path_halfwidth
*
move_normal_y
p2y
=
current_pos
[
1
]
+
path_halfwidth
*
move_normal_y
new_vertices
.
extend
((
p1x
,
p1y
,
current_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
current_pos
[
0
],
current_pos
[
1
],
current_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
current_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p1x
,
p1y
,
current_pos
[
2
]))
new_vertices
.
extend
((
p2x
,
p2y
,
current_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
current_pos
[
0
],
current_pos
[
1
],
current_pos
[
2
]
-
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
current_pos
[
2
]
+
path_halfheight
))
new_vertices
.
extend
((
p2x
,
p2y
,
current_pos
[
2
]))
new_normals
.
extend
((
0
,
0
,
1
))
new_normals
.
extend
((
-
move_normal_x
,
-
move_normal_y
,
0
))
new_normals
.
extend
((
0
,
0
,
-
1
))
new_normals
.
extend
((
move_normal_x
,
move_normal_y
,
0
))
end_first
=
len
(
vertex_list
)
/
3
+
len
(
new_vertices
)
/
3
-
4
end_first
=
len
(
vertex_list
)
/
3
+
len
(
new_vertices
)
/
3
-
4
new_indices
+=
triangulate_rectangle
(
end_first
+
3
,
end_first
+
2
,
new_indices
+=
triangulate_rectangle
(
end_first
+
3
,
end_first
+
2
,
end_first
+
1
,
end_first
)
end_first
+
1
,
end_first
)
...
@@ -424,6 +438,7 @@ class GcodeModel(Model):
...
@@ -424,6 +438,7 @@ class GcodeModel(Model):
index_list
+=
new_indices
index_list
+=
new_indices
vertex_list
+=
new_vertices
vertex_list
+=
new_vertices
normal_list
+=
new_normals
color_list
+=
list
(
gline_color
)
*
(
len
(
new_vertices
)
/
3
)
color_list
+=
list
(
gline_color
)
*
(
len
(
new_vertices
)
/
3
)
prev_is_extruding
=
True
prev_is_extruding
=
True
...
@@ -457,6 +472,8 @@ class GcodeModel(Model):
...
@@ -457,6 +472,8 @@ class GcodeModel(Model):
count
=
len
(
travel_vertex_list
))
count
=
len
(
travel_vertex_list
))
self
.
vertices
=
numpy
.
fromiter
(
vertex_list
,
dtype
=
GLfloat
,
self
.
vertices
=
numpy
.
fromiter
(
vertex_list
,
dtype
=
GLfloat
,
count
=
len
(
vertex_list
))
count
=
len
(
vertex_list
))
self
.
normals
=
numpy
.
fromiter
(
normal_list
,
dtype
=
GLfloat
,
count
=
len
(
normal_list
))
self
.
indices
=
numpy
.
fromiter
(
index_list
,
dtype
=
GLuint
,
self
.
indices
=
numpy
.
fromiter
(
index_list
,
dtype
=
GLuint
,
count
=
len
(
index_list
))
count
=
len
(
index_list
))
self
.
colors
=
numpy
.
fromiter
(
color_list
,
dtype
=
GLfloat
,
self
.
colors
=
numpy
.
fromiter
(
color_list
,
dtype
=
GLfloat
,
...
@@ -509,13 +526,15 @@ class GcodeModel(Model):
...
@@ -509,13 +526,15 @@ class GcodeModel(Model):
self
.
index_buffer
=
numpy2vbo
(
self
.
indices
,
use_vbos
=
self
.
use_vbos
,
self
.
index_buffer
=
numpy2vbo
(
self
.
indices
,
use_vbos
=
self
.
use_vbos
,
target
=
GL_ELEMENT_ARRAY_BUFFER
)
target
=
GL_ELEMENT_ARRAY_BUFFER
)
self
.
vertex_buffer
=
numpy2vbo
(
self
.
vertices
,
use_vbos
=
self
.
use_vbos
)
self
.
vertex_buffer
=
numpy2vbo
(
self
.
vertices
,
use_vbos
=
self
.
use_vbos
)
self
.
vertex_color_buffer
=
numpy2vbo
(
self
.
colors
,
use_vbos
=
self
.
use_vbos
)
# each pair of vertices shares the color
self
.
vertex_color_buffer
=
numpy2vbo
(
self
.
colors
,
use_vbos
=
self
.
use_vbos
)
self
.
vertex_normal_buffer
=
numpy2vbo
(
self
.
normals
,
use_vbos
=
self
.
use_vbos
)
self
.
initialized
=
True
self
.
initialized
=
True
def
display
(
self
,
mode_2d
=
False
):
def
display
(
self
,
mode_2d
=
False
):
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
self
.
offset_x
,
self
.
offset_y
,
0
)
glTranslatef
(
self
.
offset_x
,
self
.
offset_y
,
0
)
glEnableClientState
(
GL_VERTEX_ARRAY
)
glEnableClientState
(
GL_VERTEX_ARRAY
)
glEnableClientState
(
GL_NORMAL_ARRAY
)
has_vbo
=
isinstance
(
self
.
vertex_buffer
,
VertexBufferObject
)
has_vbo
=
isinstance
(
self
.
vertex_buffer
,
VertexBufferObject
)
self
.
_display_travels
(
has_vbo
)
self
.
_display_travels
(
has_vbo
)
...
@@ -533,6 +552,7 @@ class GcodeModel(Model):
...
@@ -533,6 +552,7 @@ class GcodeModel(Model):
glDisableClientState
(
GL_COLOR_ARRAY
)
glDisableClientState
(
GL_COLOR_ARRAY
)
glDisableClientState
(
GL_VERTEX_ARRAY
)
glDisableClientState
(
GL_VERTEX_ARRAY
)
glDisableClientState
(
GL_NORMAL_ARRAY
)
glPopMatrix
()
glPopMatrix
()
...
@@ -581,6 +601,12 @@ class GcodeModel(Model):
...
@@ -581,6 +601,12 @@ class GcodeModel(Model):
else
:
else
:
glColorPointer
(
4
,
GL_FLOAT
,
0
,
self
.
vertex_color_buffer
.
ptr
)
glColorPointer
(
4
,
GL_FLOAT
,
0
,
self
.
vertex_color_buffer
.
ptr
)
self
.
vertex_normal_buffer
.
bind
()
if
has_vbo
:
glNormalPointer
(
GL_FLOAT
,
0
,
None
)
else
:
glNormalPointer
(
GL_FLOAT
,
0
,
self
.
vertex_normal_buffer
.
ptr
)
self
.
index_buffer
.
bind
()
self
.
index_buffer
.
bind
()
start
=
1
start
=
1
...
@@ -635,6 +661,7 @@ class GcodeModel(Model):
...
@@ -635,6 +661,7 @@ class GcodeModel(Model):
self
.
vertex_buffer
.
unbind
()
self
.
vertex_buffer
.
unbind
()
self
.
vertex_color_buffer
.
unbind
()
self
.
vertex_color_buffer
.
unbind
()
self
.
vertex_normal_buffer
.
unbind
()
class
GcodeModelLight
(
Model
):
class
GcodeModelLight
(
Model
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment