I am trying to add a simple grass texture on my imported plane. Instead of loading the full texture, it loads a solid color. Any help is appreciated.
Here is the texture:
Here is the result:
Here is my code
from direct.showbase.ShowBase import ShowBase
from direct.task.TaskManagerGlobal import taskMgr
from panda3d.core import WindowProperties, Texture, TextureStage
from panda3d.core import AmbientLight
from panda3d.core import Vec4
class Game(ShowBase):
player_x = 1
player_y = 22
player_speed = 1
def __init__(self):
ShowBase.__init__(self)
properties = WindowProperties()
properties.setSize(1000, 750)
self.win.requestProperties(properties)
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)
grass_tex = self.loader.loadTexture("Models/Misc/Untitled.jpg")
grass_tex.setWrapU(Texture.WM_repeat)
grass_tex.setWrapV(Texture.WM_repeat)
self.scene = self.loader.loadModel("Models/Misc/floor.bam")
self.scene.setTexture(grass_tex, 16)
self.scene.setTexScale(TextureStage.getDefault(), 8, 4)
self.scene.reparentTo(self.render)
self.scene.setScale(0.5, 0.5, 0.5)
self.scene.setPos(1, 22, 1)
self.updateTask = taskMgr.add(self.update, "update")
def update(self, task):
self.accept('d', self.change_x)
self.camera.setPos(self.player_x, self.player_y, 1.5)
return task.cont
def change_x(self):
self.player_x += self.player_speed
self.camera.setPos(self.player_x, self.player_y, 1.5)
game = Game()
game.run()