Having a hard time with models

I cant seem to get the .egg models I make to show up in Panda.

import direct.directbase.DirectStart

#Load the first environment model
model = loader.loadModel("models/earth")
model.reparentTo(render)
model.setScale(2,2,2)
model.setPos(0,5,0)


run()

First I used this same code to load the ball model from the example, and it worked fine. Then I change to model to one I got out of a downloaded example and I doesn’t show up. I am new to Panda 3D and Python. Is there a code I can use to point the camera right at the model?

Thanks

first, try if you can see your model in pview. if you don’t see anything there, your egg file is damaged or empty

if it works, do the following.

import direct.directbase.DirectStart

model = loader.loadModel("models/earth")
model.reparentTo(render)
# this lets us control the camera
base.disableMouse()
camera.setPos(-5, -5, 2)
# changes the rotation so that cam faces the model's center
camera.lookAt(model)

run()

of course i’m guessing that your object is small here. if it’s big, set the camera’s position a bit more away.

Note that it helps to know how big the model is. A model called “earth” might be very big indeed, and if you move it only 5 units in front of the camera, it might not be far enough; and your camera might be inside it (and thus unable to see it).

In pview, you can press the “c” key to automatically center the model in front of the camera based on its bounding volume. (And you can press the shift-“B” key to report the bounding volume and size to the console window.)

It’s possible to do this in Python code, too, but usually when you’re loading a model in an application, you already know how big it is, where its center is, and where you want it to go in your scene.

David

Thanks!

I have got it working.