Calculate projected area of a collision shape

ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Calculate projected area of a collision shape

Post by ola »

Hi again!

I need to calculate the projected area of a rigid body's collision shape, in a given direction. Sortof like the area of it's shadow, if the light beams creating the shadow were parallel. Not in realtime, by the way, just during some init routines.

So I wondered if there are some clever methods to do this? It does not have to be extremely accurate either.

One method that I thought of was to use raycasts in a regular grid and integrate over the grid squares that are hit by the ray.

Cheers,
Ola
Netzapper
Posts: 3
Joined: Sat Jul 07, 2007 9:55 pm

Post by Netzapper »

You can do this easily:

Determine the vector of the direction of the "light" (yourpos - lightpos). Rotate your model so that the vector is the -Z axis. Now, ignoring the Z component of your vertices, take the 2D convex hull (or alpha-shape, if you want holes) of the pointcloud. There's your "shadow".