Game Development Reference
In-Depth Information
q=(q)?q:EPSILON;
//m2 is slope of one line, c2 is constant value for y=mx+c
//line equation
m2=(double)(y[max]-y[min])/q;
c2=y[max]-m2*x[max];
//Now we know the highest. middle and lowesty positions
//Draw horizontal lines from highest to middle position
//Only draw the first section if they values differ
if (y[max]!=y[mid]){
q=(double)(x[mid]-x[max]);
q=(q)?q:EPSILON;
//m1 is slope of other line, c1 is constant value for line
//equation
m1=(double)(y[mid]-y[max])/q;
c1=(double)y[mid]-m1*x[mid];
for (i=y[max];i>y[mid];i-){
xs=((double)i-c1)/m1; xe=((double)i-c2)/m2;
HorzLine(buf, (int)xs, (int)xe, i);
}
}
//Reached the mid point, only draw ify values differ
if (y[mid]!=y[min]){
q=(double)(x[mid]-x[min]);
q=(q)?q:EPSILON;
m1=(double)(y[mid]-y[min])/q;
c1=(double)y[mid]-m1*x[mid];
for (i=y[mid];i>y[min];i-){
xs=((double)i-c1)/m1; xe=((double)i-c2)/m2;
HorzLine(buf, (int)xs, (int)xe, i);
}
}
//If a four point polygon then repeat for the second triangle
count++;
}
//If required paint the normals in red
if (drawNormal){
COLOUR normcol;
normcol.red=255;normcol.green=0;normcol.blue=0;
for (i=0;i<numverts;i++){
buf.DrawLine(pts[i].sx, pts[i].sy, pts[i].snx,
pts[i].sny, normcol);
}
}
}
Search Nedrilad ::




Custom Search