how to make python ursina engine's cube texture
Asked Answered
B

2

5

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.
Brachio answered 26/2, 2021 at 12:25 Comment(0)
S
6

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!

Stingo answered 31/3, 2021 at 16:35 Comment(2)
I find it often quite hard to import .obj files, but textures I can do.Stingo
Thanks for approving!Stingo
W
1

There is no such thing as ursina specific textures. When importing a texture, just use texture='cool_file' without the extension (.jpg, .png and .psd). Ursina currently supports png, jpeg and psd images (the psd-tools library must be installed since it isn't by default).

If you want to do uv mapping, you need to directly do it in a 3D software (e.g. Blender), and just import the model.

Whether answered 9/3, 2021 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.