예제 #1
0
const Vector3& Transform::GetUp()
{
	CalculateWorldMatrix();
	_up._x = _worldMatrix._21;
	_up._y = _worldMatrix._22;
	_up._z = _worldMatrix._23;
	return _up;
}
예제 #2
0
const Vector3& Transform::GetRight()
{
	CalculateWorldMatrix();
	_right._x = _worldMatrix._11;
	_right._y = _worldMatrix._12;
	_right._z = _worldMatrix._13;
	return _right;
}
예제 #3
0
const Vector3& Transform::GetForward()
{
	CalculateWorldMatrix();
	_forward._x = _worldMatrix._31;
	_forward._y = _worldMatrix._32;
	_forward._z = _worldMatrix._33;
	return _forward;
}
예제 #4
0
	void Text::DrawVertexBuffer( int prVertexCount )
	{
		UINT stride = sizeof( Tuxis::Vertex::SpriteVertex );
		UINT offset = 0;
		Engine::GetContext()->IASetVertexBuffers( 0, 1, &VertexBuffer, &stride, &offset );
		XMMATRIX WorldMatrix = CalculateWorldMatrix();
		XMMATRIX FinalMatrix = WorldMatrix * (Engine::GetInstance()->GetActive2DCamera()->GetFinalMatrix())  ;
		FinalMatrix = XMMatrixTranspose( FinalMatrix );

		Engine::GetContext()->VSSetShader( mShader->VertexShader, 0, 0 );
		Engine::GetContext()->PSSetShader( mShader->PixelShader , 0, 0 );

		Engine::GetContext()->UpdateSubresource( ShaderConstantBuffer, 0, NULL, &FinalMatrix, 0, 0 );
		Engine::GetContext()->VSSetConstantBuffers( 0, 1, &ShaderConstantBuffer );

		Engine::GetContext()->PSSetShaderResources( 0, 1, mFont->GetTextureAtlas()->GetShaderResourceView() );
		Engine::GetContext()->PSSetSamplers( 0, 1, mFont->GetTextureAtlas()->GetSamplerState() );
		Engine::GetContext()->IASetInputLayout( mShader->InputLayout );
		Engine::GetContext()->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

		Graphics::Instance()->DisableStencilBuffer();
		Engine::GetContext()->Draw( prVertexCount, 0 );
	}
예제 #5
0
const Matrix4x4& Transform::GetWorldMatrix()
{
	CalculateWorldMatrix();
	return this->_worldMatrix;
}
예제 #6
0
	void TiledSpriteGroup::Draw()
	{
		if(!mVisible) return;
		
	
		if(!mTiledTextureRegion)
			Log::Error("TxTiledSpriteGroup::Draw - Not set Texture Region.");

		Graphics::Instance()->DisableStencilBuffer();

		// Calculate matrices
		XMMATRIX WorldMatrix = CalculateWorldMatrix();
		XMMATRIX FinalMatrix = WorldMatrix*(Engine::GetInstance()->GetActive2DCamera()->GetFinalMatrix() );
		FinalMatrix = XMMatrixTranspose( FinalMatrix );
	
		int RealDrawCount=CountOfSprites;
	
	
		// Modify the vertex buffer
		D3D11_MAPPED_SUBRESOURCE mapResource;
		Engine::GetContext()->Map( VertexBuffer, 0,D3D11_MAP_WRITE_DISCARD, 0, &mapResource );
		{
			Tuxis::Vertex::SpriteGroupVertex* pTempVertex=(Tuxis::Vertex::SpriteGroupVertex*)mapResource.pData;
	
			int BufferCounter=0;
	
			for(int i=0;i<CountOfSprites*6;i+=6)
			{	
				if(SpriteBase[i/6].Visible==false)
				{
					RealDrawCount--;
					continue;
				}
	
				floatRect *Region=mTiledTextureRegion->TileCoordinates.at(SpriteBase[i/6].Frame);

				HalfTexSize.x=( (Region->x2 - Region->x1) )/2.0f;
				HalfTexSize.y=( (Region->y2 - Region->y1) )/2.0f;
	
				AbsTextureCoordinate(
					Region->x1 / (int)mTiledTextureRegion->mTexture->GetWidth(),
					Region->y1 / (int)mTiledTextureRegion->mTexture->GetHeight(),
					Region->x2 / (int)mTiledTextureRegion->mTexture->GetWidth(),
					Region->y2 / (int)mTiledTextureRegion->mTexture->GetHeight()
					);
	
				float xPos=SpriteBase[i/6].Position.x;
				float yPos=SpriteBase[i/6].Position.y;
	
				// Vertex Position.
				pTempVertex[BufferCounter + 0].Position = XMFLOAT3( -HalfTexSize.x,  -HalfTexSize.y, 0.0f );
				pTempVertex[BufferCounter + 1].Position = XMFLOAT3(  HalfTexSize.x,   HalfTexSize.y, 0.0f );
				pTempVertex[BufferCounter + 2].Position = XMFLOAT3( -HalfTexSize.x,   HalfTexSize.y, 0.0f );
	
				pTempVertex[BufferCounter + 3].Position = XMFLOAT3(  HalfTexSize.x,  -HalfTexSize.y, 0.0f );
				pTempVertex[BufferCounter + 4].Position = XMFLOAT3(  HalfTexSize.x,   HalfTexSize.y, 0.0f );
				pTempVertex[BufferCounter + 5].Position = XMFLOAT3( -HalfTexSize.x,  -HalfTexSize.y, 0.0f );
	
				// Texture Position.
				pTempVertex[BufferCounter + 0].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.x1, AbsTextureCoordinate.y1 );
				pTempVertex[BufferCounter + 1].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.y2, AbsTextureCoordinate.y2 );
				pTempVertex[BufferCounter + 2].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.x1, AbsTextureCoordinate.y2 );
	
				pTempVertex[BufferCounter + 3].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.x2, AbsTextureCoordinate.y1 );
				pTempVertex[BufferCounter + 4].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.x2, AbsTextureCoordinate.y2 );
				pTempVertex[BufferCounter + 5].TexCoord 
					= XMFLOAT2( AbsTextureCoordinate.x1, AbsTextureCoordinate.y1 );
	
	
				XMFLOAT4 CurrentColor=SpriteBase[i/6].Color;
	
				pTempVertex[BufferCounter + 0].Color = CurrentColor;
				pTempVertex[BufferCounter + 1].Color = CurrentColor;
				pTempVertex[BufferCounter + 2].Color = CurrentColor;
				pTempVertex[BufferCounter + 3].Color = CurrentColor;
				pTempVertex[BufferCounter + 4].Color = CurrentColor;
				pTempVertex[BufferCounter + 5].Color = CurrentColor;
	
				float Rotation=SpriteBase[i/6].Rotation;
	
				pTempVertex[BufferCounter + 0].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
				pTempVertex[BufferCounter + 1].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
				pTempVertex[BufferCounter + 2].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
				pTempVertex[BufferCounter + 3].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
				pTempVertex[BufferCounter + 4].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
				pTempVertex[BufferCounter + 5].Rotation = XMFLOAT3( xPos ,  yPos , Rotation );
	
				float Scale=SpriteBase[i/6].Scale;
	
				pTempVertex[BufferCounter + 0].Scale = Scale;
				pTempVertex[BufferCounter + 1].Scale = Scale;
				pTempVertex[BufferCounter + 2].Scale = Scale;
				pTempVertex[BufferCounter + 3].Scale = Scale;
				pTempVertex[BufferCounter + 4].Scale = Scale;
				pTempVertex[BufferCounter + 5].Scale = Scale;
	
				BufferCounter+=6;
			}
		}
		Engine::GetContext()->Unmap( VertexBuffer,0);
	
		//FinalMatrix=XMMatrixTranspose(FinalMatrix);
	
		// Context configuration
		Engine::GetContext()->IASetVertexBuffers( 0, 1, &VertexBuffer, &VB_Stride, &VB_Offset );
		Engine::GetContext()->VSSetShader( mShader->VertexShader, 0, 0 );
		Engine::GetContext()->PSSetShader( mShader->PixelShader , 0, 0 );

		Engine::GetContext()->UpdateSubresource( ShaderConstantBuffer, 0, NULL, &FinalMatrix, 0, 0 );
		Engine::GetContext()->VSSetConstantBuffers( 0, 1, &ShaderConstantBuffer );

		Engine::GetContext()->PSSetShaderResources( 0, 1, mTiledTextureRegion->mTexture->GetShaderResourceView() );
		Engine::GetContext()->PSSetSamplers( 0, 1, mTiledTextureRegion->mTexture->GetSamplerState() );
		Engine::GetContext()->IASetInputLayout( mShader->InputLayout );
		Engine::GetContext()->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
	
		// Drawing
		Engine::GetContext()->Draw(6*RealDrawCount,0);
	}