}
}
void drawSubSector (int s )
Компьютерная графика. Полигональные модели
int firstSeg = subSectors [s].firstSeg; // get segments, forming ssector int numSegs = subSectors [s].numSegs;
Segment * seg = &segs [firstSeg]; // pointer to current segment
if ( curSector == NULL ) //1st ssector to be drawn
{ // front-to-back will contain viewer
SideDef * side = &sides [lines [seg->fineDef].sideDefs [ seg->lineSide]];
curSector = &subSectors [s]; // so remember it & adjust height locZ = 40 + sectors [side -> sector].floorHeight;
}
for (int i = 0; i < numSegs; seg++ ) // draw all front-facing segments if (frontFacing ( seg -> from, seg -> to )) drawSeg (seg );
}
void drawSeg ( Segment * seg )
{
int x1 = vertices [seg->from].x - locX; int y1 = vertices [seg->from].y - locY; int x2 = vertices [seg->to].x - locX; int y2 = vertices [seg->to].y - locY;
// convert to local coords int u1 = fixed2lnt (-x1*sine (angle) + y1*cosine (angle)); int v1 = fixed2lnt ( x1*cosine (angle) + y1*sine (angle)),; int u2 = fixed2lnt (-x2*sine (angle) + y2*cosine (angle)); int v2 = fixed2lnt ( x2*cosine (angle) + y2*skie (angle));
if ( v1 < V_MIN && v2 < V_MIN ) // segment behind the image plane
return;
if ( v1 < V_MIN ) // clip 1st point
{
u1 += (int)(((long)(V_MIN - v1) * (long)(u2 - u1)) / (v2 - v1)); v1 =V_MIN;
}
if ( v2 < VJvllN ) // clip 2nd point
{
u2 += (int)(((long)(V_MIN - v2) * (long)(u2 - u1)) / (v2 - v1)); v2 = VJvllN;
}
// project vertices to screen int d = (int) (1601 - ( u1 * HSCALE )/v1 ); int c2 = (int) (1601 - ( u2 * HSCALE ) / v2 );
// reject invisible segs if ( d >= SCREENJ/VIDTH || c2 < 0 || c2 <= d ) return;
SideDef * side = &sides [ lines [seg -> lineDef].sideDefs [ seg -> lineSide]];
int floorHeight = sectors [side->sector].floorHeight; int ceilingHeight = sectors [side->sector].ceilingHeight;
if ( side -> main_tx [0] != '-') // simple wall from floor to ceiling