I am new to Panda3D, fairly new to 3D, but long-time programmer, in python and in other game engines.
I am trying to put images on a wall (think museum). I want to fill the wall as much as I can but retain the aspect ratio of the image. There are about 1000 images, all with different aspect ratios.
Problem: images fill the wall but either stretch to fit or sometimes double to fit.
I created the wall in Blender, exported then converted to bam. Here is the code that places the image on the wall.
game.walls[w] = loader.loadModel("models/wall.bam") game.walls[w].setScale(6.0,1.0,3.5) game.walls[w].reparentTo(render) game.walls[w].setPos(0,6,0) ts[w] = TextureStage('ts') ts[w].setTexcoordName('0') ts[w].setMode(TextureStage.MReplace) print("image: "+str(w)+":"+images[inums[i]]) wallTex[w] = loader.loadTexture("images/"+images[inums[i]]) isizeX = wallTex[w].getXSize() isizeZ = wallTex[w].getYSize() # wallTex[w].setWrapU(Texture.WM_border_color) # wallTex[w].setWrapV(Texture.WM_border_color) asprat = (isizeX/isizeZ) print("asprat: "+str(asprat)+":"+str(asprats[i])) game.walls[w].setTexture(ts[w],wallTex[w]) wallTex[w].setBorderColor(0) game.walls[w].setTexRotate(ts[w],90) game.walls[w].setTexScale(ts[w],4,4) # game.walls[w].setTexScale(ts[w],4,4/asprats[i]) game.walls[w].setTexOffset(ts[w], 0,0.5)
I have played with many variations of TexScale and TexOffsets but apparently I don’t understand how they work. Using setWrapU just makes the whole wall black. And the size calculations are all wrong – the aspect ratios are all either 1.0 or 0.5 or 2.0, not the real aspect ratios (I tried both, no improvement).
I cannot find any zoom or stretch or way to prevent those. What am I missing?