3D model in front of the camera

Hi!

I want to show a 3d model in a user interface, the UI is using aspect2d and the 3d model is using render.
What i want is to show the 3d model always in the center of the screen and above the UI, regardless if the user moves the camera.

How can i do that?
(Basicaly, how to update the position of the model to be always in front of the camera and above the UI)

Thanks.

set up a task to run each frame that calls

base.camera.lookAt(nameOfTheNodeThatIsYourModel)

This will cause the camera to swivel to place the node you specify into the center of the field of view.

Well, you can achieve the 3-d model always being in the same place onscreen by parenting the model to the camera; no need for a look-at task. But that won’t solve another problem: the render2d graph is always drawn on top of the 3-d graph, by default.

There are two solutions to this. The simplest solution is just to parent your 3-d model to aspect2d, then you can sort it relative to the gui. For instance, you can parent it directly to your gui frame, and scale it appropriately for the screen (you’ll probably need to make it very tiny).

The other solution is to open a new DisplayRegion with a new camera, that has a higher sort value than aspect2d, so that everything this new camera sees will be drawn on top of the gui. Then you can put your 3-d model in the new scene graph for this new camera.

David

Thanks Tutunkommon, but the thing is i don’t want to rotate or move the camera when i show the 3d model, just leave it fixed (or free to move) and show the model in the center of the screen.

deleted, b/c David said it much better than I did, and earlier too!

I used the model with aspect2d as you said David, almost everything is fine, the only problem i had is how the model looks on screen, i attached two images to show you.

Panda Model using render:

Panda model using aspect2d:

Looks like inverted normals, but im not sure.

Try turning on the depth test and write:

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

David

It worked! :slight_smile:

Many Thanks David.