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 wa3d(desc): outline = desc.get('poly') depth = desc.get('depth') fy = desc.get('fy', 0) if fy > 0: outline = [ fy - outline[i] if i % 2 == 1 else outline[i] for i in range(0, len(outline)) ] print(outline) height = desc.get('height', 1.0) depth_y = depth * math.sqrt(2.0) y0 = outline[1] - depth - height x0 = 0 z0 = -depth_y pos = (x0, y0, z0) top = (x0, y0 + height, z0) #vars.walk_areas.append (WalkAreaInfo(x0, y0 + height, z0, fy, outline[1])) color = desc.get('color', [1, 1, 1, 1]) oline = [] a0 = 0 #outline[1] for i in range(0, len(outline), 2): oline.append(outline[i] - x0) oline.append((outline[i + 1] - a0) * math.sqrt(2.0)) print(oline) pos = (0, 0, 0) e = Entity(pos=pos) e.auto_pos = True shape = sh3d.Prism(shape=sh.Poly(outline=oline), height=height, walls=desc.get('walls', [])) print(shape) e.model = {'type': 'model.shape', 'shape': shape, 'color': color} #e.add_component(ShapeGfxColor(shape=shape, color=color)) dt = monkey.engine.data.globals e.add_component( Collider(shape=shape, flag=dt.CollisionFlags.platform, mask=0, tag=dt.CollisionTags.platform)) return e