|
@@ -15,7 +15,7 @@ namespace bbiwarg.Graphics
|
|
class Output : GameWindow
|
|
class Output : GameWindow
|
|
{
|
|
{
|
|
private IVideoDataSource source;
|
|
private IVideoDataSource source;
|
|
- private Point[,] depthPixels = new Point[320,240];
|
|
|
|
|
|
+ private Point[] depthPixels;
|
|
private ImageData currentImage;
|
|
private ImageData currentImage;
|
|
|
|
|
|
private List<IGraphicElement> graphicElements = new List<IGraphicElement>();
|
|
private List<IGraphicElement> graphicElements = new List<IGraphicElement>();
|
|
@@ -24,7 +24,7 @@ namespace bbiwarg.Graphics
|
|
private float[] vertices = new float[0];
|
|
private float[] vertices = new float[0];
|
|
private uint[] triangles = new uint[0];
|
|
private uint[] triangles = new uint[0];
|
|
|
|
|
|
- private float maxDelta = 0;
|
|
|
|
|
|
+ private Point palmPoint;
|
|
|
|
|
|
|
|
|
|
public Output(IVideoDataSource source)
|
|
public Output(IVideoDataSource source)
|
|
@@ -40,7 +40,7 @@ namespace bbiwarg.Graphics
|
|
GL.ClearColor(Color.Black);
|
|
GL.ClearColor(Color.Black);
|
|
|
|
|
|
initializeDepthPixels();
|
|
initializeDepthPixels();
|
|
- initBuffers();
|
|
|
|
|
|
+ //initBuffers();
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnRenderFrame(FrameEventArgs e)
|
|
protected override void OnRenderFrame(FrameEventArgs e)
|
|
@@ -55,10 +55,14 @@ namespace bbiwarg.Graphics
|
|
source.updateFrame();
|
|
source.updateFrame();
|
|
currentImage = source.getImageData();
|
|
currentImage = source.getImageData();
|
|
|
|
|
|
- updateDepthPixels();
|
|
|
|
-
|
|
|
|
- updateBuffer();
|
|
|
|
- drawBuffer();
|
|
|
|
|
|
+ updateDepthPixels();
|
|
|
|
+
|
|
|
|
+ foreach (IGraphicElement graphicElement in graphicElements) {
|
|
|
|
+ graphicElement.draw();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //updateBuffer();
|
|
|
|
+ //drawBuffer();
|
|
|
|
|
|
SwapBuffers();
|
|
SwapBuffers();
|
|
}
|
|
}
|
|
@@ -67,43 +71,46 @@ namespace bbiwarg.Graphics
|
|
{
|
|
{
|
|
base.OnResize(e);
|
|
base.OnResize(e);
|
|
GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
|
|
GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
|
|
- Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Width / (float)Height, 1.0f, 3000.0f);
|
|
|
|
|
|
+ Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 3, Width / (float)Height, 0.01f, 3.0f);
|
|
GL.MatrixMode(MatrixMode.Projection);
|
|
GL.MatrixMode(MatrixMode.Projection);
|
|
GL.LoadMatrix(ref projection);
|
|
GL.LoadMatrix(ref projection);
|
|
}
|
|
}
|
|
|
|
|
|
private void initializeDepthPixels()
|
|
private void initializeDepthPixels()
|
|
{
|
|
{
|
|
- int width = currentImage.getWidth();
|
|
|
|
- int height = currentImage.getHeight();
|
|
|
|
-
|
|
|
|
- for (int x = 0; x < width; x++)
|
|
|
|
- {
|
|
|
|
- for (int y = 0; y < height; 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);
|
|
|
|
- }
|
|
|
|
|
|
+ VertexArray vertexArray = source.getVertexArray();
|
|
|
|
+ int numVertices = vertexArray.getNumVertices();
|
|
|
|
+ depthPixels = new Point[numVertices];
|
|
|
|
+
|
|
|
|
+ float size = 0.001f;
|
|
|
|
+ for (int i = 0; i < numVertices; i++) {
|
|
|
|
+ Vertex vertex = vertexArray.getVertex(i);
|
|
|
|
+ Color color = vertexArray.getColor(i);
|
|
|
|
+ Point pixel = new Point(vertex, color, size);
|
|
|
|
+ depthPixels[i] = pixel;
|
|
|
|
+ graphicElements.Add(pixel);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Vector palmPosition = source.getPalmPosition3D(1);
|
|
|
|
+ Vertex palmVertex = new Vertex(palmPosition[0], palmPosition[2], palmPosition[1]);
|
|
|
|
+ palmPoint = new Point(palmVertex, Color.Yellow, 0.005f);
|
|
|
|
+ graphicElements.Add(palmPoint);
|
|
}
|
|
}
|
|
|
|
|
|
private void updateDepthPixels()
|
|
private void updateDepthPixels()
|
|
{
|
|
{
|
|
- for (int x = 0; x < currentImage.getWidth(); x++)
|
|
|
|
- {
|
|
|
|
- for (int y = 0; y < currentImage.getHeight(); y++)
|
|
|
|
- {
|
|
|
|
- Point depthPixel = depthPixels[x, y];
|
|
|
|
|
|
+ VertexArray vertexArray = source.getVertexArray();
|
|
|
|
+ int numVertices = vertexArray.getNumVertices();
|
|
|
|
|
|
- depthPixel.position.z = currentImage.getDepth(x, y);
|
|
|
|
- depthPixel.color = currentImage.getColor(x, y);
|
|
|
|
- }
|
|
|
|
|
|
+ for (int i = 0; i < numVertices; i++)
|
|
|
|
+ {
|
|
|
|
+ depthPixels[i].position = vertexArray.getVertex(i);
|
|
|
|
+ depthPixels[i].color = vertexArray.getColor(i);
|
|
}
|
|
}
|
|
|
|
+ Vector palmPosition = source.getPalmPosition3D(1);
|
|
|
|
+ palmPoint.position.x = palmPosition[0];
|
|
|
|
+ palmPoint.position.y = palmPosition[2];
|
|
|
|
+ palmPoint.position.z = palmPosition[1];
|
|
}
|
|
}
|
|
|
|
|
|
private void initBuffers()
|
|
private void initBuffers()
|
|
@@ -130,7 +137,7 @@ namespace bbiwarg.Graphics
|
|
|
|
|
|
foreach (IGraphicElement graphicElement in graphicElements)
|
|
foreach (IGraphicElement graphicElement in graphicElements)
|
|
{
|
|
{
|
|
- List<Vector> elementVertices = graphicElement.getVertices(currentImage.getWidth(), currentImage.getHeight());
|
|
|
|
|
|
+ List<Vector> elementVertices = graphicElement.getVertices();
|
|
uint[] elementTriangles = graphicElement.getTriangleIndices();
|
|
uint[] elementTriangles = graphicElement.getTriangleIndices();
|
|
Color elementColor = graphicElement.getColor();
|
|
Color elementColor = graphicElement.getColor();
|
|
|
|
|