__init__.py 3.05 KB
Newer Older
Bruno Laurencich's avatar
Bruno Laurencich committed
1
bl_info = {
2 3
	"name": "Chordata mocap",
	"category": "Rigging",
Bruno Laurencich's avatar
Bruno Laurencich committed
4 5 6 7 8
}

# To support reload properly, try to access a package var, 
# if it's there, reload everything
if "bpy" in locals():
9
	import imp
Bruno Laurencich's avatar
Bruno Laurencich committed
10
	imp.reload(connection)
11
	imp.reload(panel)
Bruno Laurencich's avatar
Bruno Laurencich committed
12
	imp.reload(remote_runner)
13
	imp.reload(u)
Bruno Laurencich's avatar
Bruno Laurencich committed
14
	imp.reload(receive)
Bruno Laurencich's avatar
Bruno Laurencich committed
15
else:
Bruno Laurencich's avatar
Bruno Laurencich committed
16
	from . import connection
17
	from . import panel
Bruno Laurencich's avatar
Bruno Laurencich committed
18
	from . import remote_runner
19
	from . import utils as u
Bruno Laurencich's avatar
Bruno Laurencich committed
20
	from . import receive
Bruno Laurencich's avatar
Bruno Laurencich committed
21

Bruno Laurencich's avatar
Bruno Laurencich committed
22

23
import bpy
24 25 26 27 28 29 30 31
from bpy import props
from bpy.types import WindowManager
C = bpy.context

# =========================================
# =           GLOBAL PROPERTIES           =
# =========================================

32 33 34 35 36 37
def check_local_ip(self, context):
	chord_global = context.user_preferences.addons[__package__].preferences
	if chord_global.trans_method != "Multicast":
		chord_global.local_ip_addr = u.get_local_ip()

class Chord_Properties(bpy.types.AddonPreferences):
Bruno Laurencich's avatar
Bruno Laurencich committed
38
	"""A collection to hold all the global chordata properties.
39 40 41 42 43
	can be retrived at: 
	bpy.context.user_preferences.addons['<addon_name>'].preferences"""

	bl_idname = __package__

Bruno Laurencich's avatar
Bruno Laurencich committed
44
	state = props.EnumProperty(\
45
		items=u.possible_states(),\
46 47
		options={'SKIP_SAVE'}
		)
48

49 50
	trans_method = props.EnumProperty(\
		items= u.transmition_methods(), 
51 52
		default="Unicast",
		update=check_local_ip)
53 54 55

	net_submask = props.StringProperty( default = "255.255.255.0" )

Bruno Laurencich's avatar
Bruno Laurencich committed
56
	notochord_msg = props.StringProperty( default = "" )
Bruno Laurencich's avatar
Bruno Laurencich committed
57

58 59
	notochord_hostname = props.StringProperty( name="Notochord hostname", 
		description="The hostname to be used for the ip resolution", default = "notochord" )
Bruno Laurencich's avatar
Bruno Laurencich committed
60

61 62 63
	multicast_grp_addr = props.StringProperty( default = "239.0.0.1" )
	
	local_ip_addr = props.StringProperty( default = u.get_local_ip() )
64 65 66 67

	notochord_dest_port = props.IntProperty( default = 6565 )

	notochord_parameters = props.StringProperty( default = "" )
Bruno Laurencich's avatar
Bruno Laurencich committed
68

Bruno Laurencich's avatar
Bruno Laurencich committed
69 70
	notochord_ip = props.StringProperty( default = "" )

71
	last_check = props.IntProperty( default = 0 , options={'SKIP_SAVE'})
Bruno Laurencich's avatar
Bruno Laurencich committed
72 73 74

	max_ip_discover_attempts = props.IntProperty( default = 3 )

75 76 77 78 79 80 81
	receiving = props.BoolProperty(default = False , options={'SKIP_SAVE'})

	manage_notochord = props.BoolProperty( name="Manage notochord",
		description="Start the notochord when receiving, and finish it on close",  default = False )

	show_advanced = props.BoolProperty( name="Show advanced panel",  default = False )

82 83 84 85 86 87 88 89 90 91
def target_update(self, context):
	"""TODO: this function should block from selecting a non armature typed object """
	pass


class Chord_Scene_Properties(bpy.types.PropertyGroup):

	target = bpy.props.PointerProperty(name = "Source armature object",
								description="The Armature to display the capture",
								type=bpy.types.Object)#, update=target_update
92 93
# ======  End of GLOBAL PROPERTIES  =======

Bruno Laurencich's avatar
Bruno Laurencich committed
94
def register():
95 96 97
	bpy.utils.register_class(Chord_Scene_Properties)
	bpy.types.Scene.chordata = \
		bpy.props.PointerProperty(type=Chord_Scene_Properties)
98 99
	
	bpy.utils.register_module(__name__)
Bruno Laurencich's avatar
Bruno Laurencich committed
100

101 102 103
def unregister():
	# bpy.utils.unregister_class(Chord_Get_Ip)
	bpy.utils.unregister_module(__name__)
104
	# del WindowManager.chordata
105
	
Bruno Laurencich's avatar
Bruno Laurencich committed
106
if __name__ == "__main__":
107
	register()
108 109