aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorDiva Canto2013-06-05 20:20:22 -0700
committerDiva Canto2013-06-05 20:20:22 -0700
commit25fa647a74194db5b20155ac6d8a34cc231996e8 (patch)
tree5dce1f838e05c2bb8562cd039e229210d99b1c5c /OpenSim/Region/ScriptEngine
parentStrengthen some assumptions. (diff)
parentDatabase persistence for keyframes. Contains a Migration. (diff)
downloadopensim-SC-25fa647a74194db5b20155ac6d8a34cc231996e8.zip
opensim-SC-25fa647a74194db5b20155ac6d8a34cc231996e8.tar.gz
opensim-SC-25fa647a74194db5b20155ac6d8a34cc231996e8.tar.bz2
opensim-SC-25fa647a74194db5b20155ac6d8a34cc231996e8.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs140
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs5
4 files changed, 159 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0b4b043..cd6092d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7296,6 +7296,146 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7296 } 7296 }
7297 } 7297 }
7298 7298
7299 public void llSetKeyframedMotion(LSL_List frames, LSL_List options)
7300 {
7301 SceneObjectGroup group = m_host.ParentGroup;
7302
7303 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical)
7304 return;
7305 if (group.IsAttachment)
7306 return;
7307
7308 if (frames.Data.Length > 0) // We are getting a new motion
7309 {
7310 if (group.RootPart.KeyframeMotion != null)
7311 group.RootPart.KeyframeMotion.Delete();
7312 group.RootPart.KeyframeMotion = null;
7313
7314 int idx = 0;
7315
7316 KeyframeMotion.PlayMode mode = KeyframeMotion.PlayMode.Forward;
7317 KeyframeMotion.DataFormat data = KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation;
7318
7319 while (idx < options.Data.Length)
7320 {
7321 int option = (int)options.GetLSLIntegerItem(idx++);
7322 int remain = options.Data.Length - idx;
7323
7324 switch (option)
7325 {
7326 case ScriptBaseClass.KFM_MODE:
7327 if (remain < 1)
7328 break;
7329 int modeval = (int)options.GetLSLIntegerItem(idx++);
7330 switch(modeval)
7331 {
7332 case ScriptBaseClass.KFM_FORWARD:
7333 mode = KeyframeMotion.PlayMode.Forward;
7334 break;
7335 case ScriptBaseClass.KFM_REVERSE:
7336 mode = KeyframeMotion.PlayMode.Reverse;
7337 break;
7338 case ScriptBaseClass.KFM_LOOP:
7339 mode = KeyframeMotion.PlayMode.Loop;
7340 break;
7341 case ScriptBaseClass.KFM_PING_PONG:
7342 mode = KeyframeMotion.PlayMode.PingPong;
7343 break;
7344 }
7345 break;
7346 case ScriptBaseClass.KFM_DATA:
7347 if (remain < 1)
7348 break;
7349 int dataval = (int)options.GetLSLIntegerItem(idx++);
7350 data = (KeyframeMotion.DataFormat)dataval;
7351 break;
7352 }
7353 }
7354
7355 group.RootPart.KeyframeMotion = new KeyframeMotion(group, mode, data);
7356
7357 idx = 0;
7358
7359 int elemLength = 2;
7360 if (data == (KeyframeMotion.DataFormat.Translation | KeyframeMotion.DataFormat.Rotation))
7361 elemLength = 3;
7362
7363 List<KeyframeMotion.Keyframe> keyframes = new List<KeyframeMotion.Keyframe>();
7364 while (idx < frames.Data.Length)
7365 {
7366 int remain = frames.Data.Length - idx;
7367
7368 if (remain < elemLength)
7369 break;
7370
7371 KeyframeMotion.Keyframe frame = new KeyframeMotion.Keyframe();
7372 frame.Position = null;
7373 frame.Rotation = null;
7374
7375 if ((data & KeyframeMotion.DataFormat.Translation) != 0)
7376 {
7377 LSL_Types.Vector3 tempv = frames.GetVector3Item(idx++);
7378 frame.Position = new Vector3((float)tempv.x, (float)tempv.y, (float)tempv.z);
7379 }
7380 if ((data & KeyframeMotion.DataFormat.Rotation) != 0)
7381 {
7382 LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++);
7383 Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s);
7384 q.Normalize();
7385 frame.Rotation = q;
7386 }
7387
7388 float tempf = (float)frames.GetLSLFloatItem(idx++);
7389 frame.TimeMS = (int)(tempf * 1000.0f);
7390
7391 keyframes.Add(frame);
7392 }
7393
7394 group.RootPart.KeyframeMotion.SetKeyframes(keyframes.ToArray());
7395 group.RootPart.KeyframeMotion.Start();
7396 }
7397 else
7398 {
7399 if (group.RootPart.KeyframeMotion == null)
7400 return;
7401
7402 if (options.Data.Length == 0)
7403 {
7404 group.RootPart.KeyframeMotion.Stop();
7405 return;
7406 }
7407
7408 int code = (int)options.GetLSLIntegerItem(0);
7409
7410 int idx = 0;
7411
7412 while (idx < options.Data.Length)
7413 {
7414 int option = (int)options.GetLSLIntegerItem(idx++);
7415 int remain = options.Data.Length - idx;
7416
7417 switch (option)
7418 {
7419 case ScriptBaseClass.KFM_COMMAND:
7420 int cmd = (int)options.GetLSLIntegerItem(idx++);
7421 switch (cmd)
7422 {
7423 case ScriptBaseClass.KFM_CMD_PLAY:
7424 group.RootPart.KeyframeMotion.Start();
7425 break;
7426 case ScriptBaseClass.KFM_CMD_STOP:
7427 group.RootPart.KeyframeMotion.Stop();
7428 break;
7429 case ScriptBaseClass.KFM_CMD_PAUSE:
7430 group.RootPart.KeyframeMotion.Pause();
7431 break;
7432 }
7433 break;
7434 }
7435 }
7436 }
7437 }
7438
7299 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) 7439 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed)
7300 { 7440 {
7301 int idx = 0; 7441 int idx = 0;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 4ac179a..a6ea88c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -427,6 +427,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
427 void print(string str); 427 void print(string str);
428 428
429 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc); 429 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc);
430 void llSetKeyframedMotion(LSL_List frames, LSL_List options);
430 LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 431 LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
431 } 432 }
432} 433}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index dc5ef13..559068d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -748,6 +748,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
748 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; 748 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2;
749 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; 749 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3;
750 750
751 public const int KFM_MODE = 1;
752 public const int KFM_LOOP = 1;
753 public const int KFM_REVERSE = 3;
754 public const int KFM_FORWARD = 0;
755 public const int KFM_PING_PONG = 2;
756 public const int KFM_DATA = 2;
757 public const int KFM_TRANSLATION = 2;
758 public const int KFM_ROTATION = 1;
759 public const int KFM_COMMAND = 0;
760 public const int KFM_CMD_PLAY = 0;
761 public const int KFM_CMD_STOP = 1;
762 public const int KFM_CMD_PAUSE = 2;
763
751 /// <summary> 764 /// <summary>
752 /// process name parameter as regex 765 /// process name parameter as regex
753 /// </summary> 766 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index c7a7cf6..398c125 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -554,6 +554,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
554 return m_LSL_Functions.llGetLinkNumberOfSides(link); 554 return m_LSL_Functions.llGetLinkNumberOfSides(link);
555 } 555 }
556 556
557 public void llSetKeyframedMotion(LSL_List frames, LSL_List options)
558 {
559 m_LSL_Functions.llSetKeyframedMotion(frames, options);
560 }
561
557 public LSL_Integer llGetListEntryType(LSL_List src, int index) 562 public LSL_Integer llGetListEntryType(LSL_List src, int index)
558 { 563 {
559 return m_LSL_Functions.llGetListEntryType(src, index); 564 return m_LSL_Functions.llGetListEntryType(src, index);