Esempio n. 1
0
def new_state(settings):
    state = {}
    state = {"counter" : 1.0, "world" : None, "keyboard" : new_keyboard(), "interface" : None, "animations" : []}
    state.update(settings)
    state["interface"] = thing_blank(new_id(state), "Interface")
    state["world"] = new_world(state)
    return state
Esempio n. 2
0
def thing_move_read(state):
    thing = {}
    text = None
    with open("/".join([state["things_dir"], state["thing_name"]])) as f:
        text = f.read()
    map = json.loads(text)
    geometry = state["geometries"][map["geometry_name"]]
    thing = thing_new(new_id(state), "Object", map["position"], map["rotates"], [], geometry, map["bounds"])
    return thing
Esempio n. 3
0
def thing_move_read(state):
    thing = {}
    text = None
    with open("/".join([state["things_dir"], state["thing_name"]])) as f:
        text = f.read()
    map = json.loads(text)
    geometry = state["geometries"][map["geometry_name"]]
    thing = thing_new(new_id(state), "Object", map["position"], map["rotates"],
                      [], geometry, map["bounds"])
    return thing
Esempio n. 4
0
def task_new(state, name):
    task = {}
    task = {
        "id": new_id(state),
        "name": name,
        "status": "run",
        "signal_on_exit": [],
        "waiting_on": [],
        "time_start": 0.0,
        "step": 0.0,
        "animations": {}
    }
    return task
Esempio n. 5
0
def start(argv, state):
    text = None
    with open("/".join([state["animations_dir"], state["animation_name"]])) as f:
        text = f.read()
    animation = json.loads(text)
    state["animation"] = animation
    geometries = {}
    for action in animation["actions"]:
            if (action["type"] == "vertices"):
                        with open("/".join([state["geometries_dir"], action["geometry_name"]])) as f:
                            text = f.read()
                        geometry = {"vertices" : json.loads(text), "id" : new_id(state)}
                        geometries[action["geometry_name"]] = geometry
    state["geometries"] = geometries
    thing = thing_move_read(state)
    state["world"]["children"].append(thing)
    return 
Esempio n. 6
0
def start(argv, state):
    text = None
    with open("/".join([state["animations_dir"],
                        state["animation_name"]])) as f:
        text = f.read()
    animation = json.loads(text)
    state["animation"] = animation
    geometries = {}
    for action in animation["actions"]:
        if (action["type"] == "vertices"):
            with open("/".join(
                [state["geometries_dir"], action["geometry_name"]])) as f:
                text = f.read()
            geometry = {"vertices": json.loads(text), "id": new_id(state)}
            geometries[action["geometry_name"]] = geometry
    state["geometries"] = geometries
    thing = thing_move_read(state)
    state["world"]["children"].append(thing)
    return
Esempio n. 7
0
def new_world(state):
    world = {}
    world = thing_blank(new_id(state), "World")
    return world
Esempio n. 8
0
def new_world(state):
    world = {}
    world = thing_new(new_id(state), "World", [0.0, 0.0, 0.0], [], [], None)
    return world
Esempio n. 9
0
def task_new(state, name):
    task = {}
    task = {"id" : new_id(state), "name" : name, "status" : "run", "signal_on_exit" : [], "waiting_on" : [], "time_start" : 0.0, "step" : 0.0, "animations" : {}}
    return task
Esempio n. 10
0
def new_world(state):
    world = {}
    world = thing_new(new_id(state), "World", [0.0, 0.0, 0.0], [], [], None)
    return world