private void HandleInteractInputJson(string content) { JObject o = JObject.Parse(content); string aniName = null; string aniContent = null; string targetAvatar = null; string actionName = null; string actionContent = null; string configString = null; string avatarID = null; if (o["avatarID"] != null) { //Console.WriteLine("anName " + o["aniName"]); avatarID = o["avatarID"].ToString(); } if (o["aniName"] != null) { //Console.WriteLine("anName " + o["aniName"]); aniName = o["aniName"].ToString(); } if (o["aniContent"] != null) { aniContent = o["aniContent"].ToString(); } if (o["targetAvatarURI"] != null) { targetAvatar = o["targetAvatarURI"].ToString(); } if (o["actionName"] != null) { actionName = o["actionName"].ToString(); } if (o["actionContent"] != null) { actionContent = o["actionContent"].ToString(); } if (o["configString"] != null) { configString = o["configString"].ToString(); } //Write animation to file string aniPath = "../../Plugins/BVHAnimation/additionalfile/" + aniName; System.IO.File.WriteAllText(aniPath, aniContent); //Write action to file string actionPath = "../../Plugins/BVHAnimation/additionalfile/" + actionName; System.IO.File.WriteAllText(actionPath, actionContent); if (avatarCollection.ContainsKey(avatarID)) { //update the new info AvatarInfo a = new AvatarInfo(); a.actionName = actionName; a.animationName = aniName; a.meshURI = targetAvatar; a.configString = configString; a.entity = avatarCollection[avatarID].entity; BVHAnimationPluginInitializer.Instance.avatarCollection[avatarID] = a; } else { Console.WriteLine("SetAnimationEntity: No such avatar"); } }
public void CreateAnimationEntity(string content, int timestamp) { //Console.WriteLine("Get in here"); //string inputpath = "../../Plugins/BVHAnimation/additionalfile/" + inputName; //JObject o = JObject.Parse(System.IO.File.ReadAllText(inputpath)); //HandleInteractInputJson(inputpath, avatarID); JObject o = JObject.Parse(content); string avatarID = null; if (o["avatarID"] != null) { //Console.WriteLine("anName " + o["aniName"]); avatarID = o["avatarID"].ToString(); } string targetAvatar = null; if (o["targetAvatarURI"] != null) { targetAvatar = o["targetAvatarURI"].ToString(); } float x = 0.0f; float y = 0.0f; float z = 0.0f; if (o["position"] != null) { if ((string)o["position"][0] != null) x = (float)o["position"][0]; if ((string)o["position"][1] != null) y = (float)o["position"][1]; if ((string)o["position"][2] != null) z = (float)o["position"][2]; } if (!avatarCollection.ContainsKey(avatarID)) { //Create avatar and add it to world Entity newAvatar = new Entity(); newAvatar["mesh"]["uri"].Suggest(targetAvatar); newAvatar["mesh"]["visible"].Suggest(true); newAvatar["location"]["position"].Suggest(new Vector(x, y, z)); World.Instance.Add(newAvatar); //Create the new info AvatarInfo a = new AvatarInfo(); a.actionName = null; a.animationName = null; a.meshURI = targetAvatar; a.configString = null; a.entity = newAvatar.Guid.ToString("D"); //Console.WriteLine(a.entity); BVHAnimationPluginInitializer.Instance.avatarCollection.Add(avatarID, a); //Console.WriteLine("avatarID:" + avatarID); } }