public void llSetKeyframedMotion(LSL_List keyframes, LSL_List options) { if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) { return; } if (!m_host.IsRoot) { Error("llSetKeyframedMotion", "Must be used in the root object!"); return; } KeyframeAnimation.Data dataType = KeyframeAnimation.Data.Both; KeyframeAnimation.Modes currentMode = KeyframeAnimation.Modes.Forward; for (int i = 0; i < options.Length; i += 2) { LSL_Integer option = options.GetLSLIntegerItem(i); LSL_Integer value = options.GetLSLIntegerItem(i + 1); if (option == ScriptBaseClass.KFM_COMMAND) { m_host.ParentEntity.AddKeyframedMotion(null, (KeyframeAnimation.Commands)value.value); break; //Its supposed to be the only option in the list } if (option == ScriptBaseClass.KFM_MODE) { currentMode = (KeyframeAnimation.Modes)value.value; } else if (option == ScriptBaseClass.KFM_DATA) { dataType = (KeyframeAnimation.Data)value.value; } } List <Vector3> positions = new List <Vector3>(); List <Quaternion> rotations = new List <Quaternion>(); List <float> times = new List <float>(); for (int i = 0; i < keyframes.Length; i += (dataType == KeyframeAnimation.Data.Both ? 3 : 2)) { if (dataType == KeyframeAnimation.Data.Both || dataType == KeyframeAnimation.Data.Translation) { LSL_Vector pos = keyframes.GetVector3Item(i); positions.Add(pos.ToVector3()); } if (dataType == KeyframeAnimation.Data.Both || dataType == KeyframeAnimation.Data.Rotation) { LSL_Rotation rot = keyframes.GetQuaternionItem(i + (dataType == KeyframeAnimation.Data.Both ? 1 : 0)); Quaternion quat = rot.ToQuaternion(); quat.Normalize(); rotations.Add(quat); } LSL_Float time = keyframes.GetLSLFloatItem(i + (dataType == KeyframeAnimation.Data.Both ? 2 : 1)); times.Add((float)time); } KeyframeAnimation animation = new KeyframeAnimation { CurrentMode = currentMode, PositionList = positions.ToArray(), RotationList = rotations.ToArray(), TimeList = times.ToArray(), CurrentAnimationPosition = 0, InitialPosition = m_host.AbsolutePosition, InitialRotation = m_host.GetRotationOffset() }; m_host.ParentEntity.AddKeyframedMotion(animation, KeyframeAnimation.Commands.Play); }