Browse Source

+ added support for depth information in TUIOobject (it uses the angle parameter!)

SLR_Kinect_PC 9 years ago
parent
commit
8071843847
2 changed files with 25 additions and 3 deletions
  1. 13 0
      bbiwarg/TUIO/TUIO/TuioServer.cs
  2. 12 3
      bbiwarg/TUIO/TuioCommunicator.cs

+ 13 - 0
bbiwarg/TUIO/TUIO/TuioServer.cs

@@ -202,6 +202,19 @@ namespace TUIO
                 updatedObjectList.Add(tobj);
         }
 
+        /// <summary>
+        /// Updates a tuio object.
+        /// </summary>
+        /// <param name="tobj">the object to update</param>
+        /// <param name="xp">new x position</param>
+        /// <param name="yp">new y position</param>
+        public void updateTuioObject(TuioObject tobj, float xp, float yp, float angle)
+        {
+            tobj.update(currentFrameTime, xp, yp, angle);
+            if (!updatedObjectList.Contains(tobj))
+                updatedObjectList.Add(tobj);
+        }
+
         /// <summary>
         /// Adds a tuio cursor alive message to a packet.
         /// </summary>

+ 12 - 3
bbiwarg/TUIO/TuioCommunicator.cs

@@ -122,7 +122,11 @@ namespace BBIWARG.TUIO
                         List<TuioObject> palmTobjs = tobjects[palm.TrackID];
                         Vector2D[] corners = palm.Quad.Corners;
                         for (int i = 0; i < 4; i++)
-                            server.updateTuioObject(palmTobjs[i], corners[i].X, corners[i].Y);
+                            server.updateTuioObject(
+                                palmTobjs[i], 
+                                corners[i].X, 
+                                corners[i].Y, 
+                                frameData.DepthImage.getDepthAt((int) corners[i].X, (int) corners[i].Y));
                         updatedIDs.Add(palm.TrackID);
                     }
                     else
@@ -130,8 +134,13 @@ namespace BBIWARG.TUIO
                         // add / create
                         List<TuioObject> palmTobjs = new List<TuioObject>();
                         Vector2D[] corners = palm.Quad.Corners;
-                        for (int i = 0; i < 4; i++)
-                            palmTobjs.Add(server.addTuioObject(corners[i].X, corners[i].Y, palm.TrackID + 0.1f * i));
+                        for (int i = 0; i < 4; i++) 
+                        {
+                            palmTobjs.Add(server.addTuioObject(
+                                corners[i].X, 
+                                corners[i].Y, 
+                                frameData.DepthImage.getDepthAt((int) corners[i].X, (int) corners[i].Y))); //palm.TrackID + 0.1f * i));
+                        }
                         tobjects.Add(palm.TrackID, palmTobjs);
                         updatedIDs.Add(palm.TrackID);
                     }