Hello !
Here my code :
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;
using UnityEngine;
using System;
public class Recup_donnees_6bis : MonoBehaviour {
class Data_struct {
public String marker_name ;
public Vector3 [] positions ;
}
GameObject [] body ;
string[][] datas;
int cpt = 0 ;
void Awake ()
{
Application.targetFrameRate = 25;
}
void Start()
{
body = new GameObject[55];
body [0] = GameObject.Find ("RightUpLeg");
body [1] = GameObject.Find ("LeftUpLed");
body [5] = GameObject.Find ("Neck");
body [6] = GameObject.Find ("RightArm");
body [7] = GameObject.Find ("LeftArm");
body [8] = GameObject.Find ("Throat");
body [9] = GameObject.Find ("Spine1");
body [11] = GameObject.Find ("Spine");
body [12] = GameObject.Find ("Hips");
body [13] = GameObject.Find ("Scalp");
body [14] = GameObject.Find ("HeadTop_End");
body [15] = GameObject.Find ("R_Temple");
body [16] = GameObject.Find ("L_Temple");
body [17] = GameObject.Find ("RightForeArm");
body [21] = GameObject.Find ("RightHand");
body [23] = GameObject.Find ("RightHandIndex1");
body [24] = GameObject.Find ("RightHandThumb2");
body [25] = GameObject.Find ("RightHandPinky2");
body [26] = GameObject.Find ("LeftForeArm");
body [30] = GameObject.Find ("LeftHand");
body [32] = GameObject.Find ("LeftHandIndex1");
body [33] = GameObject.Find ("LeftHandThumb2");
body [34] = GameObject.Find ("LeftHandPinky2");
body [35] = GameObject.Find ("RightLed");
body [38] = GameObject.Find ("RightFoot");
body [41] = GameObject.Find ("RightFootToeBase_End");
body [42] = GameObject.Find ("RightToeBase");
body [45] = GameObject.Find ("LeftLed");
body [48] = GameObject.Find ("LeftFoot");
body [51] = GameObject.Find ("LeftFootToeBase_End");
body [53] = GameObject.Find ("LeftToeBase");
StreamReader reader = new StreamReader ("Suj01_PI_DP_C00_1.txt");
using (reader) {
string line = " ";
int lineNumber = 10;
for (int i = 0; i < lineNumber; i++)
{
line = reader.ReadLine();
if (line == null) return;
}
string line_10;
line_10 = line;
string[] names = line_10.Split (new String[] {",",",,,"},StringSplitOptions.RemoveEmptyEntries);
Data_struct [] nv_data ;
nv_data = new Data_struct[names.Length] ;
for (int i =0 ; i< names.Length; ++i )
{
nv_data *= new Data_struct () ;*
nv_data.marker_name = names ;
}
line = reader.ReadLine();
string line_11;
line_11 = line;
string[] axes = line_11.Split(new String[] {“Field #”,“,”},StringSplitOptions.RemoveEmptyEntries);
datas = new string[4000][];
int counter = 0;
while (line != null) {
counter++;
line = reader.ReadLine();
if (line == “ANALOG”)
break ;
if ((counter %3) != 1)
continue;
string lines_datas;
lines_datas = line;
datas[cpt] = lines_datas.Split(new string[] {“,”},StringSplitOptions.RemoveEmptyEntries);
line = reader.ReadLine();
cpt ++ ;
}
for (int i = 0 ; i < cpt ; ++i )
{
for (int j = 1 ; j < names.Length+1 ; j++ )
{
nv_data[j-1].positions = new Vector3[cpt];
nv_data[j-1].positions.x = float.Parse(datas_[j3-2]);
nv_data[j-1].positions.y = float.Parse(datas[j3-1]);
nv_data[j-1].positions.z = float.Parse(datas[j3]);
}*_
}
}
}
void update ()
{
// To associate names_markers to avatar_joints :
for (int k = 0 ; k < body.Length ; ++k)
body[k].transform.position = nv_data[k].positions[k];
}
}
My problem : at the last line “nv_data” doesn’t exist at the current context.
I think I know for why but I don’t know how I can fix this problem.
I’m forced to integrate this last line in “void update ()” because it varies each frame.
Could you help me, please ?