I use this code to load a cubic texture. However, after generating the texture coordinates, +Z looks along the +Y axis
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, TexturePool, LoaderOptions, TextureStage, TexGenAttrib
class TetsCubeMap(ShowBase):
def __init__(self):
ShowBase.__init__(self)
lo = LoaderOptions(flags = LoaderOptions.TF_generate_mipmaps)
texture_cube_map = Texture()
texture_cube_map.setup_cube_map()
texture_cube_map.read(fullpath = '+X.png', z = 0, n = 0, read_pages = False, read_mipmaps = False, options = lo)
texture_cube_map.read(fullpath = '-X.png', z = 1, n = 0, read_pages = False, read_mipmaps = False, options = lo)
texture_cube_map.read(fullpath = '+Y.png', z = 2, n = 0, read_pages = False, read_mipmaps = False, options = lo)
texture_cube_map.read(fullpath = '-Y.png', z = 3, n = 0, read_pages = False, read_mipmaps = False, options = lo)
texture_cube_map.read(fullpath = '+Z.png', z = 4, n = 0, read_pages = False, read_mipmaps = False, options = lo)
texture_cube_map.read(fullpath = '-Z.png', z = 5, n = 0, read_pages = False, read_mipmaps = False, options = lo)
TexturePool.add_texture(texture_cube_map)
skybox = loader.load_model('Sphere.bam')
skybox.set_tex_gen(TextureStage.get_default(), TexGenAttrib.M_world_cube_map)
skybox.set_texture(texture_cube_map)
skybox.reparent_to(render)
app = TetsCubeMap()
app.run()
Is it possible to change the direction vector of the coordinates of the cube texture so that it coincides with the render?
Add answer
skybox.set_tex_hpr(TextureStage.get_default(), (0, 90, 0))
Add thoughts
I have just discovered that the cubic texture is reflected along one axis, in other words, mirrored. Now the question arose how to return it to its normal appearance.
Add answer
It seems my productivity is on top.
skybox.set_tex_scale(TextureStage.get_default(), (1, -1))