python3dgame-enginetexture-mappingpanda3d

how to make python ursina engine's cube texture


I am wondering about how to make a simple cube texture in the Python Panda3D wrapper, ursina engine library. Here's the code that I have tried.

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. I want to know how to make uv map ( one that I made is really bad ).
  2. I want to know convert uv map to ursina engine cube texture.

Solution

  • Built in textures are great for Ursina Voxel engines. They include:

    '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'
    

    They are all great textures. But if you don't want to use built in textures, use a .jpg .psd or .png file, but without the file extension.

    e.g. My_Image.png would be imported as...

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

    If you have multiple files that have the same name but different file extensions,

    e.g. My_Image.png and My_Image.jpg

    and both of them are compatible, it will use the first file in the directory. I hope this helps. If so, please approve this so others can see that it works. It worked for me and I hope this improves your programs!