Hi , so I want to show the hands' data in excel (time, position, velocity for each bone). I have come to this solution right now but it's not convenient at all, I create an array for each bone characteristic and store data from void update(), then write every one of them into a cell :
int f=0;
float[] grab_angle_L;
float[] grab_strength_L;
float[] L_Pinky_MetaJoint1_x;
float[] L_Pinky_MetaJoint2_x;
float[] L_Pinky_MetaJoint1_y;
float[] L_Pinky_MetaJoint2_y;
float[] L_Pinky_MetaJoint1_z;
float[] L_Pinky_MetaJoint2_z;
// and so on .....
void Update()
{
Frame frame = controller.Frame();
if (frame.Hands.Count > 0)
{
List<Hand> hands = frame.Hands;
Hand firstHand = hands[0];
}
Hand hand = frame.Hands[0];
List<Finger> fingers = hand.Fingers;
grab_angle_L[f] = hand.GrabAngle;
grab_strength_L[f] = hand.GrabStrength;
L_Pinky_MetaJoint1_x[f] = hand.Fingers[4].bones[0].PrevJoint.x;
L_Pinky_MetaJoint2_x[f] = hand.Fingers[4].bones[0].NextJoint.x;
L_Pinky_MetaJoint1_y[f] = hand.Fingers[4].bones[0].PrevJoint.y;
// and so on ........
f++;
}
void WriteinExce()
{
FileStream Address = new FileStream(Application.dataPath + "/Datas in Excel.xls", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
HSSFWorkbook work = new HSSFWorkbook();
HSSFSheet Sheet01 = (HSSFSheet)work.CreateSheet("Results");
HSSFRow row = (HSSFRow)Sheet01.CreateRow(0);
HSSFCell xcell = (HSSFCell)row.CreateCell(0);
for (int i = 1; i < SMPXpos.Length; i++)
{
row = (HSSFRow)Sheet01.CreateRow(i);
HSSFCell Mcell = (HSSFCell)row.CreateCell(0);
Mcell.SetCellValue( L_Pinky_MetaJoint1_x[i]);
HSSFCell Scell = (HSSFCell)row.CreateCell(1);
Scell.SetCellValue( L_Pinky_MetaJoint1_x[i]);
HSSFCell MScell = (HSSFCell)row.CreateCell(2);
MScell.SetCellValue( L_Pinky_MetaJoint2_x[i]);
// and so on....
}
work.Write(Address);
work.Close();
}
but that obviously takes time to code
Can you help me display the hands' data in excel in a much smarter way? I need it for my thesis.