Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons-contrib
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-contrib
Commits
ae731385
Commit
ae731385
authored
11 years ago
by
CoDEmanX
Browse files
Options
Downloads
Patches
Plain Diff
Game Property Visualizer: added back modal method for realtime feedback (Area.tag_draw).
parent
c993c924
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
space_view3d_game_props_visualiser.py
+31
-19
31 additions, 19 deletions
space_view3d_game_props_visualiser.py
with
31 additions
and
19 deletions
space_view3d_game_props_visualiser.py
+
31
−
19
View file @
ae731385
...
@@ -28,7 +28,8 @@ bl_info = {
...
@@ -28,7 +28,8 @@ bl_info = {
"
description
"
:
"
Display the game properties next to selected objects
"
"
description
"
:
"
Display the game properties next to selected objects
"
"
in the 3d-view
"
,
"
in the 3d-view
"
,
"
warning
"
:
"
Script is returning errors
"
,
"
warning
"
:
"
Script is returning errors
"
,
"
wiki_url
"
:
"
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Game_Property_Visualiser
"
,
"
wiki_url
"
:
"
http://wiki.blender.org/index.php/Extensions:2.6/Py/
"
"
Scripts/3D_interaction/Game_Property_Visualiser
"
,
"
tracker_url
"
:
"
https://developer.blender.org/T22607
"
,
"
tracker_url
"
:
"
https://developer.blender.org/T22607
"
,
"
category
"
:
"
3D View
"
}
"
category
"
:
"
3D View
"
}
...
@@ -52,8 +53,8 @@ def calc_callback(self, context):
...
@@ -52,8 +53,8 @@ def calc_callback(self, context):
return
return
# get screen information
# get screen information
mid_x
=
context
.
region
.
width
/
2.0
mid_x
=
context
.
region
.
width
/
2.0
mid_y
=
context
.
region
.
height
/
2.0
mid_y
=
context
.
region
.
height
/
2.0
width
=
context
.
region
.
width
width
=
context
.
region
.
width
height
=
context
.
region
.
height
height
=
context
.
region
.
height
...
@@ -61,7 +62,7 @@ def calc_callback(self, context):
...
@@ -61,7 +62,7 @@ def calc_callback(self, context):
view_mat
=
context
.
space_data
.
region_3d
.
perspective_matrix
view_mat
=
context
.
space_data
.
region_3d
.
perspective_matrix
ob_mat
=
context
.
active_object
.
matrix_world
ob_mat
=
context
.
active_object
.
matrix_world
total_mat
=
view_mat
*
ob_mat
total_mat
=
view_mat
*
ob_mat
# calculate location info
# calculate location info
texts
=
[]
texts
=
[]
...
@@ -76,15 +77,15 @@ def calc_callback(self, context):
...
@@ -76,15 +77,15 @@ def calc_callback(self, context):
for
p
in
ob
.
game
.
properties
:
for
p
in
ob
.
game
.
properties
:
# d = {'data':p.name+':'+str(p.value)}
# d = {'data':p.name+':'+str(p.value)}
# print (d)
# print (d)
locs
.
append
(
mathutils
.
Vector
((
0
,
0
,
0
,
1
)))
locs
.
append
(
mathutils
.
Vector
((
0
,
0
,
0
,
1
)))
for
loc
in
locs
:
for
loc
in
locs
:
vec
=
total_mat
*
loc
# order is important
vec
=
total_mat
*
loc
# order is important
# dehomogenise
# dehomogenise
vec
=
mathutils
.
Vector
((
vec
[
0
]
/
vec
[
3
],
vec
[
1
]
/
vec
[
3
],
vec
[
2
]
/
vec
[
3
]))
vec
=
mathutils
.
Vector
((
vec
[
0
]
/
vec
[
3
],
vec
[
1
]
/
vec
[
3
],
vec
[
2
]
/
vec
[
3
]))
x
=
int
(
mid_x
+
vec
[
0
]
*
width
/
2.0
)
x
=
int
(
mid_x
+
vec
[
0
]
*
width
/
2.0
)
y
=
int
(
mid_y
+
vec
[
1
]
*
height
/
2.0
)
y
=
int
(
mid_y
+
vec
[
1
]
*
height
/
2.0
)
texts
+=
[
x
,
y
]
texts
+=
[
x
,
y
]
# store as ID property in mesh
# store as ID property in mesh
context
.
scene
[
'
GamePropsVisualizer
'
]
=
texts
context
.
scene
[
'
GamePropsVisualizer
'
]
=
texts
...
@@ -110,21 +111,21 @@ def draw_callback(self, context):
...
@@ -110,21 +111,21 @@ def draw_callback(self, context):
texts
=
context
.
scene
[
'
GamePropsVisualizer
'
]
texts
=
context
.
scene
[
'
GamePropsVisualizer
'
]
# draw
# draw
i
=
0
i
=
0
blf
.
size
(
0
,
12
,
72
)
blf
.
size
(
0
,
12
,
72
)
bgl
.
glColor3f
(
1.0
,
1.0
,
1.0
)
bgl
.
glColor3f
(
1.0
,
1.0
,
1.0
)
for
ob
in
bpy
.
context
.
selected_objects
:
for
ob
in
bpy
.
context
.
selected_objects
:
for
pi
,
p
in
enumerate
(
ob
.
game
.
properties
):
for
pi
,
p
in
enumerate
(
ob
.
game
.
properties
):
blf
.
position
(
0
,
texts
[
i
],
texts
[
i
+
1
]
-
(
pi
+
1
)
*
14
,
0
)
blf
.
position
(
0
,
texts
[
i
],
texts
[
i
+
1
]
-
(
pi
+
1
)
*
14
,
0
)
if
p
.
type
==
'
FLOAT
'
:
if
p
.
type
==
'
FLOAT
'
:
t
=
p
.
name
+
'
:
'
+
str
(
'
%g
'
%
p
.
value
)
t
=
p
.
name
+
'
:
'
+
str
(
'
%g
'
%
p
.
value
)
else
:
else
:
t
=
p
.
name
+
'
:
'
+
str
(
p
.
value
)
t
=
p
.
name
+
'
:
'
+
str
(
p
.
value
)
blf
.
draw
(
0
,
t
)
blf
.
draw
(
0
,
t
)
i
+=
2
i
+=
2
# operator
# operator
...
@@ -156,22 +157,33 @@ class GamePropertyVisualizer(bpy.types.Operator):
...
@@ -156,22 +157,33 @@ class GamePropertyVisualizer(bpy.types.Operator):
def
poll
(
cls
,
context
):
def
poll
(
cls
,
context
):
return
context
.
mode
!=
'
EDIT_MESH
'
return
context
.
mode
!=
'
EDIT_MESH
'
def
execute
(
self
,
context
):
def
modal
(
self
,
context
,
event
):
if
not
context
.
scene
.
display_game_properties
:
return
self
.
cancel
(
context
)
context
.
area
.
tag_redraw
()
return
{
'
PASS_THROUGH
'
}
def
invoke
(
self
,
context
,
event
):
if
context
.
area
.
type
==
'
VIEW_3D
'
:
if
context
.
area
.
type
==
'
VIEW_3D
'
:
if
not
context
.
scene
.
display_game_properties
:
if
not
context
.
scene
.
display_game_properties
:
# operator is called and not running
# operator is called and not running
GamePropertyVisualizer
.
handle_add
(
self
,
context
)
GamePropertyVisualizer
.
handle_add
(
self
,
context
)
context
.
scene
.
display_game_properties
=
True
context
.
scene
.
display_game_properties
=
True
context
.
window_manager
.
modal_handler_add
(
self
)
return
{
'
RUNNING_MODAL
'
}
else
:
else
:
# operator is called again, stop displaying
# operator is called again, stop displaying
GamePropertyVisualizer
.
handle_remove
()
return
self
.
cancel
(
context
)
context
.
scene
.
display_game_properties
=
False
context
.
area
.
tag_redraw
()
return
{
'
FINISHED
'
}
else
:
else
:
self
.
report
({
'
WARNING
'
},
"
View3D not found, can
'
t run operator
"
)
self
.
report
({
'
WARNING
'
},
"
View3D not found, can
'
t run operator
"
)
return
{
'
CANCELLED
'
}
return
{
'
CANCELLED
'
}
def
cancel
(
self
,
context
):
GamePropertyVisualizer
.
handle_remove
()
context
.
scene
.
display_game_properties
=
False
context
.
area
.
tag_redraw
()
return
{
'
FINISHED
'
}
# defining the panel
# defining the panel
def
menu_func
(
self
,
context
):
def
menu_func
(
self
,
context
):
...
...
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