如何制作Python Ursina引擎的立方体纹理



我想知道如何在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体素引擎。它们包括:

'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.pngMy_Image.jpg

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

没有什么特殊的纹理。当导入纹理时,只使用texture='cool_file'而不使用扩展名(.jpg,.png.psd)。Ursina目前支持png, jpeg和psd图像(psd-tools库必须安装,因为它不是默认的)。

如果你想做uv映射,你需要直接在3D软件中做(例如Blender),只需要导入模型。

最新更新