- procedure buildShadowVolume( MeshID: Integer;lightposit: T3DPoint; ext: GlfLoat );
- var
- i: integer;
- e0, e1: integer;
- vExtended: T3DPoint;
- v1: T3DPoint;
- begin
- glDisable( GL_LIGHTING );
- glBegin( GL_TRIANGLES );
- glColor3f( 0.2, 0.8, 0.4 ); //set shadow color
- //
- // For each vertex of the shadow casting object, find the edge
- // that it helps define and extrude a quad out from that edge.
- //
- for i:=0 to scene.Mesh[meshid].NumFaces-1 do
- begin
- // Define the edge we're currently working on extruding...
- e0 := i;
- e1 := i+1;
- // If the edge's second vertex is out of array range,
- // place it back at 0
- if( e1 >= scene.Mesh[meshid].NumFaces-1 ) then e1 := 0;
- // v0 of our extruded quad will simply use the edge's first
- // vertex or e0.
- glVertex3f( scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e0]].x,
- scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e0]].y,
- scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e0]].z );
- // v1 of our quad is created by taking the edge's first
- // vertex and extending it out by some amount.
- vExtended:=extendVertex( lightPosit, scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e0]], ext );
- glVertex3f( vExtended.x, vExtended.y, vExtended.z );
- // v2 of our quad is created by taking the edge's second
- // vertex and extending it out by some amount.
- vExtended:=extendVertex( lightPosit, scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e1]], ext );
- glVertex3f( vExtended.x, vExtended.y, vExtended.z );
- // v3 of our extruded quad will simply use the edge's second
- // vertex or e1.
- glVertex3f( scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e1]].x,
- scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e1]].x,
- scene.Mesh[meshid].Vertex[scene.Mesh[meshid].Face[e1]].x );
- end;
- glEnd();
- glEnable( GL_LIGHTING );
- end;