13. Элементы виртуальной реальност

// no lower or upper drawSimpleWall ( d, c2, locZ - floorHeight, ceilingHeight - locZ, v1, v2 );
else
{ // otherwise we'll need adjacent sector heights
SideDef * otherSide = &sides [lines [seg -> lineDef].sideDefs [
seg -> lineSide A 1]];
// draw lower part if ( side -> lower Jx [0] !=-')
drawLowerWall ( d, c2, locZ - floorHeight, locZ - sectors [otherSide ->
sector].floorHeight, v1, v2 );
else
drawLowerWall ( d, c2, locZ - floorHeight, locZ - floorHeight, v1, v2 );
// draw upper part if ( side -> upperjx [0] !=)
drawUpperWall ( c1, c2, sectors [
otherSide->sector].ceilingHeight - locZ, ceilingHeight - locZ, v1, v2 );
else
drawUpperWall ( c1, c2, ceilingHeight - locZ, ceilingHeight - locZ, v1, v2 );
}
}
// Draw walls using horizon lines - only parts between horizon lines are drawn
void drawSimpleWall (int coh, int col2, int bottomHeight, int topHeight,
int v1, int v2 )
{
Fixed b1 = int2Fixed ( 1001 + ( bottomHeight * VSCALE ) / v1 ); Fixed b2 = int2Fixed (1001 + ( bottomHeight * VSCALE ) / v2 ); Fixed t1 = int2Fixed ( 1001 - (topHeight * VSCALE ) / v1 ); Fixed t2 = int2Fixed (1001 - (topHeight * VSCALE ) / v2 ); Fixed db = ( b2 - b1 ) / ( co!2 - coil ); Fixed dt = (t2-t1 )/(co!2-col1 ); int top, bottom;
if ( coll < 0 ) // clip invisible part {
b1 -= coll * db; t1 -= coh * dt; coll = 0;
}
if ( col2 > 320 ) col2 = 320;
, for (int col = coh; col < col2; col++ ) {
top = fixed2lnt (t1 ); bottom = fixed2lnt ( b1 ); t1 += dt; b1 += db;
if (topLine [col] > bottom Line [col] ) // nothing to draw here

Компьютерная графика. Полигональные модели

continue;
if (top > bottomLine [col] ) top = bottomLine [col];
if ( bottom < topLine [col]) bottom = topLine [col];
if (top >= topLine [col] ) // draw ceiling {
drawVertLine ( col, topLine [col], top, CEILING_COLOR ); topLine [col] = ++top;
}
else // otherwise correct to
top = topLine [col]; // draw only visible part
if ( bottom <= bottomLine [col] ) // draw floor {

⇐ Предыдущая| |Следующая ⇒