Example #1
0
void BatchRenderer::DrawSolidTriangle3D(
	const Vec3D& a, const Vec3D& b, const Vec3D& c,
	const FColor& color
	)
{
	const U4 rgbaColor = color.ToRGBA32();

	SetBatchState( this, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

	const UINT iBaseVertex = self->batchedVertices.Num();
	Vertex & v0 = self->batchedVertices.Add();
	Vertex & v1 = self->batchedVertices.Add();
	Vertex & v2 = self->batchedVertices.Add();

	v0.xyz.x 	= a.x;
	v0.xyz.y 	= a.y;
	v0.xyz.z 	= a.z;
	v0.rgba.asU32 	= rgbaColor;

	v1.xyz.x 	= b.x;
	v1.xyz.y 	= b.y;
	v1.xyz.z 	= b.z;
	v1.rgba.asU32 	= rgbaColor;

	v2.xyz.x 	= c.x;
	v2.xyz.y 	= c.y;
	v2.xyz.z 	= c.z;
	v2.rgba.asU32 	= rgbaColor;

	self->batchedIndices.Add( iBaseVertex + 0 );
	self->batchedIndices.Add( iBaseVertex + 1 );
	self->batchedIndices.Add( iBaseVertex + 2 );
}
Example #2
0
void BatchRenderer::DrawSprite(
	const Matrix4& cameraWorldMatrix,
	const Vec3D& spriteOrigin,
	const FLOAT spriteSizeX, const FLOAT spriteSizeY,
	const FColor& color
)
{
	const Vec3D spriteX = cameraWorldMatrix[0].ToVec3() * spriteSizeX;
	const Vec3D spriteY = cameraWorldMatrix[1].ToVec3() * spriteSizeY;

	const U4 rgbaColor = color.ToRGBA32();

	SetBatchState( this, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

	const UINT iBaseVertex = self->batchedVertices.Num();

	Vertex & v0 = self->batchedVertices.Add();
	Vertex & v1 = self->batchedVertices.Add();
	Vertex & v2 = self->batchedVertices.Add();
	Vertex & v3 = self->batchedVertices.Add();

	
	v0.xyz		= spriteOrigin - spriteX - spriteY;	// bottom left
	v0.uv.x 	= 0.0f;
	v0.uv.y 	= 1.0f;
	v0.rgba.asU32 	= rgbaColor;

	v1.xyz		= spriteOrigin - spriteX + spriteY;	// top left
	v1.uv.x 	= 0.0f;
	v1.uv.y 	= 0.0f;
	v1.rgba.asU32 	= rgbaColor;

	v2.xyz		= spriteOrigin + spriteX + spriteY;	// top right
	v2.uv.x 	= 1.0f;
	v2.uv.y 	= 0.0f;
	v2.rgba.asU32 	= rgbaColor;

	v3.xyz		= spriteOrigin + spriteX - spriteY;	// bottom right
	v3.uv.x 	= 1.0f;
	v3.uv.y 	= 1.0f;
	v3.rgba.asU32 	= rgbaColor;

	// indices:
	// 0,	1,	2,
	// 0,	2,	3,

	self->batchedIndices.Add( iBaseVertex + 0 );
	self->batchedIndices.Add( iBaseVertex + 1 );
	self->batchedIndices.Add( iBaseVertex + 2 );

	self->batchedIndices.Add( iBaseVertex + 0 );
	self->batchedIndices.Add( iBaseVertex + 2 );
	self->batchedIndices.Add( iBaseVertex + 3 );
}
Example #3
0
void BatchRenderer::DrawTriangle3D(
	const Vec3D& a, const Vec3D& b, const Vec3D& c,
	const FColor& color
)
{
#if 0
	DrawLine3D( a, b, color, color );
	DrawLine3D( b, c, color, color );
	DrawLine3D( c, a, color, color );
#else
	SetBatchState( this, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP );

	Vertex & v0 = self->batchedVertices.Add();
	Vertex & v1 = self->batchedVertices.Add();
	Vertex & v2 = self->batchedVertices.Add();
	Vertex & v3 = self->batchedVertices.Add();

	v0.xyz.x 	= a.x;
	v0.xyz.y 	= a.y;
	v0.xyz.z 	= a.z;
	v0.rgba.asU32 	= color.ToRGBA32();

	v1.xyz.x 	= b.x;
	v1.xyz.y 	= b.y;
	v1.xyz.z 	= b.z;
	v1.rgba.asU32 	= color.ToRGBA32();

	v2.xyz.x 	= c.x;
	v2.xyz.y 	= c.y;
	v2.xyz.z 	= c.z;
	v2.rgba.asU32 	= color.ToRGBA32();

	v3.xyz.x 	= a.x;
	v3.xyz.y 	= a.y;
	v3.xyz.z 	= a.z;
	v3.rgba.asU32 	= color.ToRGBA32();
#endif
}
Example #4
0
FORCEINLINE R8G8B8A8 FColor_to_RGBA32( const FColor& theColor )
{
	R8G8B8A8	rgba;
	rgba.asU32 	= theColor.ToRGBA32();
	return rgba;
}