Problem loading simple model

I am newbie to panda3d. I created two simple models using Blender and exported as .x files. I converted the .x files to .egg using x2egg. I tried loading the model(cubemodel)using the sample program in the panda3d manual but I am not able to load it. I am able to load the model using pview. Can somebody please help.Thank you in advance.


from math import pi, sin, cos
 
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
 
class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
 
        # Load the environment model.
        #self.environ = self.loader.loadModel("models/environment")
        #self.box = self.loader.loadModel("models/xbox")
        self.cube = self.loader.loadModel("models/cubemodel")
        self.cube.reparentTo(self.render)
        self.cube.setScale(0.25,0.25,0.25)
        self.cube.setPos(0, 0, 0)
        #self.box.reparentTo(self.render)
        #self.sphere = self.loader.loadModel("models/sphere")
        #self.sphere.reparentTo(self.render)
        # Reparent the model to render.
        #self.environ.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        #self.environ.setScale(0.25, 0.25, 0.25)
        #self.environ.setPos(-8, 42, 0)
 
        # Add the spinCameraTask procedure to the task manager.
        #self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
 
    # Define a procedure to move the camera.
    def spinCameraTask(self, task):
        angleDegrees = task.time * 6.0
        angleRadians = angleDegrees * (pi / 180.0)
        self.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3)
        self.camera.setHpr(angleDegrees, 0, 0)
        return Task.cont
 
app = MyApp()
app.run()

Hmm… Looking over your code, I see a few things that might perhaps be your problem.

  1. As it stands, it looks as though you’re leaving the camera at the origin, and thus presumably inside the model, leaving it invisible. Have you tried simply setting the camera’s position to some point down the negative y-axis, perhaps at -1 or -10?

  2. When instated, your camera rotation task seems to set the camera’s z-position to 3 - might the model not simply be below its view-frustum?

These next two I’m not at all confident about; I include them in case they prove of use, once the above two possibilities have been considered.

  1. Is “self.render” the same as “render” in this case? Have you tried just parenting to “render”?

  2. I don’t see a call to “base.disableMouse()”, and thus am not sure of how well camera placement will work.

thank you so much Thaumaturge