Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
c62dc337
Commit
c62dc337
authored
6 years ago
by
Antonioya
Browse files
Options
Downloads
Patches
Plain Diff
MeasureIt: Fix render result.
Thanks to Jacques Lucke for help me to fix this area.
parent
c3c0fd18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
measureit/measureit_render.py
+7
-36
7 additions, 36 deletions
measureit/measureit_render.py
with
7 additions
and
36 deletions
measureit/measureit_render.py
+
7
−
36
View file @
c62dc337
...
@@ -65,14 +65,17 @@ def render_main(self, context, animation=False):
...
@@ -65,14 +65,17 @@ def render_main(self, context, animation=False):
# Loop to draw all lines in Offsecreen
# Loop to draw all lines in Offsecreen
# --------------------------------------
# --------------------------------------
offscreen
=
gpu
.
types
.
GPUOffScreen
(
width
,
height
)
offscreen
=
gpu
.
types
.
GPUOffScreen
(
width
,
height
)
view_matrix
=
scene
.
camera
.
matrix_world
.
inverted
()
view_matrix
=
Matrix
([
projection_matrix
=
scene
.
camera
.
calc_matrix_camera
(
context
.
depsgraph
,
x
=
width
,
y
=
height
)
[
2
/
width
,
0
,
0
,
-
1
],
[
0
,
2
/
height
,
0
,
-
1
],
[
0
,
0
,
1
,
0
],
[
0
,
0
,
0
,
1
]])
with
offscreen
.
bind
():
with
offscreen
.
bind
():
bgl
.
glClear
(
bgl
.
GL_COLOR_BUFFER_BIT
)
bgl
.
glClear
(
bgl
.
GL_COLOR_BUFFER_BIT
)
gpu
.
matrix
.
reset
()
gpu
.
matrix
.
reset
()
gpu
.
matrix
.
load_matrix
(
view_matrix
)
gpu
.
matrix
.
load_matrix
(
view_matrix
)
gpu
.
matrix
.
load_projection_matrix
(
projection_matrix
)
gpu
.
matrix
.
load_projection_matrix
(
Matrix
.
Identity
(
4
)
)
# -----------------------------
# -----------------------------
# Loop to draw all objects
# Loop to draw all objects
...
@@ -116,7 +119,7 @@ def render_main(self, context, animation=False):
...
@@ -116,7 +119,7 @@ def render_main(self, context, animation=False):
draw_rectangle
((
x1
,
y1
),
(
x2
,
y2
),
rfcolor
)
draw_rectangle
((
x1
,
y1
),
(
x2
,
y2
),
rfcolor
)
buffer
=
bgl
.
Buffer
(
bgl
.
GL_BYTE
,
width
*
height
*
4
)
buffer
=
bgl
.
Buffer
(
bgl
.
GL_BYTE
,
width
*
height
*
4
)
bgl
.
glReadBuffer
(
bgl
.
GL_
BACK
)
bgl
.
glReadBuffer
(
bgl
.
GL_
COLOR_ATTACHMENT0
)
bgl
.
glReadPixels
(
0
,
0
,
width
,
height
,
bgl
.
GL_RGBA
,
bgl
.
GL_UNSIGNED_BYTE
,
buffer
)
bgl
.
glReadPixels
(
0
,
0
,
width
,
height
,
bgl
.
GL_RGBA
,
bgl
.
GL_UNSIGNED_BYTE
,
buffer
)
offscreen
.
free
()
offscreen
.
free
()
...
@@ -150,38 +153,6 @@ def render_main(self, context, animation=False):
...
@@ -150,38 +153,6 @@ def render_main(self, context, animation=False):
settings
.
color_depth
=
depth
settings
.
color_depth
=
depth
# --------------------------------------------------------------------
# Get the final render image and return as image object
#
# return None if no render available
# --------------------------------------------------------------------
def
get_render_image
(
outpath
):
saved
=
False
# noinspection PyBroadException
try
:
# noinspection PyBroadException
try
:
result
=
bpy
.
data
.
images
[
'
Render Result
'
]
if
result
.
has_data
is
False
:
# this save produce to fill data image
result
.
save_render
(
outpath
)
saved
=
True
except
:
print
(
"
No render image found
"
)
return
None
# Save and reload
if
saved
is
False
:
result
.
save_render
(
outpath
)
img
=
img_utils
.
load_image
(
outpath
)
return
img
except
:
print
(
"
Unexpected render image error
"
)
return
None
# -------------------------------------
# -------------------------------------
# Save image to file
# Save image to file
# -------------------------------------
# -------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment