def box(args): color = args['color'] size = args['size'] pos = args['pos'] mass = args['mass'] color = utils.hex_to_rgb(color) half_size = [size[0] * 0.5, size[1] * 0.5, size[2] * 0.5] e = Entity() e.auto_pos = True e.model = { 'type': 'model.box3D_color', 'color': [color[0], color[1], color[2], 1], 'size': size, 'offset': [-half_size[0], -half_size[1], -half_size[2]] } e.components = [{ 'type': 'bullet.rigid_body', 'pos': pos, 'mass': mass, 'shape': { 'type': 'bullet.box', 'size': half_size } }] return e
def entity(ciao): e = Entity() e.model = ciao.get('model', None) e.scale = ciao.get('scale') e.components = ciao.get('components', []) e.tag = ciao.get('tag', None) children = ciao.get('children') if children: tile_size = getattr( monkey.engine.data.globals, 'tile_size', [1, 1]) # monkey.engine.room_vars.get('tile_size', [1, 1]) for c in children: entity_desc = c positions = c.get('pos', [0, 0, 0]) if 'ref' in c: entity_desc = monkey.engine.get_asset(entity_desc, c['ref']) factory = monkey.engine.get_item_factory(entity_desc['type']) if not factory: print('Don' 't have factory for item: ' + entity_desc['type']) exit(1) for ip in range(0, len(positions), 3): pos = positions[ip:ip + 3] child = factory(entity_desc) child.pos = tiles_to_world(pos, tile_size) e.children.append(child) return e
def ramp(args): e = Entity() pos = args['pos'] e.model = { 'type': 'model.ramp3D_wireframe', 'width': args['width'], 'length': args['length'], 'height': args['height'] } e.components = [{ 'type': 'bullet.rigid_body', 'pos': pos, 'mass': 0, 'shape': { 'type': 'bullet.ramp', 'width': args['width'], 'length': args['length'], 'height': args['height'] } }] return e