瀏覽代碼

Changed VertexArray and getVertexArray() to store all vertices in big array.

Daniel Kauth 11 年之前
父節點
當前提交
0c902026f3
共有 3 個文件被更改,包括 18 次插入14 次删除
  1. 8 8
      bbiwarg/DataSource/IisuDataSource.cs
  2. 9 6
      bbiwarg/DataSource/VertexArray.cs
  3. 1 0
      bbiwarg/bbiwarg.csproj

+ 8 - 8
bbiwarg/DataSource/IisuDataSource.cs

@@ -358,7 +358,7 @@ namespace bbiwarg.DataSource
 
         public VertexArray getVertexArray()
         {
-            Vertex[] vertices = new Vertex[width * height];
+            float[] vertexData = new float[3 * width * height];
             Color[] colors = new Color[width * height];
 
             int index = 0;
@@ -367,19 +367,17 @@ namespace bbiwarg.DataSource
                 for (int y = 0; y < height; y++)
                 {
                     int depth = currentImage.getDepth(x, y);
-                    vertices[index] = create3DVertexFrom2D(x, y, depth);
+                    create3DVertexFrom2D(x, y, depth, vertexData, 3 * index);
                     colors[index] = currentImage.getColor(x, y);
 
                     index++;
                 }
-
-
             }
-
-            return new VertexArray(vertices, colors);
+    
+            return new VertexArray(vertexData, colors);
         }
 
-        private Vertex create3DVertexFrom2D(float pixelX, float pixelY, int depth)
+        private void create3DVertexFrom2D(float pixelX, float pixelY, int depth, float[] vertexData, int index)
         {
             float convertedDepth = depth / 1000f; // mm into m
 
@@ -393,7 +391,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;
         }
     }
 }

+ 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) {

+ 1 - 0
bbiwarg/bbiwarg.csproj

@@ -63,6 +63,7 @@
     <Compile Include="DataSource\DepthImage.cs" />
     <Compile Include="DataSource\IisuDataSource.cs" />
     <Compile Include="DataSource\IVideoDataSource.cs" />
+    <Compile Include="DataSource\VectorExtender.cs" />
     <Compile Include="DataSource\VertexArray.cs" />
     <Compile Include="Graphics\Rectangle.cs" />
     <Compile Include="Graphics\IGraphicElement.cs" />