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
a6a2274f
Commit
a6a2274f
authored
Oct 19, 2015
by
Dalai Felinto
Browse files
Rename: offscreen_object > offscreen and color_object > color_texture
parent
2fdd7617
Changes
4
Hide whitespace changes
Inline
Side-by-side
space_view3d_virtual_reality/hmd/__init__.py
View file @
a6a2274f
...
...
@@ -58,8 +58,8 @@ class HMD_Base:
"_head_transformation"
,
"_is_direct_mode"
,
"_eye_pose"
,
"_offscreen
_object
"
,
"_color_
object
"
,
"_offscreen"
,
"_color_
texture
"
,
"_modelview_matrix"
,
"_near"
,
"_far"
,
...
...
@@ -74,8 +74,8 @@ class HMD_Base:
self
.
_height
=
[
0
,
0
]
self
.
_projection_matrix
=
[
Matrix
.
Identity
(
4
),
Matrix
.
Identity
(
4
)]
self
.
_modelview_matrix
=
[
Matrix
.
Identity
(
4
),
Matrix
.
Identity
(
4
)]
self
.
_color_
object
=
[
0
,
0
]
self
.
_offscreen
_object
=
[
None
,
None
]
self
.
_color_
texture
=
[
0
,
0
]
self
.
_offscreen
=
[
None
,
None
]
self
.
_eye_orientation_raw
=
[[
1.0
,
0.0
,
0.0
,
0.0
],
[
1.0
,
0.0
,
0.0
,
0.0
]]
self
.
_eye_position_raw
=
[[
0.0
,
0.0
,
0.0
],
[
0.0
,
0.0
,
0.0
]]
self
.
_scale
=
self
.
_calculateScale
(
context
)
...
...
@@ -103,13 +103,12 @@ class HMD_Base:
self
.
_height
[
self
.
_current_eye
]
=
value
@
property
def
offscreen
_object
(
self
):
return
self
.
_offscreen
_object
[
self
.
_current_eye
]
def
offscreen
(
self
):
return
self
.
_offscreen
[
self
.
_current_eye
]
@
property
@
property
def
color_object
(
self
):
return
self
.
_color_object
[
self
.
_current_eye
]
def
color_texture
(
self
):
return
self
.
_color_texture
[
self
.
_current_eye
]
@
property
def
projection_matrix
(
self
):
...
...
@@ -131,13 +130,13 @@ class HMD_Base:
"""
try
:
for
i
in
range
(
2
):
self
.
_offscreen
_object
[
i
]
=
gpu
.
offscreen
.
new
(
self
.
_width
[
i
],
self
.
_height
[
i
],
0
)
self
.
_color_
object
[
i
]
=
self
.
_offscreen
_object
[
i
].
color_
object
self
.
_offscreen
[
i
]
=
gpu
.
offscreen
.
new
(
self
.
_width
[
i
],
self
.
_height
[
i
],
0
)
self
.
_color_
texture
[
i
]
=
self
.
_offscreen
[
i
].
color_
texture
except
Exception
as
E
:
print
(
E
)
self
.
_offscreen
_object
[
0
]
=
None
self
.
_offscreen
_object
[
1
]
=
None
self
.
_offscreen
[
0
]
=
None
self
.
_offscreen
[
1
]
=
None
return
False
else
:
...
...
@@ -171,7 +170,7 @@ class HMD_Base:
"""
try
:
for
i
in
range
(
2
):
self
.
_offscreen
_object
[
i
]
=
None
self
.
_offscreen
[
i
]
=
None
except
Exception
as
E
:
print
(
E
)
...
...
space_view3d_virtual_reality/hmd/oculus.py
View file @
a6a2274f
...
...
@@ -77,7 +77,7 @@ class Oculus(HMD_Base):
return
True
def
_setup
(
self
):
return
self
.
_hmd
.
setup
(
self
.
_color_
object
[
0
],
self
.
_color_
object
[
1
])
return
self
.
_hmd
.
setup
(
self
.
_color_
texture
[
0
],
self
.
_color_
texture
[
1
])
def
loop
(
self
,
context
):
"""
...
...
space_view3d_virtual_reality/operator.py
View file @
a6a2274f
...
...
@@ -266,12 +266,12 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
return
False
# get the data from device
color_
object
=
[
0
,
0
]
color_
texture
=
[
0
,
0
]
for
i
in
range
(
2
):
self
.
_hmd
.
setEye
(
i
)
color_
object
[
i
]
=
self
.
_hmd
.
color_
object
color_
texture
[
i
]
=
self
.
_hmd
.
color_
texture
self
.
_preview
.
init
(
color_
object
[
0
],
color_
object
[
1
])
self
.
_preview
.
init
(
color_
texture
[
0
],
color_
texture
[
1
])
return
True
def
_slaveSetup
(
self
,
context
):
...
...
@@ -409,15 +409,15 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
for
i
in
range
(
2
):
self
.
_hmd
.
setEye
(
i
)
offscreen
_object
=
self
.
_hmd
.
offscreen
_object
offscreen
=
self
.
_hmd
.
offscreen
projection_matrix
=
self
.
_hmd
.
projection_matrix
modelview_matrix
=
self
.
_hmd
.
modelview_matrix
# drawing
try
:
offscreen
_object
.
draw_view3d
(
projection_matrix
,
modelview_matrix
)
offscreen
.
draw_view3d
(
projection_matrix
,
modelview_matrix
)
except
:
offscreen
_object
.
draw_view3d
(
scene
,
view3d
,
region
,
projection_matrix
,
modelview_matrix
)
offscreen
.
draw_view3d
(
scene
,
view3d
,
region
,
projection_matrix
,
modelview_matrix
)
self
.
_hmd
.
frameReady
()
self
.
_is_rendering
=
False
...
...
space_view3d_virtual_reality/preview.py
View file @
a6a2274f
...
...
@@ -16,20 +16,20 @@ from bgl import *
class
Preview
:
__slots__
=
{
"_color_
object
_left"
,
"_color_
object
_right"
,
"_color_
texture
_left"
,
"_color_
texture
_right"
,
}
def
init
(
self
,
color_
object
_left
,
color_
object
_right
):
def
init
(
self
,
color_
texture
_left
,
color_
texture
_right
):
"""
Initialize preview window
:param color_
object
_left: 2D Texture binding ID (bind to the Framebuffer Object) for left eye
:type color_
object
_left: bgl.GLuint
:param color_
object
_right: 2D Texture binding ID (bind to the Framebuffer Object) for right eye
:type color_
object
_right: bgl.GLuint
:param color_
texture
_left: 2D Texture binding ID (bind to the Framebuffer Object) for left eye
:type color_
texture
_left: bgl.GLuint
:param color_
texture
_right: 2D Texture binding ID (bind to the Framebuffer Object) for right eye
:type color_
texture
_right: bgl.GLuint
"""
self
.
update
(
color_
object
_left
,
color_
object
_right
)
self
.
update
(
color_
texture
_left
,
color_
texture
_right
)
def
quit
(
self
):
"""
...
...
@@ -37,17 +37,17 @@ class Preview:
"""
pass
def
update
(
self
,
color_
object
_left
,
color_
object
_right
):
def
update
(
self
,
color_
texture
_left
,
color_
texture
_right
):
"""
Update OpenGL binding textures
:param color_
object
_left: 2D Texture binding ID (bind to the Framebuffer Object) for left eye
:type color_
object
_left: bgl.GLuint
:param color_
object
_right: 2D Texture binding ID (bind to the Framebuffer Object) for right eye
:type color_
object
_right: bgl.GLuint
:param color_
texture
_left: 2D Texture binding ID (bind to the Framebuffer Object) for left eye
:type color_
texture
_left: bgl.GLuint
:param color_
texture
_right: 2D Texture binding ID (bind to the Framebuffer Object) for right eye
:type color_
texture
_right: bgl.GLuint
"""
self
.
_color_
object
_left
=
color_
object
_left
self
.
_color_
object
_right
=
color_
object
_right
self
.
_color_
texture
_left
=
color_
texture
_left
self
.
_color_
texture
_right
=
color_
texture
_right
def
_drawRectangle
(
self
,
eye
):
...
...
@@ -92,10 +92,10 @@ class Preview:
glEnable
(
GL_TEXTURE_2D
)
glActiveTexture
(
GL_TEXTURE0
)
glBindTexture
(
GL_TEXTURE_2D
,
self
.
_color_
object
_left
)
glBindTexture
(
GL_TEXTURE_2D
,
self
.
_color_
texture
_left
)
self
.
_drawRectangle
(
0
)
glBindTexture
(
GL_TEXTURE_2D
,
self
.
_color_
object
_right
)
glBindTexture
(
GL_TEXTURE_2D
,
self
.
_color_
texture
_right
)
self
.
_drawRectangle
(
1
)
glBindTexture
(
GL_TEXTURE_2D
,
act_tex
[
0
])
...
...
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