示例#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
void SaveTextureAsEXR(ID3D11ShaderResourceView* srv, const wchar* filePath)
{
    ID3D11DevicePtr device;
    srv->GetDevice(&device);

    TextureData<Float4> textureData;
    GetTextureData(device, srv, textureData);

    SaveTextureAsEXR(textureData, filePath);
}
///	\brief	implementation for buffer data interaction of texture undo/redo actions
///	\param	pCommand - pointer to command this action belongs to
///	\param	hashName - hash of object name to interact
///	\param	offset - delta data offset in command buffer
///	\param	size - delta data size in command buffer
///	\param	mode - command buffer interaction mode
DWORD UndoRedoTextureDataImpl(CUndoCommandData *pCommand, DWORD hashName, size_t offset, size_t size, DeltaMode mode)
{
	// get texture for interaction
	ITextureObject *pTexture = LoadTexture(hashName);
	ASSERT(pTexture != NULL);
	if (pTexture != NULL)
	{
		// get delta data buffer
		LPBYTE pData = pCommand->GetDeltaData() + offset;

		if (DeltaNone == mode)
		{
			// apply data directly from the buffer for DeltaNone mode
			ASSERT(GetTextureDataSize(pTexture) == size);
			pTexture->Write(pData);
		}
		else
		{
			// get current texture state for applying delta
			Buffer currentData;
			GetTextureData(pTexture, currentData);

			// this assertion means that something was totally changed inside 
			// editors or EE
			ASSERT(currentData.size() >= size);

			// restore correct data for the buffer
			if (DeltaAdd == mode)
			{
				for (Buffer::iterator it = currentData.begin(); size > 0; --size, ++pData, ++it)
				{
					(*it) = (*it) + (*pData);
				}
			}
			else
			{
				for (Buffer::iterator it = currentData.begin(); size > 0; --size, ++pData, ++it)
				{
					(*it) = (*it) - (*pData);
				}
			}
			// write updated buffer with data
			pTexture->Write(&currentData.front());
		}
	}

	return MSG_HANDLED;
}
示例#4
0
// Decode a texture into 32-bit floats and copies it to the CPU
void GetTextureData(ID3D11Device* device, ID3D11ShaderResourceView* textureSRV,
                    TextureData<UByte4N>& textureData)
{
    GetTextureData(device, textureSRV, DXGI_FORMAT_R8G8B8A8_UNORM, textureData);
}
示例#5
0
// Decode a texture into 16-bit floats and copies it to the CPU
void GetTextureData(ID3D11Device* device, ID3D11ShaderResourceView* textureSRV,
                    TextureData<Half4>& textureData)
{
    GetTextureData(device, textureSRV, DXGI_FORMAT_R16G16B16A16_FLOAT, textureData);
}
示例#6
0
// Decode a texture into 32-bit floats and copies it to the CPU
void GetTextureData(ID3D11Device* device, ID3D11ShaderResourceView* textureSRV,
                    TextureData<Float4>& textureData)
{
    GetTextureData(device, textureSRV, DXGI_FORMAT_R32G32B32A32_FLOAT, textureData);
}
示例#7
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...
}