/********************************************************** * * AddEdgeToList * * parameters IN: * VertexCell * vertex1 * VertexCell * vertex2 * *********************************************************/ void AddEdgeToList (VertexCell * vertex1, VertexCell * vertex2) { VertexCell * tempVertex; MyVector dw; EdgeBox * edgeBox; if (vertex1->screenPos.GetY() > vertex2->screenPos.GetY()) { tempVertex = vertex1; vertex1 = vertex2; vertex2 = tempVertex; } int y1 = vertex1->screenPos.GetY(); int y2 = vertex2->screenPos.GetY(); if (y1 != y2) { int dy = y2 - y1; double currX = vertex1->screenPos.GetX(); double currZ = vertex1->screenPos.GetZ(); double currI = lightVector.DotProduct (vertex1->vertexNormal); MyVector currW = vertex1->worldPos; double dx = (vertex2->screenPos.GetX() - currX) / dy; double dz = (vertex2->screenPos.GetZ() - currZ) / dy; double di = (lightVector.DotProduct (vertex2->vertexNormal) - currI) / dy; dw.SetX( (vertex2->worldPos.GetX() - currW.GetX()) / dy); dw.SetY( (vertex2->worldPos.GetY() - currW.GetY()) / dy); dw.SetZ( (vertex2->worldPos.GetZ() - currW.GetZ()) / dy); for (int y = y1; y <= y2 - 1; y++) { edgeBox = new EdgeBox; edgeBox->x = currX; edgeBox->z = (int)currZ; edgeBox->i = currI; edgeBox->w = currW; edgeBox->next = edgeListAt[y]; edgeListAt[y] = edgeBox; currX += dx; currZ += dz; currI += di; currW.SetX( currW.GetX() + dw.GetX()); currW.SetY( currW.GetY() + dw.GetY()); currW.SetZ( currW.GetZ() + dw.GetZ()); } } }