I made a textured model in blender, and I imported it fine with this code:
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import OnscreenText
from direct.showbase.DirectObject import DirectObject
class World(DirectObject):
def __init__(self):
self.LoadTerrain()
self.LoadLight()
self.LoadCamera()
def LoadTerrain(self):
texture = EggTexture("")
self.counter = loader.loadModel('greencube.egg')
self.counter.reparentTo(render)
base.setBackgroundColor(0.0,0.0,0.3)
def LoadLight(self):
plight = AmbientLight('my plight')
plight.setColor(VBase4(0.12, 0.12, 0.12, 1))
plnp = render.attachNewNode(plight)
render.setLight(plnp)
light2 = PointLight('pointlight')
plnp2 = render.attachNewNode(light2)
plnp2.setPos(2,2,2)
render.setLight(plnp2)
def LoadCamera(self):
base.camera.setPos(4,-10,10)
base.camera.lookAt(self.counter)
mat=Mat4(camera.getMat())
mat.invertInPlace()
base.mouseInterfaceNode.setMat(mat)
if __name__ == "__main__":
w = World()
run()
The model loads in fine, but it has no texture. I know I have not loaded the texture in there, but I don’t know how. I have thought about putting in
texture = EggTexture()
but since there is no
def generateEgg(self)
part, it wouldn’t work. But this wouldn’t fit in with my other code…
Can somebody describe to me what I should do? Thanks in advance