els*_*202 4 python 3d texture-mapping game-engine panda3d
我想知道如何在 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()
Run Code Online (Sandbox Code Playgroud)
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'
Run Code Online (Sandbox Code Playgroud)
它们都是很棒的质感。但如果您不想使用内置纹理,请使用 .jpg、.psd 或 .png 文件,但不带文件扩展名。
例如
My_Image.png将被导入为...
Entity(model=cube,
texture='My_Image')
Run Code Online (Sandbox Code Playgroud)
如果您有多个名称相同但文件扩展名不同的文件,
例如
My_Image.png
和
My_Image.jpg
并且两者兼容,它将使用目录中的第一个文件。我希望这有帮助。如果是这样,请批准此操作,以便其他人可以看到它有效。它对我有用,我希望这可以改善您的程序!