|
@@ -15,6 +15,9 @@ namespace bbiwarg.Graphics
|
|
|
class Output : GameWindow
|
|
|
{
|
|
|
private IVideoDataSource source;
|
|
|
+ private Point[,] depthPixels = new Point[320,240];
|
|
|
+ private List<IGraphicElement> graphicElements = new List<IGraphicElement>();
|
|
|
+ private Point palmPixel;
|
|
|
|
|
|
public Output(IVideoDataSource source)
|
|
|
{
|
|
@@ -26,6 +29,28 @@ namespace bbiwarg.Graphics
|
|
|
base.OnLoad(e);
|
|
|
Title = "OutputTest";
|
|
|
GL.ClearColor(Color.Black);
|
|
|
+
|
|
|
+ for (int x = 0; x < 320; x++)
|
|
|
+ {
|
|
|
+ for (int y = 0; y < 240; y++)
|
|
|
+ {
|
|
|
+ Vertex vertex = new Vertex(x,y, 0.0f);
|
|
|
+ Color color = Color.White;
|
|
|
+ float size = 0.5f;
|
|
|
+
|
|
|
+ Point pixel = new Point(vertex, color, size);
|
|
|
+ depthPixels[x, y] = pixel;
|
|
|
+ graphicElements.Add(pixel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Vertex palmVertex = new Vertex(0.0f, 0.0f, 0.0f);
|
|
|
+ Color palmColor = Color.Yellow;
|
|
|
+ float palmSize = 5.0f;
|
|
|
+
|
|
|
+ palmPixel = new Point(palmVertex, palmColor, palmSize);
|
|
|
+ graphicElements.Add(palmPixel);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected override void OnRenderFrame(FrameEventArgs e)
|
|
@@ -44,29 +69,21 @@ namespace bbiwarg.Graphics
|
|
|
|
|
|
for (int x = 0; x < width; x++) {
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
- if (image.getConfidence(x, y) > 100) {
|
|
|
- int depth = image.getDepth(x, y);
|
|
|
- Vertex vertex = new Vertex(x-width/2, height/2-y, depth);
|
|
|
- Color color = image.getColor(x, y);
|
|
|
- float size = 0.5f;
|
|
|
-
|
|
|
- Point pixel = new Point(vertex, color, size);
|
|
|
- pixel.draw();
|
|
|
- }
|
|
|
+ Point depthPixel = depthPixels[x, y];
|
|
|
+
|
|
|
+ depthPixel.position.z = image.getDepth(x, y);
|
|
|
+ depthPixel.color = image.getColor(x, y);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Vector palmPosition2D = source.getPalmPosition2D(1);
|
|
|
- int palmX = (int) palmPosition2D[0];
|
|
|
- int palmY = (int) palmPosition2D[1];
|
|
|
- int palmDepth = image.getDepth(palmX, palmY);
|
|
|
- Vertex palmVertex = new Vertex(palmX - width / 2, height / 2 - palmY, palmDepth);
|
|
|
- Color palmColor = Color.Yellow;
|
|
|
- float palmSize = 5.0f;
|
|
|
-
|
|
|
- Point palmPixel = new Point(palmVertex, palmColor, palmSize);
|
|
|
- palmPixel.draw();
|
|
|
-
|
|
|
+ palmPixel.position.x = (int)palmPosition2D[0];
|
|
|
+ palmPixel.position.y = (int)palmPosition2D[1];
|
|
|
+ palmPixel.position.z = image.getDepth((int)palmPosition2D[0], (int)palmPosition2D[1]);
|
|
|
+
|
|
|
+ foreach(IGraphicElement graphicElement in graphicElements) {
|
|
|
+ graphicElement.draw(width, height);
|
|
|
+ }
|
|
|
|
|
|
SwapBuffers();
|
|
|
source.releaseFrame();
|