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
a1afffb1
Commit
a1afffb1
authored
Oct 07, 2015
by
Dalai Felinto
Browse files
Projection Matrix
parent
f5131b34
Changes
4
Hide whitespace changes
Inline
Side-by-side
space_view3d_virtual_reality/hmd/__init__.py
View file @
a1afffb1
...
...
@@ -75,11 +75,19 @@ class HMD_Base:
@
property
def
width
(
self
):
return
self
.
_width
return
self
.
_width
[
self
.
_current_eye
]
@
width
.
setter
def
width
(
self
,
value
):
self
.
_width
[
self
.
_current_eye
]
=
value
@
property
def
height
(
self
):
return
self
.
_height
return
self
.
_height
[
self
.
_current_eye
]
@
height
.
setter
def
height
(
self
,
value
):
self
.
_height
[
self
.
_current_eye
]
=
value
@
property
def
offscreen_object
(
self
):
...
...
@@ -97,6 +105,18 @@ class HMD_Base:
def
projection_matrix
(
self
):
return
self
.
_projection_matrix
[
self
.
_current_eye
]
@
projection_matrix
.
setter
def
projection_matrix
(
self
,
value
):
print
(
"projection_matrix"
,
value
)
matrix
=
Matrix
()
matrix
[
0
]
=
value
[
0
:
4
]
matrix
[
1
]
=
value
[
4
:
8
]
matrix
[
2
]
=
value
[
8
:
12
]
matrix
[
3
]
=
value
[
12
:
16
]
self
.
_projection_matrix
[
self
.
_current_eye
]
=
matrix
@
property
def
modelview_matrix
(
self
):
return
self
.
_modelview_matrix
[
self
.
_current_eye
]
...
...
@@ -104,15 +124,6 @@ class HMD_Base:
def
setEye
(
self
,
eye
):
self
.
_current_eye
=
int
(
bool
(
eye
))
def
isConnected
(
self
):
"""
Check if device is connected
:return: return True if the device is connected
:rtype: bool
"""
assert
False
,
"isConnected() not implemented for the
\"
{0}
\"
device"
.
format
(
self
.
_name
)
def
init
(
self
):
"""
Initialize device
...
...
@@ -122,7 +133,7 @@ class HMD_Base:
"""
try
:
for
i
in
range
(
2
):
self
.
_offscreen_object
[
i
]
=
gpu
.
offscreen_object_create
(
self
.
_width
,
self
.
_height
)
self
.
_offscreen_object
[
i
]
=
gpu
.
offscreen_object_create
(
self
.
_width
[
i
]
,
self
.
_height
[
i
]
)
self
.
_framebuffer_object
[
i
]
=
self
.
_offscreen_object
[
i
].
framebuffer_object
self
.
_color_object
[
i
]
=
self
.
_offscreen_object
[
i
].
color_object
...
...
@@ -185,3 +196,13 @@ class HMD_Base:
"""
TODO
def
_getCamera
(
self
,
context
):
return
context
.
scene
.
camera
def
_getCameraClipping
(
self
,
context
):
camera_ob
=
self
.
_getCamera
(
context
)
camera
=
camera_ob
.
data
near
=
camera
.
clip_start
far
=
camera
.
clip_end
return
near
,
far
space_view3d_virtual_reality/hmd/debug.py
View file @
a1afffb1
...
...
@@ -18,17 +18,7 @@ class Debug(HMD_Base):
def
__init__
(
self
,
error_callback
):
super
(
Debug
,
self
).
__init__
(
'Debug'
,
error_callback
)
def
isConnected
(
self
):
"""
Check if device is connected
:return: return True if the device is connected
:rtype: bool
"""
print_debug
(
'isConnected()'
)
return
True
def
init
(
self
):
def
init
(
self
,
context
):
"""
Initialize device
...
...
@@ -37,8 +27,8 @@ class Debug(HMD_Base):
"""
print_debug
(
'init()'
)
self
.
_width
=
512
self
.
_height
=
512
self
.
_width
=
[
512
,
512
]
self
.
_height
=
[
512
,
512
]
return
super
(
Debug
,
self
).
init
()
...
...
space_view3d_virtual_reality/hmd/oculus.py
View file @
a1afffb1
...
...
@@ -25,22 +25,21 @@ class Oculus(HMD_Base):
super
(
Oculus
,
self
).
__init__
(
'Oculus'
,
error_callback
)
checkModule
(
'oculus_sdk_bridge'
)
def
isConnected
(
self
):
"""
Check if device is connected
# self._debug()
:return: return True if the device is connected
:rtype: bool
"""
try
:
from
bridge.oculus
import
HMD
return
HMD
.
isConnected
()
def
_debug
(
self
):
import
bridge
import
bridge_wrapper
except
Exception
as
E
:
self
.
error
(
"isConnected"
,
E
,
True
)
return
False
input
=
3
device
=
bridge_wrapper
.
Debug_new
(
input
)
factor
=
bridge_wrapper
.
Debug_multiplicationFactor
()
print
(
"Multiplication factor is {0}"
.
format
(
factor
))
output
=
bridge_wrapper
.
Debug_multiplicationResult
(
device
)
print
(
"Return of {0} is {1}"
.
format
(
input
,
output
))
def
init
(
self
):
def
init
(
self
,
context
):
"""
Initialize device
...
...
@@ -52,12 +51,18 @@ class Oculus(HMD_Base):
self
.
_hmd
=
HMD
()
# gather arguments from HMD
self
.
_width
[
0
]
=
self
.
_hmd
.
width_left
self
.
_height
[
0
]
=
self
.
_hmd
.
height_left
self
.
_width
[
1
]
=
self
.
_hmd
.
width_right
self
.
_height
[
1
]
=
self
.
_hmd
.
height_right
self
.
_projection_matrix
[
0
]
=
self
.
_hmd
.
projection_matrix_left
self
.
_projection_matrix
[
1
]
=
self
.
_hmd
.
projection_matrix_right
near
,
far
=
self
.
_getCameraClipping
(
context
)
self
.
setEye
(
0
)
self
.
width
=
self
.
_hmd
.
width_left
self
.
height
=
self
.
_hmd
.
height_left
self
.
projection_matrix
=
self
.
_hmd
.
getProjectionMatrixLeft
(
near
,
far
)
self
.
setEye
(
1
)
self
.
width
=
self
.
_hmd
.
width_right
self
.
height
=
self
.
_hmd
.
height_right
self
.
projection_matrix
=
self
.
_hmd
.
getProjectionMatrixRight
(
near
,
far
)
# initialize FBO
super
(
Oculus
,
self
).
init
()
...
...
@@ -89,7 +94,7 @@ class Oculus(HMD_Base):
super
(
Oculus
,
self
).
loop
(
context
)
except
Exception
as
E
:
self
.
error
(
"loo
k
"
,
E
,
False
)
self
.
error
(
"loo
p
"
,
E
,
False
)
return
False
return
True
...
...
space_view3d_virtual_reality/operator.py
View file @
a1afffb1
...
...
@@ -136,18 +136,11 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
self
.
_hmd
=
HMD
(
display_backend
,
self
.
_error_callback
)
self
.
_preview
=
Preview
()
if
not
self
.
_hmd
.
isConnected
():
self
.
report
({
'ERROR'
},
"Device not connected"
)
return
False
if
not
self
.
_hmd
.
init
():
if
not
self
.
_hmd
.
init
(
context
):
self
.
report
({
'ERROR'
},
"Error initializing device"
)
return
False
# get the data from device
width
=
self
.
_hmd
.
width
height
=
self
.
_hmd
.
height
color_object
=
[
0
,
0
]
for
i
in
range
(
2
):
self
.
_hmd
.
setEye
(
i
)
...
...
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