Transparent Models?

This is a pretty noob question but it’s baffling me. How can I make an object invisible in such a way that I can still set up collisions with it?

I tried texturing a transparent .gif to it but to no avail.

Here’s what I tried:


    self.leftbar = loader.loadModelCopy("models/leftbar2")
    self.leftbar_tex = loader.loadTexture("models/invisible.gif")
    self.leftbar.setTexture(self.leftbar_tex,1)

Any help is greatly appreciated!

The easiest way to do this is with the hide() method on NodePath.

myModel=loader.loadModel(“model_file_name”)
myModel.reparentTo(render)
myModel.hide()

This disables the render traverser from following the model, but should still allow the collision traverser to check it.

Best of luck!
-Mark

Thank you that worked perfectly! I have one more question: Is there a way to make a whole model transparent (eg change an overall alpha value)?

Yes, using PNG. Make a PNG with an alpha channel.

Your way didn’t work because Panda3D cannot load GIF’s.

Ah, good old patent-protected GIF. That one dirty secret of the Internet that no-one likes to talk about. :wink:

The way I usually make an entire model have the same transparency is to first enable transparency on the model’s nodepath:

myModel.setTransparency(1)

Then use the color scaler to give the whole model an alpha value:

howOpaque=.5
myModel.setColorScale(1,1,1,howOpaque)

That method is particularly useful in a LerpFunction to do fade in / fade out effects.

If you want to do something more complicated (like different levels of transparency), then a PNG with alpha channels might serve better.

Best of luck,
Mark

1 Like

Hi, sorry if this is old news but you can set your model this way:

self.myModel.setColor(.3,.3,.3,0)

where the “0” will be invisible but still able to accept collisions if it is “1” it will be visible

EDIT…sorry! mctomczak said it first and better!..also helped me understand it too!