IEnumerator TestSetFaceAnimationImmediate(int au, string side, float amount) { //SmartbodyManager.Get().PythonCommand(string.Format(@"scene.command('char {0} viseme au_{1} {2}')", "Brad", i, newSlider)); // deactivate current value { string bmlString = "renderer_bml_" + GenerateBmlId(); string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>" + @"<act>" + @"<bml>" + string.Format(@"<face type=""facs"" au=""{0}"" side=""{1}"" amount=""{2}"" start=""0"" ready=""0.0001"" end=""999"" />", au, "both", 0) + // current bug in smartbody where ready has to be > 0 @"</bml>" + @"</act>"; VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "Brad", bmlString, xml)); VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "BradM", bmlString, xml)); } // set value based on given amount { string bmlString = "renderer_bml_" + GenerateBmlId(); string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>" + @"<act>" + @"<bml>" + string.Format(@"<face type=""facs"" au=""{0}"" side=""{1}"" amount=""{2}"" start=""0"" ready=""0.0001"" end=""999"" />", au, side, amount) + // current bug in smartbody where ready has to be > 0 @"</bml>" + @"</act>"; VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "Brad", bmlString, xml)); VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "BradM", bmlString, xml)); } yield break; }
void VHMsg_MessageEvent(object sender, VHMsgBase.Message message) { string [] splitargs = message.s.Split(" ".ToCharArray()); if (splitargs.Length > 0) { if (splitargs[0] == "vrAllCall") { VHMsgBase.Get().SendVHMsg("vrComponent vhmsgemulator"); } else if (splitargs[0] == "vrKillComponent") { if (splitargs.Length > 1) { if (splitargs[1] == "vhmsgemulator" || splitargs[1] == "all") { VHUtils.ApplicationQuit(); } } } } }
IEnumerator TestGazeCamera() { m_testStatusLabel = "Gaze camera - all defaults\n"; m_testStatusLabel += "<gaze target=\"Camera\" />\n"; m_testStatusLabel += "current defaults:\n"; m_testStatusLabel += "sbm:joint-speed 5000 5000 <head> <eyes>\n"; m_testStatusLabel += "sbm:speed-smoothing 0.6 0.5 0.0 <lumbar> <cervical> <eyes>\n"; string bmlString = "renderer_bml_" + GenerateBmlId(); string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?>" + @"<act>" + @"<bml>" + @"<gaze target=""Camera"" />" + @"</bml>" + @"</act>"; VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "Brad", bmlString, xml)); VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "BradM", bmlString, xml)); yield return(new WaitForSeconds(2.0f)); m_testStatusLabel = ""; }
public override void Start() { base.Start(); if (VHUtils.HasCommandLineArgument("startserver")) { Network.InitializeServer(m_MaxConnections, m_ListenPort, m_UseNat); } string fps = VHUtils.GetCommandLineArgumentValue("fps"); if (!string.IsNullOrEmpty(fps)) { Application.targetFrameRate = Convert.ToInt32(fps); } else { Application.targetFrameRate = 30; } VHMsgBase.Get().AddMessageEventHandler(VHMsg_MessageEvent); VHMsgBase.Get().SubscribeMessage("vrAllCall"); VHMsgBase.Get().SubscribeMessage("vrKillComponent"); }
IEnumerator TestPlayAnimation(string motionName, BMLData bmlData) { // TODO need to find a way to do this via Mecanim motions GameObject motionObject = GameObject.Find(motionName); SmartbodyMotion motion = motionObject.GetComponent <SmartbodyMotion>(); float start = motion.GetSyncPointTime("start"); float ready = motion.GetSyncPointTime("readyTime"); float strokeStart = motion.GetSyncPointTime("strokeStartTime"); float emphasis = motion.GetSyncPointTime("emphasisTime"); float stroke = motion.GetSyncPointTime("strokeTime"); float relax = motion.GetSyncPointTime("relaxTime"); float end = motion.GetSyncPointTime("stop"); string bmlLine = string.Format(@"<animation name=""{0}"" />", motionName); if (bmlData.hasStart) { bmlLine = bmlLine.Replace(" />", string.Format(@" start=""{0}"" />", bmlData.start)); start += bmlData.start; ready += bmlData.start; strokeStart += bmlData.start; emphasis += bmlData.start; stroke += bmlData.start; relax += bmlData.start; end += bmlData.start; } if (bmlData.hasStroke) { bmlLine = bmlLine.Replace(" />", string.Format(@" stroke=""{0}"" />", bmlData.stroke)); float amountToAdjust = bmlData.stroke - stroke; // eg, if stroke in the motion is 1.2, and bmlData.stroke is 3, we want to adjust the start by 1.8 start += amountToAdjust; ready += amountToAdjust; strokeStart += amountToAdjust; emphasis += amountToAdjust; stroke += amountToAdjust; relax += amountToAdjust; end += amountToAdjust; } if (bmlData.hasEnd) { bmlLine = bmlLine.Replace(" />", string.Format(@" end=""{0}"" />", bmlData.end)); float amountToAdjust = bmlData.end - end; // eg, if end in the motion is 3.2, and bmlData.end is 5, we want to adjust the start by 1.8 start += amountToAdjust; ready += amountToAdjust; strokeStart += amountToAdjust; emphasis += amountToAdjust; stroke += amountToAdjust; relax += amountToAdjust; end += amountToAdjust; } m_testStatusStartTime = Time.time; m_testStatusLabel = string.Format("Play Animation - {0}\n", motionName) + bmlLine + "\n" + string.Format("start = {0:f2} (@time)\n", start) + string.Format("ready = {0:f2} (@time)\n", ready) + string.Format("strokeStart = {0:f2} (@time)\n", strokeStart) + string.Format("emphasis = {0:f2} (@time)\n", emphasis) + string.Format("stroke = {0:f2} (@time)\n", stroke) + string.Format("relax = {0:f2} (@time)\n", relax) + string.Format("end = {0:f2} (@time)\n", end); string bmlString = "renderer_bml_" + GenerateBmlId(); string xml = string.Format(@"<?xml version=""1.0"" encoding=""UTF-8""?>") + string.Format(@"<act>") + string.Format(@"<bml>") + bmlLine + string.Format(@"</bml>") + string.Format(@"</act>"); VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "Brad", bmlString, xml)); VHMsgBase.Get().SendVHMsg(string.Format("vrSpeak {0} ALL {1} {2}", "BradM", bmlString, xml)); yield return(new WaitForSeconds(end)); /* * yield return new WaitForSeconds(1.44f); * // to-do, make current line red, only show time on this line * * yield return new WaitForSeconds(0); * yield return new WaitForSeconds(0.21f); * yield return new WaitForSeconds(0.15f); * yield return new WaitForSeconds(0.18f); * yield return new WaitForSeconds(1.68f); */ yield return(new WaitForSeconds(1.0f)); m_testStatusLabel = ""; }