ShadowPlacer

I’m trying to play around with the ShadowPlacer. In the generated doc, there isn’t much details on how to use this.


 	__init__(self, cTrav, shadowNodePath, wallCollideMask, floorCollideMask)

Is there a better explanation of what these 4 parameters are?

Is this what I should be using for shadows?

Thanks,

John

I’m not sure if ShadowPlacer.py is particularly useful out of context, except as an example for some ways to use the collision system.

It is a module designed to fire a ray down from a jumping object to determine where the nearest ground level is, and then it moves a node (for instance, a drop shadow polygon) to that height. But it is also designed to interface with a fair amount of code on our private codebase, which isn’t provided with it.

You may be able to glean some insight from studying the code structure, and with some experience you could probably even put it it use; but it may be a better learning experience to write your own object to do what ShadowPlacer does.

David

Is there a easier way to enable shadows of nodes in panda then? Or should I look around the code structure for that?

Thanks,

The word “shadow” means a lot of different things, and there are lots of different approaches to rendering real-time shadows in a 3-d environment using current graphics hardware. There’s not a general way to turn on shadows in Panda, and I’m not sure if there will be until there is only one thing that people mean when they say they want shadows. :slight_smile:

But you can use the core graphics capabilities of Panda to make shadows in whatever way you would like them to be enabled.

One way to do shadows is to render an offscreen image of your object, as a solid gray image on a white background, from the point of view of the light, and then apply that image as a texture onto the ground. An example of this approach can be found in direct/src/showbase/ShadowDemo.py (you might need to replace base.localAvatar with whatever object you would like to shadow).

Since this example uses multitexture, you will need to be running in OpenGL mode for it to work (at present, only the Panda OpenGL implementation supports multitexture).

David

There’s also the Toontown approach to shadows – Put a node under the avatar that has a shadow-shaped circle. This method is faster, but not as detailed.