So for this discussion imagine a polygon floating up in the air above the Y-plane (the plane that rotates freely around the up vector). Here we have a single polygon floating above the y-plane and we'd like to figure out what it's shadow would look like. Note that all we have is the polygon and the up vector for information.
We can deconstruct the polygon into individual vectors, create a polygon from that and move it on top of the ground. From this new polygon, we simply fill it with some alpha-blended color and we have a shadow.
Here I've shown an individual vector and this is what it might look like. You will be surprised at how little math this takes. Once you have the shadow vector, you do need to translate it into the space directly under the vector which can be done using my earlier finding a point closest to a triangle.
Here is the code for creating the vector of the shadow.
Vector GetInPlanePortionOfVector (const Vector& vect, const Vector& PlaneNormal)
{
float height = (vect.Dot (PlaneNormal));
Vector shadow = vect - height * PlaneNormal;
return shadow;
}
No comments:
Post a Comment