diff --git a/src/morse/builder/helpers.py b/src/morse/builder/helpers.py index aad6da7fc..c9a7623ff 100644 --- a/src/morse/builder/helpers.py +++ b/src/morse/builder/helpers.py @@ -8,22 +8,28 @@ def select_only(obj): obj.select = True bpy.context.scene.objects.active = obj +def roundv(v,r=3): + return tuple([round(e, r) for e in v]) + def do_all(): + print("base = AbstractComponent(category='props', filename='basics_wo_logic')") + meshes = [o.name for o in bpy.data.objects if o.type == 'MESH'] + print("base.append_meshes(%s)"%repr(meshes)) for obj in bpy.data.objects: - if not obj.type is 'EMPTY': - print("# warning: not an empty TODO AbstractComponent.append_meshes()") - print("# select_only(bpy.data.objects['%s'])"%obj.name) - #else: - print("bpy.ops.object.add(type='%s', location=%s, rotation=%s)" % \ - (obj.type, repr(obj.location), repr(obj.rotation_euler))) - - print("bpy.context.object.name = '%s'" % obj.name) + print("# %s : %s"%(obj.type, obj.name)) + if obj.type == 'MESH': + print("select_only(bpy.data.objects['%s'])"%obj.name) + else: + print("bpy.ops.object.add(type='%s', location=%s, rotation=%s)" % \ + (obj.type, repr(obj.location), repr(obj.rotation_euler))) + print("bpy.context.object.name = '%s'" % obj.name) + if obj.scale != (1,1,1): + print("bpy.context.object.scale = %s" % repr(obj.scale)) + print("bpy.context.object.game.physics_type = '%s'" % obj.game.physics_type) print("bpy.context.object.hide_render = %s" % obj.hide_render) - if obj.scale != (1,1,1): - print("bpy.context.object.scale = %s" % repr(obj.scale)) - print_all_logic(obj) print_properties(obj) + print_all_logic(obj) # set children - parent relationship for obj in bpy.data.objects: @@ -34,10 +40,12 @@ def do_all(): # set children - parent relationship for text in bpy.data.texts: + print("# text : %s"%text.name) print("new_text()") print("text = get_last_text()") print("text.name = '%s'" % text.name) - print("text.write(%s)" % json.dumps(text.as_string()) ) + print("text_str = %s" % json.dumps(text.as_string()) ) + print("text.write(text_str)") def get_properties(obj): @@ -76,6 +84,7 @@ def print_all_logic(obj): print("game.sensors['%s'].link(game.controllers['%s'])" % \ (brick.name, ctr.name) ) +# map the default values of game logic bricks to filter the output map_attr_default = { 'default': { '__module__': '', @@ -93,7 +102,6 @@ def print_all_logic(obj): 'use_tap': False, 'pin': False, }, - # other attributes of sensor sub-classes... 'PROPERTY': { 'evaluation_type': 'PROPEQUAL', 'property': '', @@ -114,7 +122,6 @@ def print_all_logic(obj): 'use_priority': False, 'states': 1, }, - # other attributes of controller sub-classes... 'PYTHON': { 'mode': 'SCRIPT', 'module': '', @@ -125,11 +132,9 @@ def print_all_logic(obj): 'default': { 'pin': False, }, - # other attributes of actuator sub-classes... 'VISIBILITY': { 'apply_to_children': False, 'use_occlusion': False, - 'use_visible': False, }, }, } @@ -149,30 +154,11 @@ def print_logic(brick, sca): value == map_attr_default[sca][brick.type][attr]: continue # skip default to save readibility if type(value).__name__ in ['int', 'float', 'bool']: - print("game.%ss['%s'].%s = %s" % \ - (sca, brick.name, attr, str(value)) ) + print("game.%ss[-1].%s = %s" % (sca, attr, str(value)) ) if type(value).__name__ == 'str': - print("game.%ss['%s'].%s = %s" % \ - (sca, brick.name, attr, json.dumps(value)) ) - #else: - # print("# game.%ss['%s'].%s = %s" % \ - # (sca, brick.name, attr, repr(value)) ) - - # TODO cleanup - - """ - for sca_type in ['default', brick.type]: - for attr in map_attr_default[sca][sca_type].keys(): - value = getattr(brick, attr) - if value != map_attr_default[sca][attr]: - print("game.%ss['%s'].%s = %s" % \ - (sca, brick.name, attr, str(value)) ) - """ + print("game.%ss[-1].%s = %s" % (sca, attr, json.dumps(value)) ) - -# if __name__ == '__main__': - -print("""# usage: blender -P {file} +_header = """# usage: blender -P {file} import os, sys, subprocess def ext_exec(cmd, python=None): @@ -188,18 +174,11 @@ def fix_python_path(python=None): fix_python_path() from morse.builder.bpymorse import * +from morse.builder import AbstractComponent from mathutils import Vector, Euler -""") - -do_all() - -print(""" - -# over - -""") +""" -import os, sys -# _stdout = sys.stdout -sys.stdout.flush() -sys.stdout = open(os.devnull, 'wb') +if __name__ == '__main__': + print(_header) + do_all() + print("\n\n# TODO remove the following lines (Blender output messages)\n\n") diff --git a/src/morse/builder/setup.py b/src/morse/builder/setup.py index 37f228dbc..99fde0d1b 100644 --- a/src/morse/builder/setup.py +++ b/src/morse/builder/setup.py @@ -14,6 +14,7 @@ def fix_python_path(python=None): fix_python_path() import bpy +from morse.builder import AbstractComponent from morse.builder.bpymorse import * from mathutils import Vector, Euler @@ -46,223 +47,267 @@ def setup_init(): bpy.context.scene.world.horizon_color = (0.05, 0.22, 0.4) # Display framerate and profile information of the simulation bpy.context.scene.game_settings.show_framerate_profile = True + bpy.context.scene.game_settings.show_mouse = True bpy.context.scene.render.resolution_x = 800 bpy.context.scene.render.resolution_y = 600 - # TODO camera issue, see: bpy.ops.scene.new(type='NEW') - # http://www.blender.org/documentation/blender_python_api_2_67b_release/bpy.ops.scene.html#bpy.ops.scene.new def setup_basics(): - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['CameraFP']) - bpy.ops.object.add(type='CAMERA', location=Vector((6, 0, 4.0)), rotation=Euler((1.57, 0, 1.57), 'XYZ')) + base = AbstractComponent(category='props', filename='basics_wo_logic') + base.append_meshes(['CameraID_text', 'Compass', 'HUD_plane', 'Keys_text', 'Screen', 'Screen_frame', 'Title_text']) + # CAMERA : CameraFP + bpy.ops.object.add(type='CAMERA', location=Vector((6.0, 0.0, 4.0)), rotation=Euler((1.57, 0.0, 1.57), 'XYZ')) bpy.context.object.name = 'CameraFP' bpy.context.object.game.physics_type = 'STATIC' + bpy.context.object.hide_render = False + properties(bpy.context.object, Sensitivity=0.001, Speed=0.1) game = bpy.context.object.game + add_actuator(type='SCENE', name='Set_Camera') + game.actuators[-1].mode = "CAMERA" + game.actuators[-1].name = "Set_Camera" + add_controller(type='LOGIC_AND', name='Set_Camera_cont') + game.controllers[-1].name = "cont" + game.controllers['cont'].link(actuator=game.actuators['Set_Camera']) add_controller(type='PYTHON', name='Store degfault') - game.controllers['Store degfault'].mode = "MODULE" - game.controllers['Store degfault'].module = "view_camera.store_default" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "view_camera.store_default" + game.controllers[-1].name = "Store degfault" add_controller(type='PYTHON', name='MouseLook') - game.controllers['MouseLook'].mode = "MODULE" - game.controllers['MouseLook'].module = "view_camera.rotate" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "view_camera.rotate" + game.controllers[-1].name = "MouseLook" add_controller(type='PYTHON', name='KeyboardMove') - game.controllers['KeyboardMove'].mode = "MODULE" - game.controllers['KeyboardMove'].module = "view_camera.move" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "view_camera.move" + game.controllers[-1].name = "KeyboardMove" add_sensor(type='ALWAYS', name='onLoad') + game.sensors[-1].name = "onLoad" game.sensors['onLoad'].link(game.controllers['Store degfault']) + game.sensors['onLoad'].link(game.controllers['cont']) add_sensor(type='MOUSE', name='Mouse') - game.sensors['Mouse'].mouse_event = "MOVEMENT" - game.sensors['Mouse'].use_pulse = False + game.sensors[-1].mouse_event = "MOVEMENT" + game.sensors[-1].name = "Mouse" + game.sensors[-1].use_pulse = False game.sensors['Mouse'].link(game.controllers['MouseLook']) add_sensor(type='KEYBOARD', name='All_Keys') - game.sensors['All_Keys'].key = "NONE" - game.sensors['All_Keys'].use_all_keys = True - game.sensors['All_Keys'].use_pulse_true_level = True + game.sensors[-1].key = "NONE" + game.sensors[-1].name = "All_Keys" + game.sensors[-1].use_all_keys = True + game.sensors[-1].use_pulse_true_level = True game.sensors['All_Keys'].link(game.controllers['KeyboardMove']) game.sensors['All_Keys'].link(game.controllers['MouseLook']) - properties(bpy.context.object, Sensitivity=0.001, Speed=0.1) - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['CameraID_text']) - bpy.ops.object.add(type='MESH', location=Vector((5, 0.338, 4.151)), rotation=Euler((1.57, 0, 1.57), 'XYZ')) - bpy.context.object.name = 'CameraID_text' + # MESH : CameraID_text + select_only(bpy.data.objects['CameraID_text']) bpy.context.object.game.physics_type = 'NO_COLLISION' - game = bpy.context.object.game + bpy.context.object.hide_render = True properties(bpy.context.object, Text="No camera selected") - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Compass']) - bpy.ops.object.add(type='MESH', location=Vector((-0.471, -0.312, 18.977)), rotation=Euler((0.0, 0.0, 0.0), 'XYZ')) - bpy.context.object.name = 'Compass' + game = bpy.context.object.game + # MESH : Compass + select_only(bpy.data.objects['Compass']) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = False + properties(bpy.context.object, Display=True) game = bpy.context.object.game add_controller(type='PYTHON', name='Billboard') - game.controllers['Billboard'].mode = "MODULE" - game.controllers['Billboard'].module = "billboard.reset_rotation" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "billboard.reset_rotation" + game.controllers[-1].name = "Billboard" add_controller(type='PYTHON', name='Display') - game.controllers['Display'].mode = "MODULE" - game.controllers['Display'].module = "billboard.display" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "billboard.display" + game.controllers[-1].name = "Display" add_sensor(type='ALWAYS', name='Always') - game.sensors['Always'].use_pulse_true_level = True + game.sensors[-1].name = "Always" + game.sensors[-1].use_pulse_true_level = True game.sensors['Always'].link(game.controllers['Billboard']) add_sensor(type='KEYBOARD', name='1') - game.sensors['1'].key = "ONE" - game.sensors['1'].modifier_key_1 = "LEFT_SHIFT" + game.sensors[-1].key = "ONE" + game.sensors[-1].modifier_key_1 = "LEFT_SHIFT" + game.sensors[-1].name = "1" game.sensors['1'].link(game.controllers['Display']) - properties(bpy.context.object, Display=True) - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['HUD_plane']) - bpy.ops.object.add(type='MESH', location=Vector((0.0, 0.0, 0.0)), rotation=Euler((0.0, 0.0, 0.0), 'XYZ')) - bpy.context.object.name = 'HUD_plane' + # MESH : HUD_plane + select_only(bpy.data.objects['HUD_plane']) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = True + properties(bpy.context.object, Visible=False) game = bpy.context.object.game add_actuator(type='PROPERTY', name='Toggle') - game.actuators['Toggle'].mode = "TOGGLE" - game.actuators['Toggle'].object_property = "" - game.actuators['Toggle'].property = "Visible" - game.actuators['Toggle'].value = "" + game.actuators[-1].mode = "TOGGLE" + game.actuators[-1].name = "Toggle" + game.actuators[-1].object_property = "" + game.actuators[-1].property = "Visible" + game.actuators[-1].value = "" add_actuator(type='VISIBILITY', name='Show') - game.actuators['Show'].apply_to_children = True - game.actuators['Show'].use_visible = True + game.actuators[-1].apply_to_children = True + game.actuators[-1].name = "Show" + game.actuators[-1].use_visible = True add_actuator(type='VISIBILITY', name='Hide') - game.actuators['Hide'].apply_to_children = True + game.actuators[-1].apply_to_children = True + game.actuators[-1].use_visible = False + game.actuators[-1].name = "Hide" add_controller(type='LOGIC_AND', name='And') + game.controllers[-1].name = "And" game.controllers['And'].link(actuator=game.actuators['Toggle']) add_controller(type='LOGIC_AND', name='And1') + game.controllers[-1].name = "And1" game.controllers['And1'].link(actuator=game.actuators['Show']) add_controller(type='LOGIC_NAND', name='Nand') + game.controllers[-1].name = "Nand" game.controllers['Nand'].link(actuator=game.actuators['Hide']) add_sensor(type='KEYBOARD', name='H_KEY') - game.sensors['H_KEY'].key = "H" + game.sensors[-1].key = "H" + game.sensors[-1].name = "H_KEY" game.sensors['H_KEY'].link(game.controllers['And']) add_sensor(type='PROPERTY', name='Visible') - game.sensors['Visible'].property = "Visible" - game.sensors['Visible'].value = "True" - game.sensors['Visible'].value_min = "True" + game.sensors[-1].name = "Visible" + game.sensors[-1].property = "Visible" + game.sensors[-1].value = "True" + game.sensors[-1].value_min = "True" game.sensors['Visible'].link(game.controllers['And1']) game.sensors['Visible'].link(game.controllers['Nand']) - properties(bpy.context.object, Visible=False) - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Keys_text']) - bpy.ops.object.add(type='MESH', location=Vector((-0.81, 0.3, 0.0)), rotation=Euler((0.0, 0.0, 0.0), 'XYZ')) - bpy.context.object.name = 'Keys_text' + # MESH : Keys_text + select_only(bpy.data.objects['Keys_text']) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = True + properties(bpy.context.object, Text="HUD text") game = bpy.context.object.game add_controller(type='PYTHON', name='And') - game.controllers['And'].mode = "MODULE" - game.controllers['And'].module = "hud_text.change_text" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "hud_text.change_text" + game.controllers[-1].name = "And" add_sensor(type='ALWAYS', name='Keyboard') + game.sensors[-1].name = "Keyboard" game.sensors['Keyboard'].link(game.controllers['And']) - properties(bpy.context.object, Text="HUD text") - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Scene_Script_Holder']) - bpy.ops.object.add(type='EMPTY', location=Vector((0.0, 0.0, 10.828)), rotation=Euler((0.0, 0.0, 0.0), 'XYZ')) + # EMPTY : Scene_Script_Holder + bpy.ops.object.add(type='EMPTY', location=Vector((0.0, 0.0, 10.828))) bpy.context.object.name = 'Scene_Script_Holder' + bpy.context.object.scale = Vector((0.675, 0.675, 0.675)) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = False + properties(bpy.context.object, paths_ok=True, UTMYOffset=0.0, UTMZOffset=0.0, environment_file="", UTMXOffset=0.0, Temperature="15.0") game = bpy.context.object.game - add_actuator(type='SCENE', name='Set_Camera') - game.actuators['Set_Camera'].mode = "CAMERA" add_actuator(type='GAME', name='Quit_sim') - game.actuators['Quit_sim'].filename = "" - game.actuators['Quit_sim'].mode = "QUIT" + game.actuators[-1].filename = "" + game.actuators[-1].mode = "QUIT" + game.actuators[-1].name = "Quit_sim" add_actuator(type='GAME', name='Restart_sim') - game.actuators['Restart_sim'].filename = "" - game.actuators['Restart_sim'].mode = "RESTART" - add_controller(type='LOGIC_AND', name='cont') - game.controllers['cont'].link(actuator=game.actuators['Set_Camera']) + game.actuators[-1].filename = "" + game.actuators[-1].mode = "RESTART" + game.actuators[-1].name = "Restart_sim" add_controller(type='PYTHON', name='Path') - game.controllers['Path'].mode = "MODULE" - game.controllers['Path'].module = "setup_path.test" - game.controllers['Path'].use_priority = True + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "setup_path.test" + game.controllers[-1].name = "Path" + game.controllers[-1].use_priority = True game.controllers['Path'].link(actuator=game.actuators['Quit_sim']) add_controller(type='PYTHON', name='Initialize') - game.controllers['Initialize'].mode = "MODULE" - game.controllers['Initialize'].module = "main.init" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "main.init" + game.controllers[-1].name = "Initialize" game.controllers['Initialize'].link(actuator=game.actuators['Quit_sim']) add_controller(type='PYTHON', name='Finalize') - game.controllers['Finalize'].mode = "MODULE" - game.controllers['Finalize'].module = "main.finish" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "main.finish" + game.controllers[-1].name = "Finalize" game.controllers['Finalize'].link(actuator=game.actuators['Quit_sim']) add_controller(type='PYTHON', name='Switch_Camera') - game.controllers['Switch_Camera'].mode = "MODULE" - game.controllers['Switch_Camera'].module = "main.switch_camera" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "main.switch_camera" + game.controllers[-1].name = "Switch_Camera" add_controller(type='LOGIC_AND', name='Fast_quit') + game.controllers[-1].name = "Fast_quit" game.controllers['Fast_quit'].link(actuator=game.actuators['Quit_sim']) add_controller(type='PYTHON', name='Admin') - game.controllers['Admin'].mode = "MODULE" - game.controllers['Admin'].module = "main.simulation_main" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "main.simulation_main" + game.controllers[-1].name = "Admin" game.controllers['Admin'].link(actuator=game.actuators['Quit_sim']) add_controller(type='PYTHON', name='Restart') - game.controllers['Restart'].mode = "MODULE" - game.controllers['Restart'].module = "main.restart" + game.controllers[-1].mode = "MODULE" + game.controllers[-1].module = "main.restart" + game.controllers[-1].name = "Restart" game.controllers['Restart'].link(actuator=game.actuators['Restart_sim']) add_controller(type='PYTHON', name='Import_path_script') + game.controllers[-1].name = "Import_path_script" add_sensor(type='ALWAYS', name='onLoad') - game.sensors['onLoad'].link(game.controllers['cont']) + game.sensors[-1].name = "onLoad" game.sensors['onLoad'].link(game.controllers['Path']) add_sensor(type='PROPERTY', name='paths_ok') - game.sensors['paths_ok'].property = "paths_ok" - game.sensors['paths_ok'].value = "True" - game.sensors['paths_ok'].value_min = "True" + game.sensors[-1].name = "paths_ok" + game.sensors[-1].property = "paths_ok" + game.sensors[-1].value = "True" + game.sensors[-1].value_min = "True" game.sensors['paths_ok'].link(game.controllers['Initialize']) add_sensor(type='KEYBOARD', name='ESC_KEY') - game.sensors['ESC_KEY'].key = "ESC" + game.sensors[-1].key = "ESC" + game.sensors[-1].name = "ESC_KEY" game.sensors['ESC_KEY'].link(game.controllers['Finalize']) add_sensor(type='KEYBOARD', name='F9_KEY') - game.sensors['F9_KEY'].key = "F9" + game.sensors[-1].key = "F9" + game.sensors[-1].name = "F9_KEY" game.sensors['F9_KEY'].link(game.controllers['Switch_Camera']) add_sensor(type='KEYBOARD', name='F12_KEY') - game.sensors['F12_KEY'].key = "F12" + game.sensors[-1].key = "F12" + game.sensors[-1].name = "F12_KEY" game.sensors['F12_KEY'].link(game.controllers['Fast_quit']) add_sensor(type='ALWAYS', name='Constant') - game.sensors['Constant'].use_pulse_true_level = True + game.sensors[-1].name = "Constant" + game.sensors[-1].use_pulse_true_level = True game.sensors['Constant'].link(game.controllers['Admin']) add_sensor(type='KEYBOARD', name='F11_KEY') - game.sensors['F11_KEY'].key = "F11" + game.sensors[-1].key = "F11" + game.sensors[-1].name = "F11_KEY" game.sensors['F11_KEY'].link(game.controllers['Restart']) - properties(bpy.context.object, UTMZOffset=0.0, UTMXOffset=0.0, paths_ok=True, Temperature="15.0", environment_file="", UTMYOffset=0.0) - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Screen']) - bpy.ops.object.add(type='MESH', location=Vector((4.8, 0.5, 4.3)), rotation=Euler((1.57, 0, 1.57), 'XYZ')) - bpy.context.object.name = 'Screen' + # MESH : Screen + select_only(bpy.data.objects['Screen']) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = True + properties(bpy.context.object, DisplayCamera="CameraMain", Visible=False) game = bpy.context.object.game add_actuator(type='PROPERTY', name='Toggle') - game.actuators['Toggle'].mode = "TOGGLE" - game.actuators['Toggle'].object_property = "" - game.actuators['Toggle'].property = "Visible" - game.actuators['Toggle'].value = "" + game.actuators[-1].mode = "TOGGLE" + game.actuators[-1].name = "Toggle" + game.actuators[-1].object_property = "" + game.actuators[-1].property = "Visible" + game.actuators[-1].value = "" add_actuator(type='VISIBILITY', name='Show') - game.actuators['Show'].apply_to_children = True - game.actuators['Show'].use_visible = True + game.actuators[-1].apply_to_children = True + game.actuators[-1].name = "Show" + game.actuators[-1].use_visible = True add_actuator(type='VISIBILITY', name='Hide') - game.actuators['Hide'].apply_to_children = True + game.actuators[-1].apply_to_children = True + game.actuators[-1].use_visible = False + game.actuators[-1].name = "Hide" add_controller(type='LOGIC_AND', name='And') + game.controllers[-1].name = "And" game.controllers['And'].link(actuator=game.actuators['Toggle']) add_controller(type='LOGIC_AND', name='And1') + game.controllers[-1].name = "And1" game.controllers['And1'].link(actuator=game.actuators['Show']) add_controller(type='LOGIC_NAND', name='Nand') + game.controllers[-1].name = "Nand" game.controllers['Nand'].link(actuator=game.actuators['Hide']) add_sensor(type='KEYBOARD', name='V_KEY') - game.sensors['V_KEY'].key = "V" + game.sensors[-1].key = "V" + game.sensors[-1].name = "V_KEY" game.sensors['V_KEY'].link(game.controllers['And']) add_sensor(type='PROPERTY', name='Visible') - game.sensors['Visible'].property = "Visible" - game.sensors['Visible'].value = "True" - game.sensors['Visible'].value_min = "True" + game.sensors[-1].name = "Visible" + game.sensors[-1].property = "Visible" + game.sensors[-1].value = "True" + game.sensors[-1].value_min = "True" game.sensors['Visible'].link(game.controllers['And1']) game.sensors['Visible'].link(game.controllers['Nand']) - properties(bpy.context.object, DisplayCamera="CameraMain", Visible=False) - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Screen_frame']) - bpy.ops.object.add(type='MESH', location=Vector((4.799, 0.5, 4.299)), rotation=Euler((1.57, 0, 1.57), 'XYZ')) - bpy.context.object.name = 'Screen_frame' + # MESH : Screen_frame + select_only(bpy.data.objects['Screen_frame']) bpy.context.object.game.physics_type = 'NO_COLLISION' + bpy.context.object.hide_render = True game = bpy.context.object.game - # warning: not an empty TODO AbstractComponent.append_meshes() - # select_only(bpy.data.objects['Title_text']) - bpy.ops.object.add(type='MESH', location=Vector((-0.6, 0.43, 0.0)), rotation=Euler((0.0, 0.0, 0.0), 'XYZ')) - bpy.context.object.name = 'Title_text' + # MESH : Title_text + select_only(bpy.data.objects['Title_text']) bpy.context.object.game.physics_type = 'NO_COLLISION' - game = bpy.context.object.game + bpy.context.object.hide_render = True properties(bpy.context.object, Text="MORSE keyboard shortcuts") + game = bpy.context.object.game bpy.data.objects['Compass'].parent = bpy.data.objects['CameraFP'] bpy.data.objects['HUD_plane'].parent = bpy.data.objects['CameraFP'] bpy.data.objects['Screen'].parent = bpy.data.objects['CameraFP'] @@ -270,15 +315,32 @@ def setup_basics(): bpy.data.objects['Title_text'].parent = bpy.data.objects['HUD_plane'] bpy.data.objects['CameraID_text'].parent = bpy.data.objects['Screen'] bpy.data.objects['Screen_frame'].parent = bpy.data.objects['Screen'] - new_text() - text = get_last_text() - text.name = 'Info.txt' - text.write("###########################################\n# Multi Open Robots Simulation Engine #\n###########################################\n\n\nCamera Control\n--------------\n\t\n\tDisplay help: Press the H key\n\tToggle screen on/off: Press the V key\n\t\n\tCamera controls:\n\t\tHold left CTRL + Mouse -> Look around\n\t\tW/Z, S keys -> Move forward, backward\n\t\tA/Q, D keys -> Move to the sides\n\t\tR, F keys -> Move up, down\n\t\t\n\tThe speed and sensitivity of movement can be changed by editing the Logic Properties of the CameraFP object\n\t\n\t\n\nDefault props file\n-----------------\n\nIncludes:\n\t- the Scene_Script_Holder object\n\t- the CameraFP object\n\t- the Compass object\n\t- HUD help messages\n\t- the basic scripts:\n\t\t- to initialize PYTHONPATH\n\t\t- to configure components") + # text : setup_path.py new_text() text = get_last_text() text.name = 'setup_path.py' - text.write("import sys, os\n\n\"\"\" Check that MORSE libraries are correctly installed\n\nSearches the PYTHONPATH variable for the required directories: $ORS_ROOT and $ORS_ROOT/morse/blender\n\"\"\"\n\ndef test(contr):\n print (\"==============================\")\n print (\"Welcome to the MORSE simulator\")\n print (\"==============================\")\n #print (\"\\nUsing path: {0}\\n\".format(sys.path))\n\n blender_dir = 'morse/blender'\n\n for dir in sys.path:\n if os.path.exists(os.path.join(dir, \"morse/blender/main.py\")):\n sys.path.append(os.path.join(dir, \"morse/blender\"))\n sys.path.append(os.path.join(dir, \"morse/blender/human_interaction\"))\n return\n \n print (\"MORSE ERROR: could not find the MORSE libraries. Please run 'morse check' from the command line to solve this issue.\")\n print (\"Exiting the simulation!\")\n quitActuator = contr.actuators['Quit_sim']\n contr.activate(quitActuator)") + text_str = """import sys, os + +# Check that MORSE libraries are correctly installed +# Searches the PYTHONPATH variable for the required directories: $MORSE_ROOT and $MORSE_ROOT/morse/blender +def test(contr): + print ("==============================") + print ("Welcome to the MORSE simulator") + print ("==============================") + blender_dir = 'morse/blender' + for dir in sys.path: + if os.path.exists(os.path.join(dir, "morse/blender/main.py")): + sys.path.append(os.path.join(dir, "morse/blender")) + sys.path.append(os.path.join(dir, "morse/blender/human_interaction")) + return + print ("MORSE ERROR: could not find the MORSE libraries. Please run 'morse check' from the command line to solve this issue.") + print ("Exiting the simulation!") + quitActuator = contr.actuators['Quit_sim'] + contr.activate(quitActuator) +""" + text.write(text_str) + text.use_module = True # to test with: blender -P {file} if __name__ == '__main__':