void ReadValuesShapes(int shapeInd) { string fileName = "shapesSusan.txt"; StreamReader sr = new StreamReader(fileName); string[] content = File.ReadAllLines(fileName); String[] tokens = content[shapeInd + 1].Split('\t'); TorsoAnimator torsoAnim = GameObject.Find("AgentPrefab").GetComponent <TorsoAnimator>(); int i = 2; torsoAnim.ShapeParams[(int)BPart.HeadX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.NeckX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.SpineY][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.Spine1X][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersY][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersZ][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesY][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesZ][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisLX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisRX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisY][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisZ][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.KneesX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.HipsX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.ToesX][shapeInd] = float.Parse(tokens[i++]); torsoAnim.ShapeParams[(int)BPart.SpineLength][shapeInd] = float.Parse(tokens[i++]); sr.Close(); }
// remember to use StartCoroutine when calling this function! IEnumerator GetValuesShapes(GameObject agent, int shapeInd) { string resultURL = "https://fling.seas.upenn.edu/~fundad/cgi-bin/RCTAMAN/getShapeData.php"; // Create a form object for sending high score data to the server var form = new WWWForm(); form.AddField("userId", "susand948"); form.AddField("shapeInd", shapeInd.ToString()); // Create a download object var download = new WWW(resultURL, form); // Wait until the download is done yield return(download); //reset anyway TorsoController torso = agent.GetComponent <TorsoController>(); torso.Reset(); if (download.error != null) { ShapeInfo = download.error; print("Error: " + download.error); } else { ShapeInfo = download.text; String[] vals = ShapeInfo.Split('\t'); //Assign shape values TorsoAnimator torsoAnim = agent.GetComponent <TorsoAnimator>(); int i = 0; torsoAnim.ShapeParams[(int)BPart.HeadX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.NeckX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.SpineY][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.Spine1X][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersY][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ShouldersZ][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesY][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ClaviclesZ][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisLX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisRX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisY][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.PelvisZ][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.KneesX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.HipsX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.ToesX][shapeInd] = float.Parse(vals[i++]); torsoAnim.ShapeParams[(int)BPart.SpineLength][shapeInd] = float.Parse(vals[i++]); } }