Pseudocode Lighting by Raster
int V1x, v1y, V2X, v2y, v3x, v3y, V4x, v4y; / / vertices
void lights () {float *
Ax * Ay
A'x float *, * A'y;
float * Bx, * By;
B'x
float *, * B'y;
float * Cx * Cy;
float * C'x , * C'y;
int ret;
if (ordena1 == 1) {/ / function vertex ordering devulve more orderly
bresenham1
B'x = (* Ax, * Ay, * By, Bx * ) / / use the Bresenham algorithm
B'y = bresenham2 (* Ax, * Ay, * By, * Bx)
color (r, g, b, B'x)
color (r, g, b , B'y)
bresenham1 C'x = (* Ax, * Ay, * Cy * Cx)
C'y = bresenham2 (* Ax, * Ay, * Cy * Cx)
color (r, g , b, C'x)
color (r, g, b, C'y)
}
if(ordena2==1){
B'x=bresenham1(*Ax,*Ay,*By,*Bx)
B'y=bresenham2(*Ax,*Ay,*By,*Bx)
color(r,g,b,B'x);
color(r,g,b,B'y);
C'x=bresenham1(*Ax,*Ay,*Cy,*Cx)
C'y=bresenham2(*Ax,*Ay,*Cy,*Cx)
color(r,g,b,C'x);
color(r,g,b,C'y);
}
if(ordena3==1){
B'x=bresenham1(*Ax,*Ay,*By,*Bx)
B'y=bresenham2(*Ax,*Ay,*By,*Bx)
color(r,g,b,B'x);
color(r,g,b,B'y);
C'x=bresenham1(*Ax,*Ay,*Cy,*Cx)
C'y=bresenham2(*Ax,*Ay,*Cy,*Cx)
color(r,g,b,C'x);
color(r,g,b,C'y);
}
if(ordena4==1){
B'x=bresenham1(*Ax,*Ay,*By,*Bx)
B'y=bresenham2(*Ax,*Ay,*By,*Bx)
color(r,g,b,B'x);
color(r,g,b,B'y);
C'x=bresenham1(*Ax,*Ay,*Cy,*Cx)
C'y=bresenham2(*Ax,*Ay,*Cy,*Cx)
color(r,g,b,C'x);
color(r,g,b,C'y);
}
while(By!=Cy){
if( B'y <=c'y&& c'y==cy){
A'y=cy
A'x=cx}
if( c'y <=B'y&& B'y==By){
Ay=By
Ax=Bx}
if(c'y=cy){
cy=V3Y
cx=v3X
}
if( B'y==By){
By=V3Y
Bx=v3X
}
}
B'x=bresenham1(*Ax,*Ay,*By,*Bx)
B'y=bresenham2(*Ax,*Ay,*By,*Bx)
color(r,g,b,B'x);
color(r,g,b,B'y);
C'x=bresenham1(*Ax,*Ay,*Cy,*Cx)
C'y=bresenham2(*Ax,*Ay,*Cy,*Cx)
color(r,g,b,C'x);
color(r,g,b,C'y);
}
}
int ordena1(){
if(v2y <=v1y> =v3y && v1y>=v4y){
Ay=A'y=v1y;
Ax=A'x=v1x;
if(v3y <=v2y> =v4y({
By=B'y=v2y;
Bx=B'x=v2x;
if(v3y <=v4y{
cy=c'y=v4y;
cx=c'x=v4x;
}else{
cy=c'y=v3y;
cx=c'x=v3x;
}
}
if(v2y <=v3y> =v4y){
By=B'y=v3y;
Bx=B'x=v3x;
if(v2y <=v4y{
cy=c'y=v4y;
cx=c'x=v4x;
}else{
cy=c'y=v2y;
cx=c'x=v2x;
}
}
}
if(v3y <=v4y> =v2y){
By=B'y=v4y;
Bx = B'x = V4x;
if (c = c'y <=v2y{
v3y = v2y;
c'x = cx = V2X;
} else {c = c'y = v3y;
cx = c ' x = v3x;
}}
verif = 1;}
else
verif = 0;
}}
0 comments:
Post a Comment