Browse Source

cleanup graphic-namespace2

Alexander Hendrich 11 years ago
parent
commit
f629a1e154
4 changed files with 149 additions and 149 deletions
  1. 2 2
      bbiwarg/Graphics/Output2D.cs
  2. 144 144
      bbiwarg/Graphics/Output3D.cs
  3. 1 1
      bbiwarg/Main/OutputTest.cs
  4. 2 2
      bbiwarg/bbiwarg.csproj

+ 2 - 2
bbiwarg/Graphics/OutputDepthImage.cs → bbiwarg/Graphics/Output2D.cs

@@ -14,12 +14,12 @@ using bbiwarg.Graphics.GraphicElements2D;
 
 namespace bbiwarg.Graphics
 {
-    class OutputDepthImage: GameWindow
+    class Output2D: GameWindow
     {
         private IInputProvider input;
         private uint textureId;
 
-        public OutputDepthImage(IInputProvider input): base(3 * 320, 3 * 240)
+        public Output2D(IInputProvider input): base(3 * 320, 3 * 240)
         {
             this.input = input;
         }

+ 144 - 144
bbiwarg/Graphics/Output.cs → bbiwarg/Graphics/Output3D.cs

@@ -1,144 +1,144 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using OpenTK;
-using OpenTK.Graphics.OpenGL;
-using MathNet.Numerics.LinearAlgebra.Single;
-using bbiwarg.DataSource;
-using bbiwarg.Graphics.GraphicElements3D;
-
-
-namespace bbiwarg.Graphics
-{
-    class Output : GameWindow
-    {
-        private IVideoHandle videoHandle;
-
-        private uint imageBufferId;
-
-        public Output(IVideoHandle videoHandle)
-        {
-            this.videoHandle = videoHandle;
-        }
-
-        protected override void OnLoad(EventArgs e)
-        {
-            base.OnLoad(e);
-            Title = "OutputTest";
-            GL.ClearColor(Color.Black);
-
-            // transparency
-            GL.Enable(EnableCap.Blend);
-            GL.BlendEquation(BlendEquationMode.Max);
-
-            //Depth Test 
-            GL.Enable(EnableCap.DepthTest);
-
-
-            initBuffers();
-
-            GL.Enable(EnableCap.Blend);
-            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
-        }
-
-        protected override void OnRenderFrame(FrameEventArgs e)
-        {
-            base.OnRenderFrame(e);
-            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
-            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, -Vector3.UnitZ, Vector3.UnitY);
-            GL.MatrixMode(MatrixMode.Modelview);
-            GL.LoadMatrix(ref modelview);
-
-            videoHandle.nextFrame();
-
-            Stopwatch sw = new Stopwatch();
-            sw.Start();
-
-            drawDepthImage();
-
-            // palm (iisu)
-            Vector palmPosition = videoHandle.getPalmPosition3D(1);
-            Point3D palmPoint = new Point3D(palmPosition, Color.Yellow, 0.005f);
-            palmPoint.draw();
-
-            // foreFinger
-            Vector foreFingerPosition = videoHandle.getForeFingerPosition3D(1);
-            Point3D foreFingerPoint = new Point3D(foreFingerPosition, Color.Red, 0.05f);
-            foreFingerPoint.draw();
-
-            //handPoints
-            List<Vector> handPoints = videoHandle.getHandPoints();
-            for (int i = 0; i < handPoints.Count(); i++)
-            {
-                new Point3D(videoHandle.pixel2VertexPosition(handPoints[i]), Color.Yellow, 0.001f).draw();
-            }
-
-            // foreArm (iisu)
-            Vector foreArmPosition = videoHandle.getForearmPosition3D(1);
-            Point3D foreArmPoint = new Point3D(foreArmPosition, Color.Yellow, 0.005f);
-            foreArmPoint.draw();
-
-            // finger (iisu)
-            Vector[] fingerPositions = videoHandle.getFingerTipPositions3D(1);
-            DetectionStatus[] fingerStatus = videoHandle.getFingerStatus(1);
-            for (int i = 0; i < fingerStatus.Length; ++i)
-            {
-                if (fingerStatus[i] == DetectionStatus.Detected || fingerStatus[i] == DetectionStatus.Tracked)
-                {
-                    Point3D fingerPoint = new Point3D(fingerPositions[i], Color.Yellow, 0.005f);
-                    fingerPoint.draw();
-                }
-            }
-
-            // palm
-            Palm palm = videoHandle.getPalm(1);
-            Rectangle3D palmRect = new Rectangle3D(palm.getCorners(), Color.FromArgb(128, Color.Blue));
-            palmRect.draw();
-
-            sw.Stop();
-            Console.WriteLine(sw.ElapsedMilliseconds);
-
-            SwapBuffers();
-        }
-
-        protected override void OnResize(EventArgs e)
-        {
-            base.OnResize(e);
-            GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
-            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 3, Width / (float)Height, 0.01f, 3.0f);
-            GL.MatrixMode(MatrixMode.Projection);
-            GL.LoadMatrix(ref projection);
-        }
-
-        private void initBuffers()
-        {
-            GL.GenBuffers(1, out imageBufferId);
-
-            GL.BindBuffer(BufferTarget.ArrayBuffer, imageBufferId);
-            GL.BufferData(BufferTarget.ArrayBuffer, 
-                          (IntPtr)((3 * sizeof(float) + 4  * sizeof(byte)) * videoHandle.getWidth() * videoHandle.getHeight()), 
-                          IntPtr.Zero, BufferUsageHint.StreamDraw);
-        }
-
-        private void drawDepthImage()
-        {
-            GL.EnableClientState(ArrayCap.VertexArray);
-            GL.EnableClientState(ArrayCap.ColorArray);
-
-            GL.BindBuffer(BufferTarget.ArrayBuffer, imageBufferId);
-            videoHandle.createVertexArray(GL.MapBuffer(BufferTarget.ArrayBuffer, BufferAccess.WriteOnly));
-            GL.UnmapBuffer(BufferTarget.ArrayBuffer);
-
-            GL.VertexPointer(3, VertexPointerType.Float, 3 * sizeof(float) + 4 * sizeof(byte), IntPtr.Zero);
-            GL.ColorPointer(4, ColorPointerType.UnsignedByte, 3 * sizeof(float) + 4 * sizeof(byte), 3 * sizeof(float));
-
-            GL.PointSize(2.0f);
-            GL.DrawArrays(PrimitiveType.Points, 0, videoHandle.getWidth() * videoHandle.getHeight());
-           
-        }
-    }
-}
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using MathNet.Numerics.LinearAlgebra.Single;
+using bbiwarg.DataSource;
+using bbiwarg.Graphics.GraphicElements3D;
+
+
+namespace bbiwarg.Graphics
+{
+    class Output3D : GameWindow
+    {
+        private IVideoHandle videoHandle;
+
+        private uint imageBufferId;
+
+        public Output3D(IVideoHandle videoHandle)
+        {
+            this.videoHandle = videoHandle;
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            base.OnLoad(e);
+            Title = "OutputTest";
+            GL.ClearColor(Color.Black);
+
+            // transparency
+            GL.Enable(EnableCap.Blend);
+            GL.BlendEquation(BlendEquationMode.Max);
+
+            //Depth Test 
+            GL.Enable(EnableCap.DepthTest);
+
+
+            initBuffers();
+
+            GL.Enable(EnableCap.Blend);
+            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
+        }
+
+        protected override void OnRenderFrame(FrameEventArgs e)
+        {
+            base.OnRenderFrame(e);
+            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
+            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, -Vector3.UnitZ, Vector3.UnitY);
+            GL.MatrixMode(MatrixMode.Modelview);
+            GL.LoadMatrix(ref modelview);
+
+            videoHandle.nextFrame();
+
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
+
+            drawDepthImage();
+
+            // palm (iisu)
+            Vector palmPosition = videoHandle.getPalmPosition3D(1);
+            Point3D palmPoint = new Point3D(palmPosition, Color.Yellow, 0.005f);
+            palmPoint.draw();
+
+            // foreFinger
+            Vector foreFingerPosition = videoHandle.getForeFingerPosition3D(1);
+            Point3D foreFingerPoint = new Point3D(foreFingerPosition, Color.Red, 0.05f);
+            foreFingerPoint.draw();
+
+            //handPoints
+            List<Vector> handPoints = videoHandle.getHandPoints();
+            for (int i = 0; i < handPoints.Count(); i++)
+            {
+                new Point3D(videoHandle.pixel2VertexPosition(handPoints[i]), Color.Yellow, 0.001f).draw();
+            }
+
+            // foreArm (iisu)
+            Vector foreArmPosition = videoHandle.getForearmPosition3D(1);
+            Point3D foreArmPoint = new Point3D(foreArmPosition, Color.Yellow, 0.005f);
+            foreArmPoint.draw();
+
+            // finger (iisu)
+            Vector[] fingerPositions = videoHandle.getFingerTipPositions3D(1);
+            DetectionStatus[] fingerStatus = videoHandle.getFingerStatus(1);
+            for (int i = 0; i < fingerStatus.Length; ++i)
+            {
+                if (fingerStatus[i] == DetectionStatus.Detected || fingerStatus[i] == DetectionStatus.Tracked)
+                {
+                    Point3D fingerPoint = new Point3D(fingerPositions[i], Color.Yellow, 0.005f);
+                    fingerPoint.draw();
+                }
+            }
+
+            // palm
+            Palm palm = videoHandle.getPalm(1);
+            Rectangle3D palmRect = new Rectangle3D(palm.getCorners(), Color.FromArgb(128, Color.Blue));
+            palmRect.draw();
+
+            sw.Stop();
+            Console.WriteLine(sw.ElapsedMilliseconds);
+
+            SwapBuffers();
+        }
+
+        protected override void OnResize(EventArgs e)
+        {
+            base.OnResize(e);
+            GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
+            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 3, Width / (float)Height, 0.01f, 3.0f);
+            GL.MatrixMode(MatrixMode.Projection);
+            GL.LoadMatrix(ref projection);
+        }
+
+        private void initBuffers()
+        {
+            GL.GenBuffers(1, out imageBufferId);
+
+            GL.BindBuffer(BufferTarget.ArrayBuffer, imageBufferId);
+            GL.BufferData(BufferTarget.ArrayBuffer, 
+                          (IntPtr)((3 * sizeof(float) + 4  * sizeof(byte)) * videoHandle.getWidth() * videoHandle.getHeight()), 
+                          IntPtr.Zero, BufferUsageHint.StreamDraw);
+        }
+
+        private void drawDepthImage()
+        {
+            GL.EnableClientState(ArrayCap.VertexArray);
+            GL.EnableClientState(ArrayCap.ColorArray);
+
+            GL.BindBuffer(BufferTarget.ArrayBuffer, imageBufferId);
+            videoHandle.createVertexArray(GL.MapBuffer(BufferTarget.ArrayBuffer, BufferAccess.WriteOnly));
+            GL.UnmapBuffer(BufferTarget.ArrayBuffer);
+
+            GL.VertexPointer(3, VertexPointerType.Float, 3 * sizeof(float) + 4 * sizeof(byte), IntPtr.Zero);
+            GL.ColorPointer(4, ColorPointerType.UnsignedByte, 3 * sizeof(float) + 4 * sizeof(byte), 3 * sizeof(float));
+
+            GL.PointSize(2.0f);
+            GL.DrawArrays(PrimitiveType.Points, 0, videoHandle.getWidth() * videoHandle.getHeight());
+           
+        }
+    }
+}

+ 1 - 1
bbiwarg/Main/OutputTest.cs

@@ -15,7 +15,7 @@ namespace bbiwarg.Main
             IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\1.skv");
             IVideoHandle videoHandle = new VideoHandle(inputProvider);
 
-            OutputDepthImage output = new OutputDepthImage(inputProvider);
+            Output2D output = new Output2D(inputProvider);
             output.Run(30);
         }
     }

+ 2 - 2
bbiwarg/bbiwarg.csproj

@@ -82,12 +82,12 @@
     <Compile Include="DataSource\VideoHandle.cs" />
     <Compile Include="Graphics\GraphicElements2D\IGraphicElement2D.cs" />
     <Compile Include="Graphics\GraphicElements2D\Point2D.cs" />
-    <Compile Include="Graphics\OutputDepthImage.cs" />
+    <Compile Include="Graphics\Output2D.cs" />
     <Compile Include="Graphics\GraphicElements3D\Rectangle3D.cs" />
     <Compile Include="Graphics\GraphicElements3D\IGraphicElement3D.cs" />
     <Compile Include="Graphics\GraphicElements3D\Point3D.cs" />
     <Compile Include="Main\OutputTest.cs" />
-    <Compile Include="Graphics\Output.cs" />
+    <Compile Include="Graphics\Output3D.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>