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
Calculate projected area of a collision shape
-
- Posts: 169
- Joined: Sun Jan 14, 2007 7:56 pm
- Location: Norway
-
- Posts: 3
- Joined: Sat Jul 07, 2007 9:55 pm
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".
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".