Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/etri-smartspaces

Conflicts:
	bbiwarg/DataSource/IisuInputProvider.cs
	bbiwarg/bbiwarg.csproj
Alexander Hendrich 11 years ago
parent
commit
5906614cbc

+ 2 - 2
bbiwarg/DataSource/IisuInputProvider.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Drawing;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
@@ -358,4 +358,4 @@ namespace bbiwarg.DataSource
         }
 
     }
-}
+}

+ 28 - 0
bbiwarg/DataSource/VectorExtender.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using MathNet.Numerics.LinearAlgebra.Single;
+
+namespace bbiwarg.DataSource
+{
+    public static class VectorExtender
+    {
+        public static float x(this Vector v)
+        {
+            return v[0];
+        }
+
+        public static float y(this Vector v)
+        {
+            return v[1];
+        }
+
+        public static float z(this Vector v)
+        {
+            return v[2];
+        }
+    }
+}

+ 9 - 6
bbiwarg/DataSource/VertexArray.cs

@@ -6,26 +6,29 @@ using System.Text;
 using System.Threading.Tasks;
 using bbiwarg.Graphics;
 
+using MathNet.Numerics.LinearAlgebra.Single;
+
 namespace bbiwarg.DataSource
 {
     class VertexArray
     {
-        private Vertex[] vertices;
+        private float[] vertexData;
         private Color[] colors;
 
-        public VertexArray(Vertex[] vertices, Color[] colors)
+        public VertexArray(float[] vertexData, Color[] colors)
         {
-            this.vertices = vertices;
+            this.vertexData = vertexData;
             this.colors = colors;
         }
 
         public int getNumVertices() 
         {
-            return vertices.Length;
+            return vertexData.Length / 3;
         }
 
-        public Vertex getVertex(int i) {
-            return vertices[i];
+        public float[] getVertexData()
+        {
+            return vertexData;
         }
 
         public Color getColor(int i) {

+ 7 - 7
bbiwarg/DataSource/VideoHandle.cs

@@ -88,7 +88,7 @@ namespace bbiwarg.DataSource
             int width = depthImage.getWidth();
             int height = depthImage.getHeight();
 
-            Vertex[] vertices = new Vertex[width * height];
+            float[] vertexData = new float[3 * width * height];
             Color[] colors = new Color[width * height];
 
             int index = 0;
@@ -97,19 +97,17 @@ namespace bbiwarg.DataSource
                 for (int y = 0; y < height; y++)
                 {
                     int depth = depthImage.getDepth(x, y);
-                    vertices[index] = create3DVertexFrom2D(x, y, depth);
+                    create3DVertexFrom2D(x, y, depth, vertexData, 3 * index);
                     colors[index] = getColor(x, y);
 
                     index++;
                 }
-
-
             }
 
-            return new VertexArray(vertices, colors);
+            return new VertexArray(vertexData, colors);
         }
 
-        public Vertex create3DVertexFrom2D(float pixelX, float pixelY, int depth)
+        private void create3DVertexFrom2D(float pixelX, float pixelY, int depth, float[] vertexData, int index)
         {
             int width = depthImage.getWidth();
             int height = depthImage.getHeight();
@@ -126,7 +124,9 @@ namespace bbiwarg.DataSource
             float x = relX * z;
             float y = relY * z;
 
-            return new Vertex(x, y, z);
+            vertexData[index + 0] = x;
+            vertexData[index + 1] = y;
+            vertexData[index + 2] = z;
         }
         
         

+ 1 - 0
bbiwarg/bbiwarg.csproj

@@ -63,6 +63,7 @@
     <Compile Include="DataSource\DepthImage.cs" />
     <Compile Include="DataSource\IisuInputProvider.cs" />
     <Compile Include="DataSource\IVideoHandle.cs" />
+    <Compile Include="DataSource\VectorExtender.cs" />
     <Compile Include="DataSource\VertexArray.cs" />
     <Compile Include="DataSource\VideoHandle.cs" />
     <Compile Include="Graphics\Rectangle.cs" />