如何制作 python ursina 引擎的立方体纹理

how to make python ursina engine's cube texture

我想知道如何在 Python Panda3D 包装器、ursina 引擎库中制作一个简单的立方体纹理。 这是我试过的代码。

from ursina import *

app = Ursina()
window.fps_counter.enabled = False


class Voxel(Button):
    def __init__(self, position=(0,0,0), texture='red.png'):
        super().__init__(
            parent = scene,
            position=position,
            model='cube',
            origin_y=0.5,
            texture=texture,
            color=color.color(0,0, random.uniform(0.9, 1.0)),
            scale = 1.0
        )


for x in range(3):
    for y in range(3):
        for z in range(3):
            voxel = Voxel(position=(x,y,z))
EditorCamera()
app.run()
  1. 我想知道怎么制作uv贴图(我做的那个很烂)。
  2. 我想知道将 uv 贴图转换为 ursina 引擎立方体纹理。

不存在ursina 特定的纹理。导入纹理时,只需使用 texture='cool_file' ,不带扩展名 .jpg.png.psd)。 Ursina 目前支持 png、jpeg 和 psd 图像(必须安装 psd-tools 库,因为它不是默认安装的)。

如果要做uv贴图,需要直接在3D软件中做(如Blender),导入模型即可。

内置纹理非常适合 Ursina 体素引擎。它们包括:

'arrow_down'
'arrow_right'
'brick'
'circle'
'circle_outlined'
'cobblestone'
'cursor'
'file_icon'
'folder'
'grass'
'heightmap_1'
'horizontal_gradient'
'noise'
'radial_gradient'
'reflection_map_3'
'shore'
'sky_default'
'sky_sunset'
'ursina_logo'
'ursina_wink_0000'
'ursina_wink_0001'
'vertical_gradient'
'white_cube'

它们都是很棒的纹理。但如果您不想使用内置纹理,请使用 .jpg .psd 或 .png 文件,但 没有文件扩展名 .

例如 My_Image.png 将被导入为...

Entity(model=cube,
       texture='My_Image')

如果您有多个同名但 不同 文件扩展名的文件,

例如 My_Image.png My_Image.jpg

两者是兼容的,它会使用目录中的第一个文件。 我希望这有帮助。如果是这样,请批准它,以便其他人可以看到它有效。它对我有用,我希望它能改进你的程序!