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
ef6af8b3
Commit
ef6af8b3
authored
14 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
minor cleanup.
parent
a2f135e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
space_view3d_math_vis/draw.py
+17
-16
17 additions, 16 deletions
space_view3d_math_vis/draw.py
with
17 additions
and
16 deletions
space_view3d_math_vis/draw.py
+
17
−
16
View file @
ef6af8b3
...
@@ -24,6 +24,7 @@ from mathutils import Vector, Matrix
...
@@ -24,6 +24,7 @@ from mathutils import Vector, Matrix
callbacks
=
{}
callbacks
=
{}
def
callbacks_clear
():
def
callbacks_clear
():
for
region
,
handle_pixel
,
handle_view
in
callbacks
.
values
():
for
region
,
handle_pixel
,
handle_view
in
callbacks
.
values
():
region
.
callback_remove
(
handle_pixel
)
region
.
callback_remove
(
handle_pixel
)
...
@@ -33,7 +34,7 @@ def callbacks_clear():
...
@@ -33,7 +34,7 @@ def callbacks_clear():
def
draw_callback_px
(
self
,
context
):
def
draw_callback_px
(
self
,
context
):
from
bgl
import
glColor3f
from
bgl
import
glColor3f
font_id
=
0
# XXX, need to find out how best to get this.
font_id
=
0
# XXX, need to find out how best to get this.
blf
.
size
(
font_id
,
12
,
72
)
blf
.
size
(
font_id
,
12
,
72
)
data_matrix
,
data_quat
,
data_euler
,
data_vector
,
data_vector_array
=
utils
.
console_math_data
()
data_matrix
,
data_quat
,
data_euler
,
data_vector
,
data_vector_array
=
utils
.
console_math_data
()
...
@@ -50,7 +51,7 @@ def draw_callback_px(self, context):
...
@@ -50,7 +51,7 @@ def draw_callback_px(self, context):
region
=
context
.
region
region
=
context
.
region
region3d
=
context
.
space_data
.
region_3d
region3d
=
context
.
space_data
.
region_3d
region_mid_width
=
region
.
width
/
2.0
region_mid_width
=
region
.
width
/
2.0
region_mid_height
=
region
.
height
/
2.0
region_mid_height
=
region
.
height
/
2.0
...
@@ -58,7 +59,7 @@ def draw_callback_px(self, context):
...
@@ -58,7 +59,7 @@ def draw_callback_px(self, context):
perspective_matrix
=
region3d
.
perspective_matrix
.
copy
()
perspective_matrix
=
region3d
.
perspective_matrix
.
copy
()
def
draw_text
(
text
,
vec
):
def
draw_text
(
text
,
vec
):
vec_4d
=
V
ecto
r
((
vec
.
x
,
vec
.
y
,
vec
.
z
,
1.0
)
)
vec_4d
=
v
ec
.
to
_4d
(
)
vec_4d
*=
perspective_matrix
vec_4d
*=
perspective_matrix
if
vec_4d
.
w
>
0.0
:
if
vec_4d
.
w
>
0.0
:
x
=
region_mid_width
+
region_mid_width
*
(
vec_4d
.
x
/
vec_4d
.
w
)
x
=
region_mid_width
+
region_mid_width
*
(
vec_4d
.
x
/
vec_4d
.
w
)
...
@@ -81,7 +82,7 @@ def draw_callback_px(self, context):
...
@@ -81,7 +82,7 @@ def draw_callback_px(self, context):
if
data_matrix
:
if
data_matrix
:
for
key
,
mat
in
data_matrix
.
items
():
for
key
,
mat
in
data_matrix
.
items
():
draw_text
(
key
,
mat
[
3
])
draw_text
(
key
,
mat
[
3
])
if
data_quat
:
if
data_quat
:
loc
=
context
.
scene
.
cursor_location
.
copy
()
loc
=
context
.
scene
.
cursor_location
.
copy
()
for
key
,
mat
in
data_quat
.
items
():
for
key
,
mat
in
data_quat
.
items
():
...
@@ -98,7 +99,6 @@ def draw_callback_view(self, context):
...
@@ -98,7 +99,6 @@ def draw_callback_view(self, context):
data_matrix
,
data_quat
,
data_euler
,
data_vector
,
data_vector_array
=
utils
.
console_math_data
()
data_matrix
,
data_quat
,
data_euler
,
data_vector
,
data_vector_array
=
utils
.
console_math_data
()
# draw_matrix vars
# draw_matrix vars
zero
=
Vector
((
0.0
,
0.0
,
0.0
))
zero
=
Vector
((
0.0
,
0.0
,
0.0
))
x_p
=
Vector
((
1.0
,
0.0
,
0.0
))
x_p
=
Vector
((
1.0
,
0.0
,
0.0
))
...
@@ -106,14 +106,14 @@ def draw_callback_view(self, context):
...
@@ -106,14 +106,14 @@ def draw_callback_view(self, context):
y_p
=
Vector
((
0.0
,
1.0
,
0.0
))
y_p
=
Vector
((
0.0
,
1.0
,
0.0
))
y_n
=
Vector
((
0.0
,
-
1.0
,
0.0
))
y_n
=
Vector
((
0.0
,
-
1.0
,
0.0
))
z_p
=
Vector
((
0.0
,
0.0
,
1.0
))
z_p
=
Vector
((
0.0
,
0.0
,
1.0
))
z_n
=
Vector
((
0.0
,
0.0
,
-
1.0
))
z_n
=
Vector
((
0.0
,
0.0
,
-
1.0
))
bb
=
[
Vector
()
for
i
in
range
(
8
)]
bb
=
[
Vector
()
for
i
in
range
(
8
)]
def
draw_matrix
(
mat
):
def
draw_matrix
(
mat
):
zero_tx
=
zero
*
mat
zero_tx
=
zero
*
mat
glLineWidth
(
2.0
)
glLineWidth
(
2.0
)
# x
# x
glColor3f
(
1.0
,
0.2
,
0.2
)
glColor3f
(
1.0
,
0.2
,
0.2
)
glBegin
(
GL_LINES
)
glBegin
(
GL_LINES
)
...
@@ -139,7 +139,7 @@ def draw_callback_view(self, context):
...
@@ -139,7 +139,7 @@ def draw_callback_view(self, context):
glVertex3f
(
*
(
zero_tx
))
glVertex3f
(
*
(
zero_tx
))
glVertex3f
(
*
(
y_n
*
mat
))
glVertex3f
(
*
(
y_n
*
mat
))
glEnd
()
glEnd
()
# z
# z
glColor3f
(
0.2
,
0.2
,
1.0
)
glColor3f
(
0.2
,
0.2
,
1.0
)
glBegin
(
GL_LINES
)
glBegin
(
GL_LINES
)
...
@@ -152,7 +152,7 @@ def draw_callback_view(self, context):
...
@@ -152,7 +152,7 @@ def draw_callback_view(self, context):
glVertex3f
(
*
(
zero_tx
))
glVertex3f
(
*
(
zero_tx
))
glVertex3f
(
*
(
z_n
*
mat
))
glVertex3f
(
*
(
z_n
*
mat
))
glEnd
()
glEnd
()
# bounding box
# bounding box
i
=
0
i
=
0
glColor3f
(
1.0
,
1.0
,
1.0
)
glColor3f
(
1.0
,
1.0
,
1.0
)
...
@@ -177,26 +177,27 @@ def draw_callback_view(self, context):
...
@@ -177,26 +177,27 @@ def draw_callback_view(self, context):
glBegin
(
GL_LINES
)
glBegin
(
GL_LINES
)
glVertex3f
(
*
bb
[
1
])
glVertex3f
(
*
bb
[
1
])
glVertex3f
(
*
bb
[
5
])
glVertex3f
(
*
bb
[
5
])
glVertex3f
(
*
bb
[
2
])
glVertex3f
(
*
bb
[
2
])
glVertex3f
(
*
bb
[
6
])
glVertex3f
(
*
bb
[
6
])
glVertex3f
(
*
bb
[
3
])
glVertex3f
(
*
bb
[
3
])
glVertex3f
(
*
bb
[
7
])
glVertex3f
(
*
bb
[
7
])
glEnd
()
glEnd
()
glDisable
(
GL_LINE_STIPPLE
)
glDisable
(
GL_LINE_STIPPLE
)
########
# points
# points
if
data_vector
:
if
data_vector
:
glPointSize
(
3.0
)
;
glPointSize
(
3.0
)
glBegin
(
GL_POINTS
)
glBegin
(
GL_POINTS
)
glColor3f
(
0.5
,
0.5
,
1
)
glColor3f
(
0.5
,
0.5
,
1
)
for
key
,
vec
in
data_vector
.
items
():
for
key
,
vec
in
data_vector
.
items
():
glVertex3f
(
*
vec
.
to_3d
())
glVertex3f
(
*
vec
.
to_3d
())
glEnd
()
;
glEnd
()
glPointSize
(
1.0
)
glPointSize
(
1.0
)
#######
# lines
# lines
if
data_vector_array
:
if
data_vector_array
:
glColor3f
(
0.5
,
0.5
,
1
)
glColor3f
(
0.5
,
0.5
,
1
)
...
@@ -206,7 +207,7 @@ def draw_callback_view(self, context):
...
@@ -206,7 +207,7 @@ def draw_callback_view(self, context):
glBegin
(
GL_LINE_STRIP
)
glBegin
(
GL_LINE_STRIP
)
for
vec
in
line
:
for
vec
in
line
:
glVertex3f
(
*
vec
)
glVertex3f
(
*
vec
)
glEnd
()
;
glEnd
()
glPointSize
(
1.0
)
glPointSize
(
1.0
)
glLineWidth
(
1.0
)
glLineWidth
(
1.0
)
...
...
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