8,303
社区成员
发帖
与我相关
我的任务
分享
//transform the light to the coordinate of the object
LightPosition = LightPosition * Inverse(OjbectWorldMatrix);
/*我加的:Inverse(ObjectWorldMatrix),就是将模型矩阵求逆*/
for(every polygon)
{
IncidentLightDir = AveragePolyPosition - LightPosition;
/* 我加的:AveragePolyPosition 就是计算多边形的各个顶点位置的平均值,得到的就是多边形的重心的位置*/
//if the polygon faces away from the light source...
if(DotProduct(IncidentLightDir, PolygonNormal) >= 0.0)
{
for(every edge of the polygon)
{
if(the edge is always in the contour edge list)
{
//then it can't be a contour edge since it is
//referenced by two triangels that are facing
//away from the light
remove the existing edge from the contour list;
}
else
{
add the edte to the contour list;
}
}
}
}
ExtrudeMagnitude = A_BIG_NUMBER; //一个任意大的数
for(every edge)
{
ShadowQuad[i].vertex[0] = edge[i].vertex[0];
ShadowQuad[i].vertex[1] = edge[i].vertex[1];
ShadowQuad[i].vertex[2] = edge[i].vertex[1] + ExtrucdMagnitude * (edge[i].vertex[1] - LightPosition);
ShadowQuad[i].vertex[3] = edge[i].vertex[0] + ExtrudeMagnitude * (edge[i].vertex[0] - LightPosition);
}