Skip to content

Commit

Permalink
[builder] add helper to convert .blend to pure py
Browse files Browse the repository at this point in the history
at least logic and empty objects (for now)

add setup replacing basics.blend (logic part)
reload morse.core.blenderapi in setup fix morse-simulator#405
remove MouseSensor.use_pulse, was not in 2.63
set render fps to 25 (default:24)
import at the top
  • Loading branch information
PierrickKoch committed Jan 15, 2014
1 parent 1faa537 commit 35e1edb
Show file tree
Hide file tree
Showing 4 changed files with 541 additions and 28 deletions.
27 changes: 0 additions & 27 deletions src/morse/builder/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,3 @@ def __init__(self, name="ActuatorCreator", classpath="morse.core.actuator.Actuat
blendname=None):
ComponentCreator.__init__(self, name, 'actuators', blendname)
self.properties(Component_Tag = True, classpath = classpath)

# helpers

def get_properties_str(name):
""" Returns the Game properties of the Blender object represented by the name
get_properties_str('Sick') gives
laser_range = 30.0, Component_Tag = True, scan_window = 180.0,
Visible_arc = True, resolution = 0.25,
classpath = 'morse.sensors.sick.LaserScannerClass'
"""
obj = bpymorse.get_object(name)
properties_dictionary = get_properties(obj)
return ", ".join(["%s = %s"%(pname, properties_dictionary[pname]) \
for pname in properties_dictionary])

def get_properties(obj):
import json
properties_dictionary = {}
properties = obj.game.properties
for name in properties.keys():
properties_dictionary[name] = properties[name].value
if properties[name].type == 'TIMER':
properties_dictionary[name] = "timer(%f)"%properties_dictionary[name]
elif type(properties_dictionary[name]) is str:
properties_dictionary[name] = json.dumps(properties_dictionary[name])
return properties_dictionary
3 changes: 2 additions & 1 deletion src/morse/builder/environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging; logger = logging.getLogger("morsebuilder." + __name__)
import os
import json
import morse.builder.setup
from morse.builder.morsebuilder import *
from morse.builder.abstractcomponent import Configuration
from morse.core.morse_time import TimeStrategies
Expand Down Expand Up @@ -269,7 +270,7 @@ def create(self, name=None):
# define 'Scene_Script_Holder' as the blender object of Enrivonment
if not 'Scene_Script_Holder' in bpymorse.get_objects():
# Add the necessary objects
base = Component('props', 'basics')
morse.builder.setup.init_morse()

# Set Scene_Script_Holder as core Environment object
self.set_blender_object(bpymorse.get_object('Scene_Script_Holder'))
Expand Down
Loading

0 comments on commit 35e1edb

Please sign in to comment.