Showing model in front of 2d frame [SOLVED]

The panda manual states that "Anything parented to render2d will be rendered on top of the 3-D scene, as if it were painted on the screen glass. "

This is usually what I want, but is there a way for a specific options screen (which is just a DirectFrame with an image on it) that I could show a 3d model in front of the image? I want to allow users to select a model to use.

You can parent your 3-d image directly to the DirectFrame, and set the appropriate scale and offset so that it is centered within the frame correctly.

David

I’ve loaded the model with :

model.reparentTo(self.scrChar)

scrChar is the DirectFrame.

I don’t see the model at all. When you say “set the appropriate scale and offset so that it is centered within the frame correctly.”

is there anything special about centering it in a frame?

Well, remember that the frame is probably really small compared to what you’re used to rendering the model. The frame probably has a size less than 1.0 on a side, and your model might be much larger than that. So you might need to make your model really tiny (e.g. model.setScale(0.1) or so).

You can print model.getBounds() to get an idea of the size of the model; or use model.showBounds() to draw a green wiremesh sphere around it to help you position it.

You might also need to enable depth write and test on the model:

model.setDepthTest(True)
model.setDepthWrite(True)

David

ah, gotcha…

Got it working now. Thx again! I have 1 more question tonight, which I’ll post in a new topic.

Been a busy coding day :slight_smile:

Posting back in this thread from way back.

I’ve just noticed (over a year later!) that the model I show in front of the DirectFrame for this option screen looked a little different than the same model when used in game.

I think it’s because I am using render.setShaderAuto() and have a few things like bump maps applied to my models in-game.

On this screen , however, I see them without the fx. As a test I added
render2d.setShaderAuto()

to see what would happend and I do seem to see the models change to look right. However, it totally messes up other DirectGUI controls and text on the DirectFrame (text is now invisible, etc).

Is there another way I can get this model (the only 3d element on this DirectFrame) to take advantage of setShaderAuto() ?

Why not just do model.setShaderAuto()?

Hi,
thanks for the response. I (embarassingly) realized this myself about a day after posting! :slight_smile:

Must’ve had a mental block or something!