Hello all,
I have had problems with plane objects with png textures (meaning they are irregular shaped images with transparent background), look at the shirts in this screenshots below.
Simplepbr, lighting and setshaderauto all on, the shirts and planes with png textures are missing
Simplepbr and lighting on, setautoshader removed, they render and appear perfectly, but eveything else doesn’t.
My code:
from panda3d.core import loadPrcFile
import math
loadPrcFile("configuration.prc")
from direct.showbase.ShowBase import ShowBase
#from direct.gui.OnscreenText import OnscreenText
#from panda3d.core import Material
from panda3d.core import DirectionalLight, AmbientLight, Vec4
from panda3d.core import CollisionTraverser, CollisionHandlerPusher, CollisionSphere, CollisionNode, CollisionTube, PointLight
import simplepbr
class MyGame(ShowBase):
def __init__(self):
super().__init__()
pipeline = simplepbr.init()
self.disableMouse()
self.setFrameRateMeter(True)
self.test = self.loader.loadModel("disneyst.bam")
self.test.setScale(0.15)
self.test.reparentTo(self.render)
self.x = 0
self.y = -140
self.z = 4
self.heading = 0
self.cube = self.loader.loadModel("emiratesCube.obj")
self.cube.reparentTo(self.render)
self.camera.reparentTo(self.cube)
self.cube.setPos(self.x,self.y,self.z)
ambientLight = AmbientLight("ambient light")
ambientLight.setColor(Vec4(0.2, 0.2, 0.2, 1))
self.ambientLightNodePath = self.render.attachNewNode(ambientLight)
self.render.setLight(self.ambientLightNodePath)
mainLight = DirectionalLight("main light")
self.mainLightNodePath = self.render.attachNewNode(mainLight)
self.mainLightNodePath.setHpr(0, 0, 0)
self.render.setLight(self.mainLightNodePath)
self.render.setShaderAuto()
self.keyMap = {
"forward": False,
"backward": False,
"right": False,
"left": False,
"Rotate": False,
"lookL": False,
"lookR": False
}
self.accept("w", self.updateKeyMap, ["forward", True])
self.accept("w-up", self.updateKeyMap, ["forward", False])
self.accept("a", self.updateKeyMap, ["left", True])
self.accept("a-up", self.updateKeyMap, ["left", False])
self.accept("s", self.updateKeyMap, ["backward", True])
self.accept("s-up", self.updateKeyMap, ["backward", False])
self.accept("d", self.updateKeyMap, ["right", True])
self.accept("d-up", self.updateKeyMap, ["right", False])
self.accept("arrow_left", self.updateKeyMap, ["lookL", True])
self.accept("arrow_left-up", self.updateKeyMap, ["lookL", False])
self.accept("arrow_right", self.updateKeyMap, ["lookR", True])
self.accept("arrow_right-up", self.updateKeyMap, ["lookR", False])
self.taskMgr.add(self.update, "update")
def updateKeyMap(self, controlName, controlState):
self.keyMap[controlName] = controlState
def update(self,task):
dt = globalClock.getDt()
walkConstant = 30
rotateConstant = 50
if self.keyMap["forward"]:
self.y += walkConstant*dt*(math.cos(math.radians(self.heading)))
self.x += walkConstant*dt*(math.sin(math.radians(self.heading))) *-1
if self.keyMap["backward"]:
self.y -= walkConstant * dt * (math.cos(math.radians(self.heading)))
self.x -= walkConstant * dt * (math.sin(math.radians(self.heading))) * -1
if self.keyMap["left"]:
self.y -= walkConstant * dt * (math.cos(math.radians(self.heading-90)))
self.x -= walkConstant * dt * (math.sin(math.radians(self.heading-90))) * -1
if self.keyMap["right"]:
self.y += walkConstant * dt * (math.cos(math.radians(self.heading - 90)))
self.x += walkConstant * dt * (math.sin(math.radians(self.heading - 90))) * -1
if self.keyMap["lookL"]:
self.heading += rotateConstant*dt
if self.keyMap["lookR"]:
self.heading -= rotateConstant*dt
if self.heading > 360:
self.heading -= 360
elif self.heading < 0:
self.heading += 360
self.cube.setPos(self.x,self.y,self.z)
self.cube.setH(self.heading)
return task.cont
game = MyGame()
game.run()
Thanks in advance.