Why I Can't see the model?

I just begin to learn Panda3D using Python,So I write some test code

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase): 
    def __init__(self):
        ShowBase.__init__(self)
        self.block = self.loader.loadModel("namae.egg")
        self.block.reparentTo(self.render)
        self.block.setPos(0, 0, 0)
        self.block.setHpr(30,40,35)
	self.front=self.loader.loadTexture("face.png")
	#self.side=self.loader.loadTexture("faceside.png")
	#self.top=self.loader.loadTexture("grass_top.png")
	self.block.setTexture(self.front)

app = MyApp()
app.run()

But when I run “python2 test.py”,I just get a grey window,I can’t see anything in the window.But My Teminal has some output:

Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(warning): No suitable FBConfig contexts available; using XVisual only.
depth_bits=24 color_bits=24 alpha_bits=8 stencil_bits=8 back_buffers=1 force_hardware=1

What Should I Do?

Where is the code which positions your camera? By default the camera is at (0,0,0), so if you place you model also at (0,0,0) then you can’t see anything.

Either move the camera

    self.cam.setPos(0,-20,0)
    self.cam.lookAt(0,0,0)

…or you model

    self.block.setPos(0, 20, 0)

Of course the actual position depends on your models extents.

Thank you.But I have a new question,I set a texture to my model,But I can only see a pink cube in the window.Where’s my texture?
My Model is just a cube created by blender,and the face.png is a 32x32 image(I upload a attachment)

And The Code Now:

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase): 
    def __init__(self):
        ShowBase.__init__(self)
        self.block = self.loader.loadModel("namae.egg")
        self.block.reparentTo(self.render)
        self.block.setPos(0, 0, 0)
        self.block.setHpr(30,40,35)
        self.front=self.loader.loadTexture("face.png")
        self.block.setTexture(self.front)
        self.cam.setPos(0,-20,0)
        self.cam.lookAt(0,0,0)

app = MyApp()
app.run()


Have you UV-mapped your cube in Blender? Without UV-coordinates Panda doesn’t have an obvious means of determining how to apply your texture to your model, I believe.

Er…OK,But I 'm not so good at Blender.I Just begin to learn everything .Can I do this UV-map with python code?

Not easily, unless you generate your entire cube in code - which is possible, check out the Procedural Cube sample program. You could also use automatic coordinate generation (eg. MWorldPosition), which is explained in the manual, but the utility of that is limited.

However, UV-mapping in Blender is not difficult and is an important part of modelling in the first place, so I would really recommend that you pick up a tutorial.

I’ll second rdb’s recommendation that you learn UV-mapping – It’s useful, I don’t think that it’s very difficult in Blender at all and a quick search seemed to suggest that there are quite a few tutorials available.

OK,I’ll learn