9 locationFile = open(
'HDK_LED_locations_3rmt.csv')
10 patternFile = open(
'HDK_LED_patterns.txt')
28 locations = locationFile.readlines()
29 patterns = patternFile.readlines()
31 def setMaterial(ob, mat):
33 me.materials.append(mat)
35 def makeMaterial(name, diffuse, specular, alpha):
36 mat = bpy.data.materials.new(name)
37 mat.diffuse_color = diffuse
38 mat.diffuse_shader =
'LAMBERT'
39 mat.diffuse_intensity = 1.0
40 mat.specular_color = specular
41 mat.specular_shader =
'COOKTORR'
42 mat.specular_intensity = 0.0
50 def selectNamed(name):
51 bpy.ops.object.select_all(action=
'DESELECT')
52 myobject = bpy.data.objects[name]
53 myobject.select =
True
54 bpy.context.scene.objects.active = myobject
58 def selectObject(myObject):
59 bpy.ops.object.select_all(action=
'DESELECT')
60 myObject.select =
True
61 bpy.context.scene.objects.active = myObject
65 bright = makeMaterial(
'Bright', (1,1,1), (1,1,1), 1)
70 bpy.ops.mesh.primitive_uv_sphere_add(size = 0.25, location=(1000.0,1000.0,1000.0))
76 for location
in locations:
84 currentLocation = location.split(
",")
88 bpy.ops.object.duplicate(linked=
False)
89 setMaterial(bpy.context.object, bright)
90 bpy.ops.object.shade_smooth()
91 sphereList.append(bpy.context.scene.objects.active)
96 selectObject(sphereList[listIndex])
97 myname =
'OSVR_beacon'+str(sphereNum-1).zfill(3)
98 bpy.context.active_object.name = myname
99 bpy.context.active_object.location = (float(currentLocation[2])/10, float(currentLocation[3])/10 + sensorYOffset * float(currentLocation[5]), float(currentLocation[4])/10)
111 while rep < numRepeats:
114 while count < len(patterns[0])-1:
116 bpy.context.scene.frame_set(frameNum)
117 print(
"Handling time = ", frameNum)
126 for sphere
in sphereList:
127 selectObject(sphereList[beaconId])
128 if patterns[beaconId][count] ==
'*':
129 bpy.context.object.scale = [1.00, 1.00, 1.00]
131 bpy.context.object.scale = [0.75, 0.75, 0.75]
132 bpy.ops.anim.keyframe_insert_menu(type=
'Scaling')
138 bpy.data.scenes[
"Scene"].frame_end = frameNum