def new_mesh(request_size): sizes = [32, 64, 96, 128, 192, 256, 384, 512, 768] size = "Donor{}".format(next(x for x in sizes if x > request_size)) logic.counter += 1 pre = logic.LibNew("GEN_{}".format(time()), "Mesh", [size]) handle = pre[0].name return handle
def get_mesh(self): mesh = self.own.meshes[0] try: base_obj = self.own.scene.objectsInactive[self.own.name] except KeyError: if self.own[PROP_NAME_LINKED]: return mesh if not hasattr(logic, "libnews"): logic.libnews = 0 mesh_name = mesh.name new_mesh = logic.LibNew(mesh_name + str(logic.libnews), "Mesh", [mesh_name])[0] self.own.replaceMesh(new_mesh) logic.libnews += 1 return new_mesh
def make_unique_mesh(mesh): """ Makes a new mesh with LibNew and returns it. :param mesh: Name of the mesh to duplicate or a pointer to the mesh to duplicate. :return: """ global lib_new_counter if isinstance(mesh, types.KX_MeshProxy): mesh = mesh.name newmesh = logic.LibNew(mesh + str(lib_new_counter), 'Mesh', [mesh])[0] lib_new_counter += 1 return newmesh
def __init__(self, font, text, size=16, align=ALIGN_LEFT, position=[0, 0, 0]): self.scene = module.scene_gui font_name = "Font." + font self._font = self.scene.objectsInactive[font_name] self.obj = self.scene.addObject(self._font, self.scene.active_camera) self.obj.worldPosition = position if font_name not in FLabel._loaded_fonts_right.keys(): mesh = logic.LibNew('Font' + str(FLabel._font_id), 'Mesh', [font_name])[0] v_array = mesh.getVertexArrayLength(0) if v_array != 4: utils.debug("Font object not valid, skipping!") return v0 = mesh.getVertex(0, 0) v1 = mesh.getVertex(0, 1) v2 = mesh.getVertex(0, 2) v3 = mesh.getVertex(0, 3) _swap_UV_2(v0, v1) _swap_UV_2(v2, v3) FLabel._loaded_fonts_right[font] = mesh FLabel._loaded_fonts_left[font] = self.obj.meshes[0] FLabel._font_id += 1 self._location = super().ProxyPosition() self._scale = super().ProxyScale() self._rotation = super().ProxyRotation() self._color = super().ProxyColor() self.transformable = [self.obj] self._align = None self._text = text self.ob2 = None #Second object to use on ALIGN_CENTER self.size = size self.align = align #It also does set text the first time.
def load(): logic.LibLoad("wall.blend","Scene") logic.LibNew('wall001','Mesh',['Monkey'])