mirror of
https://github.com/storytold/LiveScan3D.git
synced 2026-10-09 00:09:58 +00:00
Skeleton data can now be seen in the client and in the live window. No skeleton merging/saving yet.
This commit is contained in:
@@ -19,6 +19,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
@@ -58,6 +60,7 @@ namespace KinectServer
|
||||
public List<float> vertices = new List<float>();
|
||||
public List<byte> colors = new List<byte>();
|
||||
public List<AffineTransform> cameraPoses = new List<AffineTransform>();
|
||||
public List<Body> bodies = new List<Body>();
|
||||
public KinectSettings settings = new KinectSettings();
|
||||
|
||||
DateTime tFPSUpdateTimer = DateTime.Now;
|
||||
@@ -298,6 +301,7 @@ namespace KinectServer
|
||||
LineCount += settings.lMarkerPoses.Count * 3;
|
||||
//cameras
|
||||
LineCount += cameraPoses.Count * 3;
|
||||
LineCount += 24 * bodies.Count;
|
||||
|
||||
VBO = new VertexC4ubV3f[PointCount + 2 * LineCount];
|
||||
|
||||
@@ -322,6 +326,7 @@ namespace KinectServer
|
||||
{
|
||||
iCurLineCount += AddCamera(PointCount + 2 * iCurLineCount, cameraPoses[i]);
|
||||
}
|
||||
iCurLineCount += AddBodies(PointCount + 2 * iCurLineCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,6 +549,68 @@ namespace KinectServer
|
||||
return nLinesBeingAdded;
|
||||
}
|
||||
|
||||
private int AddBone(int bodyIdx, JointType jointType0, JointType jointType1, int startIdx)
|
||||
{
|
||||
Point3f joint0 = bodies[bodyIdx].lJoints[(int)jointType0].position;
|
||||
Point3f joint1 = bodies[bodyIdx].lJoints[(int)jointType1].position;
|
||||
AddLine(startIdx, joint0.X, joint0.Y, joint0.Z, joint1.X, joint1.Y, joint1.Z);
|
||||
return 2;
|
||||
}
|
||||
|
||||
private int AddBodies(int startIdx)
|
||||
{
|
||||
int nLinesToAdd = 24 * bodies.Count;
|
||||
int nPointsToAdd = nLinesToAdd * 2;
|
||||
|
||||
for (int i = startIdx; i < startIdx + nPointsToAdd; i++)
|
||||
{
|
||||
VBO[i].R = 0;
|
||||
VBO[i].G = 255;
|
||||
VBO[i].B = 0;
|
||||
VBO[i].A = 0;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (int bodyIdx = 0; bodyIdx < bodies.Count; bodyIdx++)
|
||||
{
|
||||
//Torso
|
||||
n += AddBone(bodyIdx, JointType.JointType_Head, JointType.JointType_Neck, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_Neck, JointType.JointType_SpineShoulder, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineShoulder, JointType.JointType_SpineMid, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineMid, JointType.JointType_SpineBase, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineShoulder, JointType.JointType_ShoulderRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineShoulder, JointType.JointType_ShoulderLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineBase, JointType.JointType_HipRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_SpineBase, JointType.JointType_HipLeft, startIdx + n);
|
||||
|
||||
// Right Arm
|
||||
n += AddBone(bodyIdx, JointType.JointType_ShoulderRight, JointType.JointType_ElbowRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_ElbowRight, JointType.JointType_WristRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_WristRight, JointType.JointType_HandRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_HandRight, JointType.JointType_HandTipRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_WristRight, JointType.JointType_ThumbRight, startIdx + n);
|
||||
|
||||
// Left Arm
|
||||
n += AddBone(bodyIdx, JointType.JointType_ShoulderLeft, JointType.JointType_ElbowLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_ElbowLeft, JointType.JointType_WristLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_WristLeft, JointType.JointType_HandLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_HandLeft, JointType.JointType_HandTipLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_WristLeft, JointType.JointType_ThumbLeft, startIdx + n);
|
||||
|
||||
// Right Leg
|
||||
n += AddBone(bodyIdx, JointType.JointType_HipRight, JointType.JointType_KneeRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_KneeRight, JointType.JointType_AnkleRight, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_AnkleRight, JointType.JointType_FootRight, startIdx + n);
|
||||
|
||||
// Left Leg
|
||||
n += AddBone(bodyIdx, JointType.JointType_HipLeft, JointType.JointType_KneeLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_KneeLeft, JointType.JointType_AnkleLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_AnkleLeft, JointType.JointType_FootLeft, startIdx + n);
|
||||
}
|
||||
return nLinesToAdd;
|
||||
}
|
||||
|
||||
private void AddLine(int startIdx, float x0, float y0, float z0,
|
||||
float x1, float y1, float z1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user