Commit 5d229ed9 authored by Dalai Felinto's avatar Dalai Felinto
Browse files

Play/Pause

parent 15e37dda
...@@ -21,18 +21,23 @@ TODO = False ...@@ -21,18 +21,23 @@ TODO = False
class Commands: class Commands:
recenter = 'RECENTER' recenter = 'RECENTER'
fullscreen = 'FULLSCREEN' fullscreen = 'FULLSCREEN'
play = 'PLAY'
pause = 'PAUSE'
test = 'TEST' test = 'TEST'
class SlaveStatus: class SlaveStatus:
non_setup = 0 # initial non_setup = 0 # initial
dupli = 1 # view3d duplicated dupli = 1 # view3d duplicated
uiless = 2 # view3d without UI uiless = 2 # view3d without UI
waituser = 3 # waiting for user to move window to HMD waituser = 3 # waiting for user to move window to HMD
usermoved = 4 # user moved window usermoved = 4 # user moved window
fullscreen = 5 # wait a bit to prevent a crash on OSX fullscreen = 5 # wait a bit to prevent a crash on OSX
ready = 6 # all went well ready = 6 # all went well
error = 7 # something didn't work play = 8 # play
pause = 9 # pause
paused = 10 # paused
error = 11 # something didn't work
# ############################################################ # ############################################################
...@@ -60,6 +65,8 @@ class VirtualRealityDisplayOperator(bpy.types.Operator): ...@@ -60,6 +65,8 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
("TOGGLE", "Toggle", "Toggle"), ("TOGGLE", "Toggle", "Toggle"),
("RECENTER", "Re-Center", "Re-Center tracking data"), ("RECENTER", "Re-Center", "Re-Center tracking data"),
("FULLSCREEN", "Fullscreen", "Make slave fullscreen"), ("FULLSCREEN", "Fullscreen", "Make slave fullscreen"),
("PLAY", "Play", ""),
("PAUSE", "Pause", ""),
), ),
default="TOGGLE", default="TOGGLE",
options={'SKIP_SAVE'}, options={'SKIP_SAVE'},
...@@ -127,6 +134,14 @@ class VirtualRealityDisplayOperator(bpy.types.Operator): ...@@ -127,6 +134,14 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
vr.command_push(Commands.fullscreen) vr.command_push(Commands.fullscreen)
return {'FINISHED'} return {'FINISHED'}
elif self.action == 'PLAY':
vr.command_push(Commands.play)
return {'FINISHED'}
elif self.action == 'PAUSE':
vr.command_push(Commands.pause)
return {'FINISHED'}
else: else:
assert False, "action \"{0}\" not implemented".format(self.action) assert False, "action \"{0}\" not implemented".format(self.action)
...@@ -234,8 +249,13 @@ class VirtualRealityDisplayOperator(bpy.types.Operator): ...@@ -234,8 +249,13 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
elif self._slave_status == SlaveStatus.fullscreen: elif self._slave_status == SlaveStatus.fullscreen:
context.window_manager.virtual_reality.is_slave_setup = False context.window_manager.virtual_reality.is_slave_setup = False
ok = self._init(context) ok = self._init(context)
elif self._slave_status == SlaveStatus.play:
self._slave_status = SlaveStatus.ready self._slave_status = SlaveStatus.ready
elif self._slave_status == SlaveStatus.pause:
self._slave_status = SlaveStatus.paused
else: else:
assert False, "_slaveSetup: Slave status \"{0}\" not defined".format(self._slave_status) assert False, "_slaveSetup: Slave status \"{0}\" not defined".format(self._slave_status)
...@@ -301,6 +321,14 @@ class VirtualRealityDisplayOperator(bpy.types.Operator): ...@@ -301,6 +321,14 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
self._slave_status = SlaveStatus.usermoved self._slave_status = SlaveStatus.usermoved
self._slaveSetup(context) self._slaveSetup(context)
elif command == Commands.play:
self._slave_status = SlaveStatus.play
self._slaveSetup(context)
elif command == Commands.pause:
self._slave_status = SlaveStatus.pause
self._slaveSetup(context)
elif command == Commands.test: elif command == Commands.test:
print("Testing !!!") print("Testing !!!")
...@@ -345,6 +373,9 @@ class VirtualRealityDisplayOperator(bpy.types.Operator): ...@@ -345,6 +373,9 @@ class VirtualRealityDisplayOperator(bpy.types.Operator):
if self._slave_status == SlaveStatus.ready: if self._slave_status == SlaveStatus.ready:
self._loop(context) self._loop(context)
elif self._slave_status == SlaveStatus.paused:
return
elif self._slave_status == SlaveStatus.waituser: elif self._slave_status == SlaveStatus.waituser:
self._drawDisplayMessage(context) self._drawDisplayMessage(context)
...@@ -435,6 +466,8 @@ class VirtualRealityCommandInfo(bpy.types.PropertyGroup): ...@@ -435,6 +466,8 @@ class VirtualRealityCommandInfo(bpy.types.PropertyGroup):
items=(("NONE", "None", ""), items=(("NONE", "None", ""),
(Commands.recenter, "Re-Center", ""), (Commands.recenter, "Re-Center", ""),
(Commands.fullscreen, "Fullscreen", ""), (Commands.fullscreen, "Fullscreen", ""),
(Commands.play, "Play", ""),
(Commands.pause, "Pause", ""),
(Commands.test, "Test", ""), (Commands.test, "Test", ""),
), ),
default="NONE", default="NONE",
......
...@@ -20,7 +20,7 @@ class VirtualRealityPanel(bpy.types.Panel): ...@@ -20,7 +20,7 @@ class VirtualRealityPanel(bpy.types.Panel):
col = layout.column() col = layout.column()
if not vr.is_enabled: if not vr.is_enabled:
col.operator("view3d.virtual_reality_display", text="Virtual Reality", icon="PLAY").action='ENABLE' col.operator("view3d.virtual_reality_display", text="Virtual Reality").action='ENABLE'
else: else:
col.operator("view3d.virtual_reality_display", text="Virtual Reality", icon="X").action='DISABLE' col.operator("view3d.virtual_reality_display", text="Virtual Reality", icon="X").action='DISABLE'
col.separator() col.separator()
...@@ -29,6 +29,10 @@ class VirtualRealityPanel(bpy.types.Panel): ...@@ -29,6 +29,10 @@ class VirtualRealityPanel(bpy.types.Panel):
col.operator("view3d.virtual_reality_display", text="Start", icon="CAMERA_STEREO").action='FULLSCREEN' col.operator("view3d.virtual_reality_display", text="Start", icon="CAMERA_STEREO").action='FULLSCREEN'
else: else:
row = col.row(align=True)
row.operator("view3d.virtual_reality_display", text="Play", icon="PLAY").action='PLAY'
row.operator("view3d.virtual_reality_display", text="Pause", icon="PAUSE").action='PAUSE'
row = col.row() row = col.row()
row.prop(vr, "use_preview") row.prop(vr, "use_preview")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment