internal void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras, RenderPoint[] points)
		{
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderZBuffer());

			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			span_gen.colors(points[0].color, points[1].color, points[2].color);
			span_gen.triangle(points[0].position.x, points[0].position.y, points[1].position.x, points[1].position.y, points[2].position.x, points[2].position.y);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}
Esempio n. 2
0
		//template<class Scanline, class Ras>
		public void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras)
		{
			double alpha = m_alpha.Value;
			double brc = 1;
#if SourceDepth24
            pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(backBuffer, new blender_bgr());
#else
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderBGRA());
#endif
			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			ras.gamma(new gamma_linear(0.0, m_gamma.Value));

			double d = m_dilation.Value;

			// Six triangles
			double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0;
			double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0;

			double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2);
			double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2);

			double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2);
			double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2);

			double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2);
			double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2);

			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			brc = 1 - brc;
			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}