-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
101 lines (79 loc) · 2.78 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
bl_info = {
"name": "HRSDK Face Tools",
"author": "Vytas Krisciunas",
"version": (1, 0),
"blender": (2, 80, 0),
"location": "View3D > Sidebar > Face Capture",
"description": "Tool for recording animation from livelink",
"warning": "",
"wiki_url": "",
"category": "Animation",
}
import sys
import os
# Try the dependencies that are shared to have priority so it wont have conflict with existing deps
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'deps'))
import bpy
from .livelink import FaceStartPortButtonOperator, FaceSetNeutralButtonOperator, FaceToggleUpdateButtonOperator, FaceBLUpdatePose, FaceLiveLinkPanel, FaceResetNeutralButtonOperator
from .streaming import FaceConnectROS, FaceDisconnectROS, FaceResetPoseButtonOperator, FaceStartStreamButtonOperator, FaceStopStreamButtonOperator,FaceStreamPanel, FaceStreaming
from .recording import LoadCSVOperator, FaceStartRecordButtonOperator, FaceStopRecordButtonOperator, FaceRecordPanel
from .utils import props
# Initially is not saved
props['faceGlobalTimerStarted'] = False
# Global timer for viweport functions
class FaceBLGlobalTimer(bpy.types.Operator):
"""Timer Control"""
bl_label = "Global Timer"
bl_idname = 'wm.face_global_timer'
_timer = None
maxFPS = 50
def execute(self, context):
print("START GLOBAL TIMER")
wm = context.window_manager
self._timer = wm.event_timer_add(1/self.maxFPS, window=context.window)
props['faceGlobalTimerStarted'] = True
wm.modal_handler_add(self)
return {'RUNNING_MODAL'}
def modal(self, context, event):
if not props['faceGlobalTimerStarted']:
return self.cancel(context)
return {'PASS_THROUGH'}
def cancel(self, context):
if self._timer:
wm = context.window_manager
wm.event_timer_remove(self._timer)
return {'CANCELLED'}
@classmethod
def poll(cls, context):
return True
# All classes should be explicitly registered by their class name
CLASSES = (
FaceStartPortButtonOperator,
FaceStartStreamButtonOperator,
FaceStopStreamButtonOperator,
FaceConnectROS,
FaceDisconnectROS,
FaceResetPoseButtonOperator,
FaceStartRecordButtonOperator,
FaceStopRecordButtonOperator,
FaceToggleUpdateButtonOperator,
FaceSetNeutralButtonOperator,
FaceBLGlobalTimer,
FaceBLUpdatePose,
FaceLiveLinkPanel,
FaceRecordPanel,
FaceStreamPanel,
LoadCSVOperator,
FaceResetNeutralButtonOperator,
FaceStreaming
)
def register():
props.register()
for klass in CLASSES:
bpy.utils.register_class(klass)
def unregister():
props.unregister()
for klass in CLASSES:
bpy.utils.unregister_class(klass)
if __name__ == "__main__":
register()