Browse Source

-added PalmPosition2D
-created Class Pixel3D
-integrated Pixel3D into OutputTest

Anton 11 years ago
parent
commit
0c0bfb2023

+ 2 - 1
bbiwarg/DataSource/IVideoDataSource.cs

@@ -65,7 +65,8 @@ namespace bbiwarg.DataSource
          * all handIndices have to be 1 or 2
          */
         bool isHandOpen(uint handIndex);
-        Vector getPalmPosition3D(uint handIndex);
+        Vector getPalmPosition3D(uint handIndex);
+        Vector getPalmPosition2D(uint handIndex);
         Vector getTipPosition3D(uint handIndex);
         Vector getForearmPosition3D(uint handIndex);
         Vector getPalmNormal3D(uint handIndex);

+ 273 - 263
bbiwarg/DataSource/IisuDataSource.cs

@@ -1,181 +1,185 @@
-using System;
-using System.Runtime.InteropServices;
-
-using Iisu;
-using MathNet.Numerics.LinearAlgebra.Single;
-
-namespace bbiwarg.DataSource
-{
-    class IIsuDataSource: IVideoDataSource
-    {
-        private IHandle handle;
-        private IDevice device;
-        private string moviePath;
-        bool active;
-
-        // parameters
-        private IParameterHandle<float> frameRate;
-
-        // data
-        private IDataHandle<bool>[] handOpen = new IDataHandle<bool>[2];
-        private IDataHandle<Iisu.Data.Vector3>[] palmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
-        private IDataHandle<Iisu.Data.Vector3>[] tipPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
-        private IDataHandle<Iisu.Data.Vector3>[] forearmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
-        private IDataHandle<Iisu.Data.Vector3>[] palmNormals3D = new IDataHandle<Iisu.Data.Vector3>[2];
-        private IDataHandle<int[]>[] fingerStatus = new IDataHandle<int[]>[2];
-        private IDataHandle<Iisu.Data.Vector3[]>[] fingerTipPositions3D = new IDataHandle<Iisu.Data.Vector3[]>[2];
-        private IDataHandle<int>[] handSides = new IDataHandle<int>[2];
-        private IDataHandle<Iisu.Data.IImageData> depthImage;
-        private IDataHandle<Iisu.Data.IImageData> colorImage;
-        private IDataHandle<Iisu.Data.IImageData> confidenceImage;
-        private IDataHandle<Iisu.Data.Vertex[]> vertexArray;
-
-        /*
-         * Creates an Iisu data source.
-         * params:
-         *  moviePath: path to movie to be used as source
-         *             if empty the camera is used
-         */
-        public IIsuDataSource(string moviePath = "")
-        {
-            this.moviePath = moviePath;
-            active = false;
-        }
-
-        public void init()
-        {
-            handle = Iisu.Iisu.Context.CreateHandle();
-            
-            IDeviceConfiguration conf = handle.CreateDeviceConfiguration();
-            if (moviePath.Length != 0)
-                conf.MoviePath = moviePath;
-
-            device = handle.InitializeDevice(conf);
-
-            // parameters
-            if (moviePath.Length != 0)
-                device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayMode").Value = 0; // playMode = once
+using System;
+using System.Runtime.InteropServices;
+
+using Iisu;
+using MathNet.Numerics.LinearAlgebra.Single;
+
+namespace bbiwarg.DataSource
+{
+    class IIsuDataSource: IVideoDataSource
+    {
+        private IHandle handle;
+        private IDevice device;
+        private string moviePath;
+        bool active;
+
+        // parameters
+        private IParameterHandle<float> frameRate;
+
+        // data
+        private IDataHandle<bool>[] handOpen = new IDataHandle<bool>[2];
+        private IDataHandle<Iisu.Data.Vector3>[] palmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
+        private IDataHandle<Iisu.Data.Vector2>[] palmPositions2D = new IDataHandle<Iisu.Data.Vector2>[2];
+        private IDataHandle<Iisu.Data.Vector3>[] tipPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
+        private IDataHandle<Iisu.Data.Vector3>[] forearmPositions3D = new IDataHandle<Iisu.Data.Vector3>[2];
+        private IDataHandle<Iisu.Data.Vector3>[] palmNormals3D = new IDataHandle<Iisu.Data.Vector3>[2];
+        private IDataHandle<int[]>[] fingerStatus = new IDataHandle<int[]>[2];
+        private IDataHandle<Iisu.Data.Vector3[]>[] fingerTipPositions3D = new IDataHandle<Iisu.Data.Vector3[]>[2];
+        private IDataHandle<int>[] handSides = new IDataHandle<int>[2];
+        private IDataHandle<Iisu.Data.IImageData> depthImage;
+        private IDataHandle<Iisu.Data.IImageData> colorImage;
+        private IDataHandle<Iisu.Data.IImageData> confidenceImage;
+        private IDataHandle<Iisu.Data.Vertex[]> vertexArray;
+
+        /*
+         * Creates an Iisu data source.
+         * params:
+         *  moviePath: path to movie to be used as source
+         *             if empty the camera is used
+         */
+        public IIsuDataSource(string moviePath = "")
+        {
+            this.moviePath = moviePath;
+            active = false;
+        }
+
+        public void init()
+        {
+            handle = Iisu.Iisu.Context.CreateHandle();
+            
+            IDeviceConfiguration conf = handle.CreateDeviceConfiguration();
+            if (moviePath.Length != 0)
+                conf.MoviePath = moviePath;
+
+            device = handle.InitializeDevice(conf);
+
+            // parameters
+            if (moviePath.Length != 0)
+                device.RegisterParameterHandle<int>("SOURCE.MOVIE.PlayMode").Value = 0; // playMode = once
             else
-                device.RegisterParameterHandle<int>("SOURCE.DEPTHSENSE.AmplitudeThreshold").Value = 100; // confidence-threshhold
-
+                device.RegisterParameterHandle<int>("SOURCE.DEPTHSENSE.AmplitudeThreshold").Value = 100; // confidence-threshhold
+
             frameRate = device.RegisterParameterHandle<float>("SOURCE.FrameRate");
-
-            // events
-            device.EventManager.RegisterEventListener("DEVICE.Status", new Iisu.EventDelegates.Device.Status(onDeviceStatusChanged));
-            
-            // data
-            depthImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.DEPTH.Image");
-            colorImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.Image");
-            confidenceImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.CONFIDENCE.Image");
-           
-            handOpen[0] = device.RegisterDataHandle<bool>("CI.HAND1.IsOpen");
-            handOpen[1] = device.RegisterDataHandle<bool>("CI.HAND2.IsOpen");
-
-            palmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmPosition3D");
-            palmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmPosition3D");
-
-            tipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.TipPosition3D");
-            tipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.TipPosition3D");
-
-            forearmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.ForearmPosition3D");
-            forearmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.ForearmPosition3D");
-
-            palmNormals3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmNormal3D");
-            palmNormals3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmNormal3D");
-
-            fingerStatus[0] = device.RegisterDataHandle<int[]>("CI.HAND1.FingerStatus");
-            fingerStatus[1] = device.RegisterDataHandle<int[]>("CI.HAND2.FingerStatus");
-
-            fingerTipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND1.FingerTipPositions3D");
-            fingerTipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND2.FingerTipPositions3D");
-
-            handSides[0] = device.RegisterDataHandle<int>("CI.HAND1.Side");
-            handSides[1] = device.RegisterDataHandle<int>("CI.HAND1.Side");
-        }
-
-        private void onDeviceStatusChanged(string eventName, DeviceStatus status)
-        {
-            active = status.HasFlag(Iisu.DeviceStatus.Playing);
+
+            // events
+            device.EventManager.RegisterEventListener("DEVICE.Status", new Iisu.EventDelegates.Device.Status(onDeviceStatusChanged));
+            
+            // data
+            depthImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.DEPTH.Image");
+            colorImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.COLOR.Image");
+            confidenceImage = device.RegisterDataHandle<Iisu.Data.IImageData>("SOURCE.CAMERA.CONFIDENCE.Image");
+           
+            handOpen[0] = device.RegisterDataHandle<bool>("CI.HAND1.IsOpen");
+            handOpen[1] = device.RegisterDataHandle<bool>("CI.HAND2.IsOpen");
+
+            palmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmPosition3D");
+            palmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmPosition3D");
+
+            palmPositions2D[0] = device.RegisterDataHandle<Iisu.Data.Vector2>("CI.HAND1.PalmPosition2D");
+            palmPositions2D[1] = device.RegisterDataHandle<Iisu.Data.Vector2>("CI.HAND2.PalmPosition2D");
+
+            tipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.TipPosition3D");
+            tipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.TipPosition3D");
+
+            forearmPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.ForearmPosition3D");
+            forearmPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.ForearmPosition3D");
+
+            palmNormals3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmNormal3D");
+            palmNormals3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND2.PalmNormal3D");
+
+            fingerStatus[0] = device.RegisterDataHandle<int[]>("CI.HAND1.FingerStatus");
+            fingerStatus[1] = device.RegisterDataHandle<int[]>("CI.HAND2.FingerStatus");
+
+            fingerTipPositions3D[0] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND1.FingerTipPositions3D");
+            fingerTipPositions3D[1] = device.RegisterDataHandle<Iisu.Data.Vector3[]>("CI.HAND2.FingerTipPositions3D");
+
+            handSides[0] = device.RegisterDataHandle<int>("CI.HAND1.Side");
+            handSides[1] = device.RegisterDataHandle<int>("CI.HAND1.Side");
+        }
+
+        private void onDeviceStatusChanged(string eventName, DeviceStatus status)
+        {
+            active = status.HasFlag(Iisu.DeviceStatus.Playing);
             if (vertexArray != null && !vertexArray.Valid && active)
-                vertexArray = device.RegisterDataHandle<Iisu.Data.Vertex[]>("SCENE.VertexArray");
-        }
-
-        public void start()
-        {
-            device.Start();
-        }
-
-        public void stop()
-        {
-            device.Stop(true);
-        }
-
-        public void updateFrame()
-        {
-            device.UpdateFrame(true);
-        }
-
-        public void releaseFrame()
-        {
-            device.ReleaseFrame();
-        }
-
-        public bool isActive()
-        {
-            return active;
-        }
-
-        public int getFrameRate()
-        {
-            return (int) frameRate.Value;
-        }
-
-        public DepthImage getDepthImage()
-        {
-            Iisu.Data.IImageInfos imageInfos = depthImage.Value.ImageInfos;
-            int width = (int) imageInfos.Width;
-            int height = (int) imageInfos.Height;
-            int numBytes = (int) imageInfos.BytesRaw;
-
-            IntPtr imageData = depthImage.Value.Raw;
-            
-            short[] depthData = new short[width * height];
-            Marshal.Copy(imageData, depthData, 0, width * height);
-
-            return new DepthImage(width, height, depthData);
-        }
-
-        public ColorImage getColorImage()
-        {
-            Iisu.Data.IImageInfos imageInfos = colorImage.Value.ImageInfos;
-            int width = (int)imageInfos.Width;
-            int height = (int)imageInfos.Height;
-            int numBytes = (int)imageInfos.BytesRaw;
-
-            IntPtr imageData = colorImage.Value.Raw;
-
-            byte[] colorData = new byte[numBytes];
-            Marshal.Copy(imageData, colorData, 0, numBytes);
-
-            return new ColorImage(width, height, colorData);
-        }
-
-        public ConfidenceImage getConfidenceImage()
-        {
-            Iisu.Data.IImageInfos imageInfos = confidenceImage.Value.ImageInfos;
-            int width = (int)imageInfos.Width;
-            int height = (int)imageInfos.Height;
-            int numBytes = (int)imageInfos.BytesRaw;
-
-            IntPtr imageData = confidenceImage.Value.Raw;
-
-            short[] confidenceData = new short[width * height];
-            Marshal.Copy(imageData, confidenceData, 0, width * height);
-
-            return new ConfidenceImage(width, height, confidenceData);
-        }
-
-        public VertexArray getVertexArray()
+                vertexArray = device.RegisterDataHandle<Iisu.Data.Vertex[]>("SCENE.VertexArray");
+        }
+
+        public void start()
+        {
+            device.Start();
+        }
+
+        public void stop()
+        {
+            device.Stop(true);
+        }
+
+        public void updateFrame()
+        {
+            device.UpdateFrame(true);
+        }
+
+        public void releaseFrame()
+        {
+            device.ReleaseFrame();
+        }
+
+        public bool isActive()
+        {
+            return active;
+        }
+
+        public int getFrameRate()
+        {
+            return (int) frameRate.Value;
+        }
+
+        public DepthImage getDepthImage()
+        {
+            Iisu.Data.IImageInfos imageInfos = depthImage.Value.ImageInfos;
+            int width = (int) imageInfos.Width;
+            int height = (int) imageInfos.Height;
+            int numBytes = (int) imageInfos.BytesRaw;
+
+            IntPtr imageData = depthImage.Value.Raw;
+            
+            short[] depthData = new short[width * height];
+            Marshal.Copy(imageData, depthData, 0, width * height);
+
+            return new DepthImage(width, height, depthData);
+        }
+
+        public ColorImage getColorImage()
+        {
+            Iisu.Data.IImageInfos imageInfos = colorImage.Value.ImageInfos;
+            int width = (int)imageInfos.Width;
+            int height = (int)imageInfos.Height;
+            int numBytes = (int)imageInfos.BytesRaw;
+
+            IntPtr imageData = colorImage.Value.Raw;
+
+            byte[] colorData = new byte[numBytes];
+            Marshal.Copy(imageData, colorData, 0, numBytes);
+
+            return new ColorImage(width, height, colorData);
+        }
+
+        public ConfidenceImage getConfidenceImage()
+        {
+            Iisu.Data.IImageInfos imageInfos = confidenceImage.Value.ImageInfos;
+            int width = (int)imageInfos.Width;
+            int height = (int)imageInfos.Height;
+            int numBytes = (int)imageInfos.BytesRaw;
+
+            IntPtr imageData = confidenceImage.Value.Raw;
+
+            short[] confidenceData = new short[width * height];
+            Marshal.Copy(imageData, confidenceData, 0, width * height);
+
+            return new ConfidenceImage(width, height, confidenceData);
+        }
+
+        public VertexArray getVertexArray()
         {
             if (vertexArray != null && vertexArray.Valid)
             {
@@ -196,91 +200,97 @@ namespace bbiwarg.DataSource
             else
             {
                 return new VertexArray(new DenseVector[0], new Color4[0]);
-            }
-        }
-
-        private void checkHandIndex(uint handIndex) 
-        {
-            if (handIndex < 1 || handIndex > 2)
-                throw new ArgumentOutOfRangeException("handIndex is out of range [0,1]");
-        }
-
-        public bool isHandOpen(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            return handOpen[handIndex - 1].Value;
-        }
-
-        public Vector getPalmPosition3D(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            return new DenseVector(palmPositions3D[handIndex - 1].Value.ToArray());
-        }
-
-        public Vector getTipPosition3D(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            return new DenseVector(tipPositions3D[handIndex - 1].Value.ToArray());
-        }
-
-        public Vector getForearmPosition3D(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            return new DenseVector(forearmPositions3D[handIndex - 1].Value.ToArray());
-        }
-
-        public Vector getPalmNormal3D(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            return new DenseVector(palmNormals3D[handIndex - 1].Value.ToArray());
-        }
-
-        public FingerStatus[] getFingerStatus(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            int[] status = fingerStatus[handIndex - 1].Value;
-            FingerStatus[] result = new FingerStatus[status.Length];
-            for (int i = 0; i < status.Length; ++i)
-            {
-                switch (status[i])
-                {
-                    case 0:
-                        result[i] = FingerStatus.Inactive;
-                        break;
-                    case 1:
-                        result[i] = FingerStatus.Detected;
-                        break;
-                    case 2:
-                        result[i] = FingerStatus.Tracked;
-                        break;
-                }
-            }
-            return result;
-        }
-
-        public Vector[] getFingerTipPositions3D(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            Iisu.Data.Vector3[] positions = fingerTipPositions3D[handIndex - 1].Value;
-            Vector[] results = new DenseVector[positions.Length];
-            for (int i = 0; i < positions.Length; ++i)
-                results[i] = new DenseVector(positions[i].ToArray());
-            return results;
-        }
-
-        public HandSide getHandSide(uint handIndex)
-        {
-            checkHandIndex(handIndex);
-            int side = handSides[handIndex - 1].Value;
-            switch (side) 
-            {
-                case 1:
-                    return HandSide.Left;
-                case 2:
-                    return HandSide.Right;
-                default:
-                    return HandSide.Unknown;
-            }
-        }
-    }
-}
+            }
+        }
+
+        private void checkHandIndex(uint handIndex) 
+        {
+            if (handIndex < 1 || handIndex > 2)
+                throw new ArgumentOutOfRangeException("handIndex is out of range [0,1]");
+        }
+
+        public bool isHandOpen(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return handOpen[handIndex - 1].Value;
+        }
+
+        public Vector getPalmPosition3D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return new DenseVector(palmPositions3D[handIndex - 1].Value.ToArray());
+        }
+
+        public Vector getPalmPosition2D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return new DenseVector(palmPositions2D[handIndex - 1].Value.ToArray());
+        }
+
+        public Vector getTipPosition3D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return new DenseVector(tipPositions3D[handIndex - 1].Value.ToArray());
+        }
+
+        public Vector getForearmPosition3D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return new DenseVector(forearmPositions3D[handIndex - 1].Value.ToArray());
+        }
+
+        public Vector getPalmNormal3D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            return new DenseVector(palmNormals3D[handIndex - 1].Value.ToArray());
+        }
+
+        public FingerStatus[] getFingerStatus(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            int[] status = fingerStatus[handIndex - 1].Value;
+            FingerStatus[] result = new FingerStatus[status.Length];
+            for (int i = 0; i < status.Length; ++i)
+            {
+                switch (status[i])
+                {
+                    case 0:
+                        result[i] = FingerStatus.Inactive;
+                        break;
+                    case 1:
+                        result[i] = FingerStatus.Detected;
+                        break;
+                    case 2:
+                        result[i] = FingerStatus.Tracked;
+                        break;
+                }
+            }
+            return result;
+        }
+
+        public Vector[] getFingerTipPositions3D(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            Iisu.Data.Vector3[] positions = fingerTipPositions3D[handIndex - 1].Value;
+            Vector[] results = new DenseVector[positions.Length];
+            for (int i = 0; i < positions.Length; ++i)
+                results[i] = new DenseVector(positions[i].ToArray());
+            return results;
+        }
+
+        public HandSide getHandSide(uint handIndex)
+        {
+            checkHandIndex(handIndex);
+            int side = handSides[handIndex - 1].Value;
+            switch (side) 
+            {
+                case 1:
+                    return HandSide.Left;
+                case 2:
+                    return HandSide.Right;
+                default:
+                    return HandSide.Unknown;
+            }
+        }
+    }
+}

+ 39 - 20
bbiwarg/Test/OutputTest.cs

@@ -14,6 +14,8 @@ namespace bbiwarg.Test
     class OutputTest : GameWindow
     {
         IVideoDataSource source;
+        private List<Triangle> triangles = new List<Triangle>();
+        private List<Pixel3D> pixel = new List<Pixel3D>();
 
         static void Main(string[] args)
         {
@@ -25,10 +27,20 @@ namespace bbiwarg.Test
 
         public void initSource()
         {
-            source = new IIsuDataSource("..\\..\\videos\\1.skv");
+            source = new IIsuDataSource("..\\..\\videos\\10.skv");
             source.init();
             source.start();
 
+            int width = 320;
+            int height = 160;
+
+            for (int x = 0; x < width; x++)
+            {
+                for (int y = 0; y < height; y++)
+                {
+                    pixel.Add(new Pixel3D(x,y,width,height));
+                }
+            }
         }
 
         protected override void OnLoad(EventArgs e)
@@ -60,30 +72,30 @@ namespace bbiwarg.Test
             int width = depthImage.getWidth();
             int height = depthImage.getHeight();
 
-            for (int x = 0; x < width-1; x++) {
-                for (int y = 0; y < height-1; y++)
-                {
-                    short confidence = confidenceImage.getConfidence(x,y);
-
-                    if(confidence > 100) {
-                        short depth = depthImage.getDepth(x, y);
 
+            
+            for (int i = 0; i < pixel.Count; i++)
+            {
+                pixel[i].depth = depthImage.getDepth(pixel[i].x, pixel[i].y);
+                pixel[i].draw();
+            }
 
-                        int relX = x - width / 2;
-                        int relY = height/2 - y;
+            Vector palmVertex = source.getPalmPosition3D(1);
+            Vector palmPixel = source.getPalmPosition2D(1);
+            Pixel3D palmPosition = new Pixel3D((int) palmPixel[0], (int) palmPixel[1], width, height);
+            palmPosition.depth = (short) (palmVertex[1] * 1000);
+            palmPosition.color = Color.Red;
+            palmPosition.size = 3;
+            palmPosition.draw();
+            //Console.WriteLine(palmPosition.toString());
+            
+           
 
-                        GL.Begin(BeginMode.Polygon);
-                        GL.Vertex3(relX-0.5f, relY+0.5f, -depth);
-                        GL.Vertex3(relX+0.5f, relY+0.5f, -depth);
-                        GL.Vertex3(relX+0.5f, relY-0.5f, -depth);
-                        GL.Vertex3(relX-0.5f, relY-0.5f, -depth);
-                        GL.End();
-                    }
-                }
+            for (int i = 0; i < triangles.Count; i++)
+            {
+                triangles[i].draw();
             }
 
-            //Triangle triangle = new Triangle(new DenseVector(new float[] { 0.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 100.0f, 0.0f, -100.0f }), new DenseVector(new float[] { 0.0f, 100.0f, -100.0f }));
-
             /*
             GL.Begin(BeginMode.Triangles);
             GL.Vertex3(0.0f, 0.0f, -4.0f);
@@ -128,5 +140,12 @@ namespace bbiwarg.Test
             GL.MatrixMode(MatrixMode.Projection);
             GL.LoadMatrix(ref projection);
         }
+
+        
+
+        public void addSurface(Triangle triangle)
+        {
+            triangles.Add(triangle);
+        }
     }
 }

+ 52 - 0
bbiwarg/Test/Pixel3D.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Drawing;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using MathNet.Numerics.LinearAlgebra.Single;
+
+namespace bbiwarg.Test
+{
+    class Pixel3D
+    {
+        public int x;
+        public int y;
+        public short depth = 100;
+        private int width;
+        private int height;
+        public Color color = Color.White;
+        public float size = 0.5f;
+
+        public Pixel3D(int x, int y, int width, int height){
+            this.x = x;
+            this.y = y;
+            this.width = width;
+            this.height = height;
+        }
+
+        public void draw(){
+             int relX = x - width / 2;
+             int relY = height/2 - y;
+
+
+             GL.Color3(color);
+
+             GL.Begin(BeginMode.Polygon);
+             GL.Vertex3(relX - size, relY + size, -depth);
+             GL.Vertex3(relX + size, relY + size, -depth);
+             GL.Vertex3(relX + size, relY - size, -depth);
+             GL.Vertex3(relX - size, relY - size, -depth);
+             GL.End();
+
+        }
+
+        public string toString()
+        {
+            return "x: " + x + "y: " + y + " depth: " + depth;
+        }
+
+    }
+}

+ 12 - 3
bbiwarg/Test/Triangle.cs

@@ -12,9 +12,9 @@ namespace bbiwarg.Test
 {
     class Triangle
     {
-        private Vector a;
-        private Vector b;
-        private Vector c;
+        public Vector a;
+        public Vector b;
+        public Vector c;
 
         public Triangle(Vector a, Vector b, Vector c)
 	    {
@@ -34,5 +34,14 @@ namespace bbiwarg.Test
             GL.End();
         }
 
+        public void setVectors(Vector a, Vector b, Vector c)
+        {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+
+        
+
     }
 }

+ 2 - 1
bbiwarg/bbiwarg.csproj

@@ -32,7 +32,7 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <PropertyGroup>
-    <StartupObject>bbiwarg.Test.TestDataSource</StartupObject>
+    <StartupObject>bbiwarg.Test.OutputTest</StartupObject>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="iisuNet, Version=3.0.0.0, Culture=neutral, processorArchitecture=x86">
@@ -65,6 +65,7 @@
     <Compile Include="DataSource\VertexArray.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Test\OutputTest.cs" />
+    <Compile Include="Test\Pixel3D.cs" />
     <Compile Include="Test\TestDataSource.cs" />
     <Compile Include="Test\Triangle.cs" />
   </ItemGroup>