noob texture problem

I feel like I’m missing something obvious here… I’m brand new to Panda3D, so please do bear with me, and feel free to move this thread if it’s in the wrong forum.

I’m trying to set up a very simple scene, mostly stripped from the tutorial with a few elements changed/added. Using Blender 2.66 and YABEE 13.1, I’ve exported a very simple cube (in fact, it’s the cube that Blender starts up with by default, completely unmodified, no texture) to an .egg file. I then load the model in Panda, apply a texture from a 128x128 bmp file using setTexture(), and run the program. The model appears completely monochrome, white or gray where my single directional light hits it, and pure, featureless black where no light hits it. I’ve been monkeying around for a little while, adding/removing/adjusting lights etc. If there’s no light in the scene, the cube appears pure black. I’m at a little bit of a loss as to what’s causing this, and I’m hoping someone might have a minute to address this noob question.

Here’s my code:

from math import pi, sin, cos
import sys

import direct.directbase.DirectStart

from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
from direct.actor.Actor import Actor
from direct.interval.IntervalGlobal import Sequence
from panda3d.core import Point3
from panda3d.core import Vec3,Vec4,BitMask32
from panda3d.core import Texture, PointLight, DirectionalLight, VBase4



class MyApp(ShowBase):

	def __init__(self):
		ShowBase.__init__(self)
		
		self.environ = self.loader.loadModel("environment")
		self.environ.reparentTo(self.render)
		
		self.environ.setScale(0.25, 0.25, 0.25)
		self.environ.setPos(-8, 42, 0)
		
		self.wall = self.loader.loadModel("cube")
		self.wall.reparentTo(self.render)
		
		self.wall.setScale(1, 1, 1)
		self.wall.setPos(-10, 10, 30)
		
		wall_tex = loader.loadTexture("wall_128.bmp")
		wall_tex.setWrapU(Texture.WMRepeat)
		wall_tex.setWrapV(Texture.WMRepeat)
		self.wall.setTexture(wall_tex)
		
		
		dlight = DirectionalLight('dlight')
		dlight.setColor(VBase4(1, 1, 1, 1))
		dlnp = render.attachNewNode(dlight)
		dlnp.setHpr(0, -60, 0)
		render.setLight(dlnp)
		
		
		base.disableMouse()
		
		self.mouse_x = 0
		self.mouse_y = 0
		
		self.keyMap = {"speed": 0, "left":0, "right":0, "forward":0, "backward":0, "up":0, "down":0, "cam-left":0, "cam-right":0}
		
		self.accept("a", self.setKey, ["cam-left",1])
		self.accept("d", self.setKey, ["cam-right",1])
		self.accept("w", self.setKey, ["forward", 1])
		self.accept("s", self.setKey, ["backward", 1])
		self.accept("space", self.setKey, ["up", 1])
		self.accept("c", self.setKey, ["down", 1])
		self.accept("shift", self.setKey, ["speed", 1])
		
		self.accept("a-up", self.setKey, ["cam-left",0])
		self.accept("d-up", self.setKey, ["cam-right",0])
		self.accept("w-up", self.setKey, ["forward", 0])
		self.accept("s-up", self.setKey, ["backward", 0])
		self.accept("space-up", self.setKey, ["up", 0])
		self.accept("c-up", self.setKey, ["down", 0])
		self.accept("shift-up", self.setKey, ["speed", 0])
		
		self.accept("escape", sys.exit)
		
		taskMgr.add(self.move,"moveTask")
		taskMgr.add(self.mouse_cam, "mouse_cam")
		
		base.camera.setPos(20 , -20.0 , 20)
		base.camera.setHpr(0, 0, 0)
		
	
	def setKey(self, key, value):
		self.keyMap[key] = value
		
	def mouse_cam(self, task):
		if base.mouseWatcherNode.hasMouse():
			
			x = base.mouseWatcherNode.getMouseX()
			y = base.mouseWatcherNode.getMouseY()
			
			
			angle_x = x * -180
			angle_y = y * 180
			
			self.mouse_x += angle_x
			self.mouse_y += angle_y
			
			
			base.camera.setHpr(self.mouse_x, self.mouse_y, 0)
			base.win.movePointer(0, 400, 300)
			
			return task.cont
		else:
			return task.cont
			
	def move(self, task):
		speed = 50
		
		if (self.keyMap["speed"] != 0):
			speed = 200
		
		if (self.keyMap["cam-left"]!=0):
			base.camera.setX(base.camera, -speed * globalClock.getDt())
		if (self.keyMap["cam-right"]!=0):
			base.camera.setX(base.camera, +speed * globalClock.getDt())
		if (self.keyMap["forward"] != 0):
			base.camera.setY(base.camera, +speed * globalClock.getDt())
		if (self.keyMap["backward"] != 0):
			base.camera.setY(base.camera, -speed * globalClock.getDt())
		if (self.keyMap["up"] != 0):
			base.camera.setZ(base.camera, +speed * globalClock.getDt())
		if (self.keyMap["down"] != 0):
			base.camera.setZ(base.camera, -speed * globalClock.getDt())
		
		
		return task.cont



app = MyApp()
app.run()

Here’s the .egg file:

<CoordinateSystem> { Z-up } 
<Material> Material {
  <Scalar> diffr { 0.640000 }
  <Scalar> diffg { 0.640000 }
  <Scalar> diffb { 0.640000 }
  <Scalar> specr { 0.500000 }
  <Scalar> specg { 0.500000 }
  <Scalar> specb { 0.500000 }
  <Scalar> shininess { 12.5 }
  <Scalar> emitr { 0.000000 }
  <Scalar> emitg { 0.000000 }
  <Scalar> emitb { 0.000000 }
}

  <Group> Cube {
    <Transform> {
      <Matrix4> {
        1.000000 0.000000 0.000000 0.000000 
        0.000000 1.000000 0.000000 0.000000 
        0.000000 0.000000 1.000000 0.000000 
        0.000000 0.000000 0.000000 1.000000 
      }
    }
    
    <VertexPool> Cube {
    
      <Vertex> 0 {
        1.0 0.9999999403953552 -1.0
      }
      <Vertex> 1 {
        1.0 -1.0 -1.0
      }
      <Vertex> 2 {
        -1.0000001192092896 -0.9999998211860657 -1.0
      }
      <Vertex> 3 {
        -0.9999996423721313 1.0000003576278687 -1.0
      }
      <Vertex> 4 {
        1.0000004768371582 0.999999463558197 1.0
      }
      <Vertex> 5 {
        -0.9999999403953552 1.0 1.0
      }
      <Vertex> 6 {
        -1.0000003576278687 -0.9999996423721313 1.0
      }
      <Vertex> 7 {
        0.9999993443489075 -1.0000005960464478 1.0
      }
      <Vertex> 8 {
        1.0 0.9999999403953552 -1.0
      }
      <Vertex> 9 {
        1.0000004768371582 0.999999463558197 1.0
      }
      <Vertex> 10 {
        0.9999993443489075 -1.0000005960464478 1.0
      }
      <Vertex> 11 {
        1.0 -1.0 -1.0
      }
      <Vertex> 12 {
        1.0 -1.0 -1.0
      }
      <Vertex> 13 {
        0.9999993443489075 -1.0000005960464478 1.0
      }
      <Vertex> 14 {
        -1.0000003576278687 -0.9999996423721313 1.0
      }
      <Vertex> 15 {
        -1.0000001192092896 -0.9999998211860657 -1.0
      }
      <Vertex> 16 {
        -1.0000001192092896 -0.9999998211860657 -1.0
      }
      <Vertex> 17 {
        -1.0000003576278687 -0.9999996423721313 1.0
      }
      <Vertex> 18 {
        -0.9999999403953552 1.0 1.0
      }
      <Vertex> 19 {
        -0.9999996423721313 1.0000003576278687 -1.0
      }
      <Vertex> 20 {
        1.0000004768371582 0.999999463558197 1.0
      }
      <Vertex> 21 {
        1.0 0.9999999403953552 -1.0
      }
      <Vertex> 22 {
        -0.9999996423721313 1.0000003576278687 -1.0
      }
      <Vertex> 23 {
        -0.9999999403953552 1.0 1.0
      }}
    
    
    <Polygon> {
      <MRef> { Material }
      <Normal> {0.000000 0.000000 -1.000000}
      <VertexRef> { 0 1 2 3 <Ref> { Cube }}
    }
    <Polygon> {
      <MRef> { Material }
      <Normal> {0.000000 0.000000 1.000000}
      <VertexRef> { 4 5 6 7 <Ref> { Cube }}
    }
    <Polygon> {
      <MRef> { Material }
      <Normal> {1.000000 -0.000000 0.000000}
      <VertexRef> { 8 9 10 11 <Ref> { Cube }}
    }
    <Polygon> {
      <MRef> { Material }
      <Normal> {-0.000000 -1.000000 -0.000000}
      <VertexRef> { 12 13 14 15 <Ref> { Cube }}
    }
    <Polygon> {
      <MRef> { Material }
      <Normal> {-1.000000 0.000000 -0.000000}
      <VertexRef> { 16 17 18 19 <Ref> { Cube }}
    }
    <Polygon> {
      <MRef> { Material }
      <Normal> {0.000000 1.000000 0.000000}
      <VertexRef> { 20 21 22 23 <Ref> { Cube }}
    }
  }

And here’s a link to the texture:
dropbox.com/s/l3gte723rml27ad/wall_128.bmp
Any thoughts would be greatly, greatly appreciated!

Your model has no UV coordinates. You need to either set UV coordinates in Blender, or tell Panda3d to automatically generate some for you. This is covered here panda3d.org/manual/index.php … oordinates.

setWrapU and setWrapV only tell Panda what to do when it finds a UV coordinate greater than 1.

Ah… Yeah, I should’ve mentioned that I’m also completely new to Blender and 3D modeling concepts in general.

setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition), that did it! The mapping is messed up, but I can take it from here. Thanks!