示例#1
0
uintptr_t CPROC DrawSectorTexture( INDEX iSector, uintptr_t psv)
{
	PCOMMON pc = (PCOMMON)psv;
	PDISPLAY display = ControlData( PDISPLAY, pc );
	INDEX iTexture = GetSectorTexture( display->pWorld, iSector );
	PFLATLAND_TEXTURE texture;
	//lprintf( WIDE("Drawing a sector...") );
	GetTextureData( display->pWorld, iTexture, &texture );
	if( !texture )
	{
		//lprintf( WIDE("no texture to draw.") );
		return 0;
	}
	if( texture->flags.bColor )
	{
		//lprintf( WIDE("Draw color...") );
		if( DrawTextureSolidColor( pc, iSector, texture->data.color ) )
			sectorsdrawn++;
		else
			sectorsskipped++;
	}
	else
		lprintf (WIDE("missing data?") );
	return 0;
}
示例#2
0
uintptr_t CPROC DrawSectorLines( INDEX pSector, uintptr_t unused )
{
	_POINT o, n;
	POBJECT object = CreateObject();
	INDEX iWorld = DrawThis.iWorld;
	INDEX pStart, pCur;
	int count=0;
	int priorend = unused;
	DrawThis.object = object;
		// origin at z +1
		scale( o, VectorConst_Y, 10.0 );//SetPoint( o, VectorConst_Z );
		// direction z+1
		SetPoint( n, VectorConst_Y );
		AddPlane( object, o, n, 0 );
		Invert( n );
		Invert( o );
		AddPlane( object, o, n, 0 );
		//DrawSpaceLines( display->pImage, pSector->spacenode );
		lprintf( WIDE("Adding Sector %d"), pSector );
	pCur = pStart = GetFirstWall( iWorld, pSector, &priorend );
	do
	{
		_POINT tmp;
      LOGICAL d = IsSectorClockwise( iWorld, pSector );
      //GETWORLD( display->pWorld );
      INDEX iLine;
		PFLATLAND_MYLINESEG Line;
		//VECTOR p1, p2;

      iLine = GetWallLine( iWorld, pCur );

		GetLineData( iWorld, iLine, &Line );
      // stop infinite looping... may be badly linked...
		count++;
		if( count > 20 )
		{
         xlprintf(LOG_ALWAYS)( WIDE("Conservative limit of 20 lines on a wall has been reached!") );
         DebugBreak();
			break;
		}
		{
			_POINT o, n, r;
			//int d;
         o[0] = Line->r.o[0];
         o[1] = Line->r.o[2];
         o[2] = Line->r.o[1];
         tmp[0] = Line->r.n[0];
         tmp[1] = Line->r.n[2];
         tmp[2] = Line->r.n[1];
			if( priorend )
			{
            lprintf( WIDE("prior end causes reversal...") );
				Invert( tmp );
			}
			if( d )
			{
            lprintf( WIDE("Sector clockwise..>") );
				Invert( tmp );
			}
			//SetPoint( o, Line->r.o );
			crossproduct( n, VectorConst_Y, tmp );
         /*
			if( priorend )
			{
            d = 1;
				Invert( n );
			}
			else
			{
				d = 1;
				}
            */
			lprintf( WIDE("Adding plane to object... ") );
			PrintVector( o );
			PrintVector( n );
			AddPlane( DrawThis.object, o, n, (GetMatedWall( iWorld, pCur )==INVALID_INDEX)?0:2 );
		}

		pCur = GetNextWall(l.world
								, pCur, &priorend );
	}while( pCur != pStart );
	if( IntersectObjectPlanes( object ) )
	{
		// destroy these planes, and add new ones.
		//priorend = FALSE;
      //DestroyObject( &object );
	}
	// oh - add lines first one way and then the other... interesting
	// to test both directions of priorend!
	if( !unused )
		DrawSectorLines( pSector, 1 );
	PutIn( object, DrawThis.root );
	{
		PFLATLAND_TEXTURE texture;
		INDEX iTexture = GetSectorTexture( l.world, pSector );
		GetTextureData( l.world, iTexture, &texture );
		SetObjectColor( object, texture->data.color /*BASE_COLOR_BLUE*/ );
	}

	return 0; // continue drawing... non zero breaks loop...
}