diff options
author | Melanie | 2012-02-26 02:36:34 +0100 |
---|---|---|
committer | Melanie | 2012-02-26 02:36:34 +0100 |
commit | c82709c0d6c72852d8614651f9cb31df09fff883 (patch) | |
tree | ee7e539ef5b56383c8bf767f06cfbc2581c8d7bf /OpenSim/Region/ScriptEngine | |
parent | Delay the sending of the initial werables update until the inventory and (diff) | |
download | opensim-SC_OLD-c82709c0d6c72852d8614651f9cb31df09fff883.zip opensim-SC_OLD-c82709c0d6c72852d8614651f9cb31df09fff883.tar.gz opensim-SC_OLD-c82709c0d6c72852d8614651f9cb31df09fff883.tar.bz2 opensim-SC_OLD-c82709c0d6c72852d8614651f9cb31df09fff883.tar.xz |
Implement llSetKeyframedMotion. No persistence, no region crossing. Yet.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
4 files changed, 158 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d0430f4..9090311 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -11896,6 +11896,144 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11896 | } | 11896 | } |
11897 | 11897 | ||
11898 | #endregion | 11898 | #endregion |
11899 | |||
11900 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
11901 | { | ||
11902 | SceneObjectGroup group = m_host.ParentGroup; | ||
11903 | |||
11904 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical) | ||
11905 | return; | ||
11906 | if (group.IsAttachment) | ||
11907 | return; | ||
11908 | |||
11909 | if (frames.Data.Length > 0) // We are getting a new motion | ||
11910 | { | ||
11911 | if (group.KeyframeMotion != null) | ||
11912 | group.KeyframeMotion.Stop(); | ||
11913 | group.KeyframeMotion = null; | ||
11914 | |||
11915 | int idx = 0; | ||
11916 | |||
11917 | KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward; | ||
11918 | KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation; | ||
11919 | |||
11920 | while (idx < options.Data.Length) | ||
11921 | { | ||
11922 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
11923 | int remain = options.Data.Length - idx; | ||
11924 | |||
11925 | switch (option) | ||
11926 | { | ||
11927 | case ScriptBaseClass.KFM_MODE: | ||
11928 | if (remain < 1) | ||
11929 | break; | ||
11930 | int modeval = (int)options.GetLSLIntegerItem(idx++); | ||
11931 | switch(modeval) | ||
11932 | { | ||
11933 | case ScriptBaseClass.KFM_FORWARD: | ||
11934 | mode = KeyframeMotion.PlayMode.Forward; | ||
11935 | break; | ||
11936 | case ScriptBaseClass.KFM_REVERSE: | ||
11937 | mode = KeyframeMotion.PlayMode.Reverse; | ||
11938 | break; | ||
11939 | case ScriptBaseClass.KFM_LOOP: | ||
11940 | mode = KeyframeMotion.PlayMode.Loop; | ||
11941 | break; | ||
11942 | case ScriptBaseClass.KFM_PING_PONG: | ||
11943 | mode = KeyframeMotion.PlayMode.PingPong; | ||
11944 | break; | ||
11945 | } | ||
11946 | break; | ||
11947 | case ScriptBaseClass.KFM_DATA: | ||
11948 | if (remain < 1) | ||
11949 | break; | ||
11950 | int dataval = (int)options.GetLSLIntegerItem(idx++); | ||
11951 | data = (KeyframeMotion.DataFormat)dataval; | ||
11952 | break; | ||
11953 | } | ||
11954 | } | ||
11955 | |||
11956 | group.KeyframeMotion = new KeyframeMotion(group, mode, data); | ||
11957 | |||
11958 | idx = 0; | ||
11959 | |||
11960 | int elemLength = 2; | ||
11961 | if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation)) | ||
11962 | elemLength = 3; | ||
11963 | |||
11964 | List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>(); | ||
11965 | while (idx < frames.Data.Length) | ||
11966 | { | ||
11967 | int remain = frames.Data.Length - idx; | ||
11968 | |||
11969 | if (remain < elemLength) | ||
11970 | break; | ||
11971 | |||
11972 | KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe(); | ||
11973 | frame.Position = null; | ||
11974 | frame.Rotation = null; | ||
11975 | |||
11976 | if ((data & KeyframeMotion.DataFormat.Translation) != 0) | ||
11977 | { | ||
11978 | LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++); | ||
11979 | frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z); | ||
11980 | } | ||
11981 | if ((data & KeyframeMotion.DataFormat.Rotation) != 0) | ||
11982 | { | ||
11983 | LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); | ||
11984 | frame.Rotation = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); | ||
11985 | } | ||
11986 | |||
11987 | float tempf = (float)frames.GetLSLFloatItem(idx++); | ||
11988 | frame.TimeMS = (int)(tempf * 1000.0f); | ||
11989 | |||
11990 | keyframes.Add(frame); | ||
11991 | } | ||
11992 | |||
11993 | group.KeyframeMotion.SetKeyframes(keyframes.ToArray()); | ||
11994 | group.KeyframeMotion.Start(); | ||
11995 | } | ||
11996 | else | ||
11997 | { | ||
11998 | if (group.KeyframeMotion == null) | ||
11999 | return; | ||
12000 | |||
12001 | if (options.Data.Length == 0) | ||
12002 | { | ||
12003 | group.KeyframeMotion.Stop(); | ||
12004 | return; | ||
12005 | } | ||
12006 | |||
12007 | int code = (int)options.GetLSLIntegerItem(0); | ||
12008 | |||
12009 | int idx = 0; | ||
12010 | |||
12011 | while (idx < options.Data.Length) | ||
12012 | { | ||
12013 | int option = (int)options.GetLSLIntegerItem(idx++); | ||
12014 | int remain = options.Data.Length - idx; | ||
12015 | |||
12016 | switch (option) | ||
12017 | { | ||
12018 | case ScriptBaseClass.KFM_COMMAND: | ||
12019 | int cmd = (int)options.GetLSLIntegerItem(idx++); | ||
12020 | switch (cmd) | ||
12021 | { | ||
12022 | case ScriptBaseClass.KFM_CMD_PLAY: | ||
12023 | group.KeyframeMotion.Start(); | ||
12024 | break; | ||
12025 | case ScriptBaseClass.KFM_CMD_STOP: | ||
12026 | group.KeyframeMotion.Stop(); | ||
12027 | break; | ||
12028 | case ScriptBaseClass.KFM_CMD_PAUSE: | ||
12029 | group.KeyframeMotion.Pause(); | ||
12030 | break; | ||
12031 | } | ||
12032 | break; | ||
12033 | } | ||
12034 | } | ||
12035 | } | ||
12036 | } | ||
11899 | } | 12037 | } |
11900 | 12038 | ||
11901 | public class NotecardCache | 12039 | public class NotecardCache |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 9679798..99bfc97 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -415,5 +415,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
415 | 415 | ||
416 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 416 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
417 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 417 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
418 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | ||
418 | } | 419 | } |
419 | } | 420 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3d0e5cb..a5e160d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -641,5 +641,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
641 | public static readonly LSLInteger RCERR_UNKNOWN = -1; | 641 | public static readonly LSLInteger RCERR_UNKNOWN = -1; |
642 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; | 642 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; |
643 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; | 643 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; |
644 | |||
645 | public const int KFM_MODE = 1; | ||
646 | public const int KFM_LOOP = 1; | ||
647 | public const int KFM_REVERSE = 3; | ||
648 | public const int KFM_FORWARD = 0; | ||
649 | public const int KFM_PING_PONG = 2; | ||
650 | public const int KFM_DATA = 2; | ||
651 | public const int KFM_TRANSLATION = 2; | ||
652 | public const int KFM_ROTATION = 1; | ||
653 | public const int KFM_COMMAND = 0; | ||
654 | public const int KFM_CMD_PLAY = 0; | ||
655 | public const int KFM_CMD_STOP = 1; | ||
656 | public const int KFM_CMD_PAUSE = 2; | ||
644 | } | 657 | } |
645 | } | 658 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index dcaa3b4..9c4437d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -1917,7 +1917,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1917 | 1917 | ||
1918 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | 1918 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
1919 | { | 1919 | { |
1920 | return m_LSL_Functions.llGetLinkNumberOfSides(link); | 1920 | return m_LSL_Functions.llGetLinkNumberOfSides(link); |
1921 | } | ||
1922 | |||
1923 | public void llSetKeyframedMotion(LSL_List frames, LSL_List options) | ||
1924 | { | ||
1925 | m_LSL_Functions.llSetKeyframedMotion(frames, options); | ||
1921 | } | 1926 | } |
1922 | } | 1927 | } |
1923 | } | 1928 | } |