Vertex ProjectionThis method is still very simple, but it is considerably better than the last one. In this method, you project each polygon onto the ground. If there is any confusion, look at figure 3.1. Figure 3.1
The calculations for this method are incredibly simple, as you can see in listing 3.1 Listing 3.1 void shadow_poly(Point3D p[], Point3D s[], Point3D l, num_verts) { for (i=0; i<num_verts; i++) { s[i].x = p[i].x - (p[i].y / l.y) - l.x; s[i].z = p[i].z - (p[i].y / l.y) - l.z; } } (Where s is the shadow vertex, p is the object vertex, and l is the point the light originates from.) Although this is much better, this algorithm is still pretty simple, and restricted in it’s use. Once again, it only works if the ground is flat and it still doesn’t shadow other objects. Don’t worry though; there are still two more algorithms! |
|||||||||||