Example #1
0
DebugDrawer::DebugDrawer()
	: lines(nullptr)
	, triangles(nullptr)
{
	Allocator* alloc = AllocatorGetThis();
	
	MaterialHandle debug = MaterialCreate(alloc, "Debug");
	
	Material* mat = debug.Resolve();
	mat->setBackfaceCulling(false);
	mat->setBlending(BlendSource::SourceAlpha, BlendDestination::InverseSourceAlpha);
	mat->setDepthCompare( DepthCompare::LessOrEqual );
	mat->setDepthOffset(Vector2(-1.0f, 1.0f));

	//mat->setDepthRange( Vector2(0.1f, 0.9f) );
	//mat->setDepthWrite(false);

	// Lines
	GeometryBuffer* linesVB = AllocateThis(GeometryBuffer);
	linesVB->setBufferAccess(BufferAccess::Write);
	linesVB->setBufferUsage(BufferUsage::Dynamic);
	SetupDebugVertexFormat(linesVB);

	lines = RenderBatchCreate(alloc);
	lines->setGeometryBuffer(linesVB);
	lines->setPrimitiveType(PrimitiveType::Lines);
	lines->setMaterial(debug);
	lines->setRenderLayer(RenderLayer::PostTransparency);
	renderables.push_back(lines.get());

	// Triangles
	GeometryBufferPtr trianglesVB = AllocateThis(GeometryBuffer);
	trianglesVB->setBufferAccess(BufferAccess::Write);
	trianglesVB->setBufferUsage(BufferUsage::Dynamic);
	SetupDebugVertexFormat(trianglesVB.get());

	triangles = RenderBatchCreate(alloc);
	triangles->setGeometryBuffer(trianglesVB);
	triangles->setPrimitiveType(PrimitiveType::Triangles);
	triangles->setMaterial(debug);
	triangles->setRenderLayer(RenderLayer::PostTransparency);
	renderables.push_back(triangles.get());

	// Quads
	GeometryBufferPtr quadsVB = AllocateThis(GeometryBuffer);
	quadsVB->setBufferAccess(BufferAccess::Write);
	quadsVB->setBufferUsage(BufferUsage::Dynamic);
	SetupDebugVertexFormat(quadsVB.get());

	quads = RenderBatchCreate(alloc);
	quads->setGeometryBuffer(quadsVB);
	quads->setPrimitiveType(PrimitiveType::Quads);
	quads->setMaterial(debug);
	quads->setRenderLayer(RenderLayer::PostTransparency);
	renderables.push_back(quads.get());

	reset();
}
Example #2
0
void Overlay::setOpacity( float opacity )
{
    this->opacity = opacity;

    if( renderables.Empty() ) return;

    MaterialHandle materialHandle = renderables[0]->getMaterial();

    Material* material = materialHandle.Resolve();
    if( !material ) return;

    material->setBlending(BlendSource::SourceAlpha, BlendDestination::InverseSourceAlpha);
}
Example #3
0
RenderBatchPtr Model::createDebugRenderable() const
{
	MaterialHandle handleMaterial = MaterialCreate(AllocatorGetHeap(), "SkeletonDebug");

	Material* material = handleMaterial.Resolve();
	material->setDepthTest(false);

	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);
	
	RenderBatch* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Lines);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(handleMaterial);

	return renderable;
}
Example #4
0
RenderablePtr DebugBuildFrustum( const Frustum& box )
{
	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);

	MaterialHandle materialHandle = MaterialCreate(AllocatorGetHeap(), "FrustumDebug");
	Material* material = materialHandle.Resolve();
	material->setBackfaceCulling( false );

	Renderable* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Quads);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(materialHandle);
	renderable->setPrimitiveRasterMode( PrimitiveRasterMode::Wireframe );

	DebugUpdateFrustum(renderable, box);
	return renderable;
}
Example #5
0
RenderablePtr DebugBuildBoundingBox( const BoundingBox& box )
{
	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);

	MaterialHandle materialHandle = MaterialCreate(AllocatorGetHeap(), "BoundingBoxDebug");
	
	Material* mat = materialHandle.Resolve();
	mat->setDepthCompare( DepthCompare::LessOrEqual );
	mat->setBackfaceCulling( false );
	//mat->setDepthRange( Vector2(0.1f, 0.9f) );

	Renderable* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Quads);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(materialHandle);
	renderable->setPrimitiveRasterMode( PrimitiveRasterMode::Wireframe );

	DebugUpdateBoudingBox(gb, box, Color::White);

	return renderable;
}