Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dalai Felinto
virtual_reality_viewport
Commits
30720f33
Commit
30720f33
authored
Oct 14, 2015
by
Dalai Felinto
Browse files
Commands (re-center) and barebones for tracking_mode
parent
e119339d
Changes
4
Show whitespace changes
Inline
Side-by-side
space_view3d_virtual_reality/hmd/__init__.py
View file @
30720f33
...
...
@@ -156,6 +156,15 @@ class HMD_Base:
"""
assert
False
,
"frameReady() not implemented for the
\"
{0}
\"
device"
.
format
(
self
.
_name
)
def
reCenter
(
self
):
"""
Re-center the HMD device
:return: return True if success
:rtype: bool
"""
assert
False
,
"reCenter() not implemented for the
\"
{0}
\"
device"
.
format
(
self
.
_name
)
def
quit
(
self
):
"""
Garbage collection
...
...
space_view3d_virtual_reality/hmd/oculus.py
View file @
30720f33
...
...
@@ -112,6 +112,15 @@ class Oculus(HMD_Base):
return
True
def
reCenter
(
self
):
"""
Re-center the HMD device
:return: return True if success
:rtype: bool
"""
return
self
.
_hmd
.
reCenter
()
def
quit
(
self
):
"""
Garbage collection
...
...
space_view3d_virtual_reality/operator.py
View file @
30720f33
...
...
@@ -13,6 +13,16 @@ from .lib import (
import
gpu
# ############################################################
# Commands
# ############################################################
class
Commands
:
recenter
=
'RECENTER'
test
=
'TEST'
# ############################################################
# Main Operator
# ############################################################
...
...
@@ -33,6 +43,7 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
items
=
((
"ENABLE"
,
"Enable"
,
"Enable"
),
(
"DISABLE"
,
"Disable"
,
"Disable"
),
(
"TOGGLE"
,
"Toggle"
,
"Toggle"
),
(
"RECENTER"
,
"Re-Center"
,
"Re-Center tracking data"
),
),
default
=
"TOGGLE"
,
options
=
{
'SKIP_SAVE'
},
...
...
@@ -77,15 +88,15 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
self
.
action
=
'DISABLE'
if
is_enabled
else
'ENABLE'
if
self
.
action
==
'DISABLE'
:
if
vr
.
is_enabled
:
if
is_enabled
:
self
.
quit
(
context
)
return
{
'FINISHED'
}
else
:
self
.
report
({
'ERROR'
},
"Virtual Reality Display is not enabled"
)
return
{
'CANCELLED'
}
el
se
:
#
ENABLE
if
vr
.
is_enabled
:
el
if
self
.
action
==
'
ENABLE
'
:
if
is_enabled
:
self
.
report
({
'ERROR'
},
"Virtual Reality Display is already enabled"
)
return
{
'CANCELLED'
}
...
...
@@ -93,9 +104,16 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
return
{
'RUNNING_MODAL'
}
else
:
# quit right away
wm
.
virtual_reality
.
is_enabled
=
False
vr
.
is_enabled
=
False
self
.
_quit
(
context
)
elif
self
.
action
==
'RECENTER'
:
vr
.
command_push
(
Commands
.
recenter
)
return
{
'FINISHED'
}
else
:
assert
False
,
"action
\"
{0}
\"
not implemented"
.
format
(
self
.
action
)
return
{
'CANCELLED'
}
def
quit
(
self
,
context
):
...
...
@@ -156,10 +174,28 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
return
True
def
_commands
(
self
,
context
):
"""
Process any pending command from the main window
"""
wm
=
context
.
window_manager
vr
=
wm
.
virtual_reality
while
vr
.
commands
:
command
=
vr
.
command_pop
()
if
command
==
Commands
.
recenter
:
if
self
.
_hmd
:
self
.
_hmd
.
reCenter
()
elif
command
==
Commands
.
test
:
print
(
"Testing !!!"
)
def
_loop
(
self
,
context
):
"""
Get fresh tracking data and render into the FBO
"""
self
.
_commands
(
context
)
self
.
_hmd
.
loop
(
context
)
for
i
in
range
(
2
):
...
...
@@ -209,13 +245,32 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
# Global Properties
# ############################################################
from
bpy.props
import
(
BoolProperty
,
CollectionProperty
,
EnumProperty
,
StringProperty
,
IntProperty
,
)
class
VirtualRealityCommandInfo
(
bpy
.
types
.
PropertyGroup
):
action
=
EnumProperty
(
name
=
"Action"
,
items
=
((
"NONE"
,
"None"
,
""
),
(
Commands
.
recenter
,
"Re-Center"
,
""
),
(
Commands
.
test
,
"Test"
,
""
),
),
default
=
"NONE"
,
)
class
VirtualRealityInfo
(
bpy
.
types
.
PropertyGroup
):
is_enabled
=
bpy
.
props
.
BoolProperty
(
is_enabled
=
BoolProperty
(
name
=
"Enabled"
,
default
=
False
,
)
preview_scale
=
bpy
.
props
.
IntProperty
(
preview_scale
=
IntProperty
(
name
=
"Preview Scale"
,
min
=
0
,
max
=
100
,
...
...
@@ -223,10 +278,37 @@ class VirtualRealityInfo(bpy.types.PropertyGroup):
subtype
=
'PERCENTAGE'
,
)
error_message
=
bpy
.
props
.
StringProperty
(
error_message
=
StringProperty
(
name
=
"Error Message"
,
)
tracking_mode
=
EnumProperty
(
name
=
"Tracking Mode"
,
description
=
""
,
items
=
((
"ALL"
,
"All"
,
""
),
(
"ROTATION"
,
"Rotation Only"
,
"Ignore positional tracking data"
),
(
"NONE"
,
"None"
,
"No tracking"
),
),
default
=
"ALL"
,
)
commands
=
CollectionProperty
(
type
=
VirtualRealityCommandInfo
)
def
command_push
(
self
,
action
):
command
=
self
.
commands
.
add
()
command
.
action
=
action
def
command_pop
(
self
):
command
=
self
.
commands
[
0
]
action
=
command
.
action
self
.
commands
.
remove
(
0
)
return
action
def
command_reset
(
self
):
while
self
.
commands
:
self
.
commands
.
remove
(
0
)
# ############################################################
# Callbacks
...
...
@@ -235,7 +317,10 @@ class VirtualRealityInfo(bpy.types.PropertyGroup):
@
persistent
def
virtual_reality_load_pre
(
dummy
):
wm
=
bpy
.
context
.
window_manager
wm
.
virtual_reality
.
is_enabled
=
False
vr
=
wm
.
virtual_reality
vr
.
is_enabled
=
False
vr
.
command_reset
()
@
persistent
...
...
@@ -244,6 +329,8 @@ def virtual_reality_load_post(dummy):
vr
=
wm
.
virtual_reality
vr
.
is_enabled
=
False
vr
.
command_reset
()
vr
.
error_message
=
""
...
...
@@ -256,6 +343,7 @@ def register():
bpy
.
app
.
handlers
.
load_pre
.
append
(
virtual_reality_load_post
)
bpy
.
utils
.
register_class
(
VirtualRealityDisplayOperator
)
bpy
.
utils
.
register_class
(
VirtualRealityCommandInfo
)
bpy
.
utils
.
register_class
(
VirtualRealityInfo
)
bpy
.
types
.
WindowManager
.
virtual_reality
=
bpy
.
props
.
PointerProperty
(
name
=
"virtual_reality"
,
...
...
@@ -271,4 +359,5 @@ def unregister():
bpy
.
utils
.
unregister_class
(
VirtualRealityDisplayOperator
)
del
bpy
.
types
.
WindowManager
.
virtual_reality
bpy
.
utils
.
unregister_class
(
VirtualRealityInfo
)
bpy
.
utils
.
unregister_class
(
VirtualRealityCommandInfo
)
space_view3d_virtual_reality/ui.py
View file @
30720f33
...
...
@@ -29,6 +29,12 @@ class VirtualRealityPanel(bpy.types.Panel):
col
.
label
(
text
=
vr
.
error_message
)
col
.
separator
()
col
.
operator
(
"view3d.virtual_reality_display"
,
text
=
"Re-Center"
).
action
=
'RECENTER'
col
.
separator
()
col
.
row
().
prop
(
vr
,
"tracking_mode"
,
expand
=
True
)
# ############################################################
# Un/Registration
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment