public void SetUp() { IConfigSource initConfigSource = new IniConfigSource(); IConfig config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); Scene scene = new SceneHelpers().SetupScene(); SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; XEngine.XEngine engine = new XEngine.XEngine(); engine.Initialise(initConfigSource); engine.AddRegion(scene); m_lslApi = new LSL_Api(); m_lslApi.Initialize(engine, part, null, null); }
public override void SetUp() { base.SetUp(); m_engine = new MockScriptEngine(); m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine); m_so = SceneHelpers.AddSceneObject(m_scene); m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. m_lslApi = new LSL_Api(); m_lslApi.Initialize(m_engine, m_so.RootPart, m_scriptItem); }
public void SetUp() { IniConfigSource initConfigSource = new IniConfigSource(); IConfig config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); Scene scene = SceneSetupHelpers.SetupScene(); SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); XEngine.XEngine engine = new XEngine.XEngine(); engine.Initialise(initConfigSource); engine.AddRegion(scene); m_lslApi = new LSL_Api(); m_lslApi.Initialize(engine, part, part.LocalId, part.UUID); }
public void TestLlRequestAgentDataOnline() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, scriptItem, null); // Initially long timeout to test cache apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20000; // Offline test { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } // Online test. Should get the 'wrong' result because of caching. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } apiGrp1.LlRequestAgentDataCacheTimeoutMs = 1; // Make absolutely sure that we should trigger cache timeout. Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(1, int.Parse(data)); m_engine.PostedEvents.Clear(); } m_scene.CloseAgent(userId, false); Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1 + 1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } }
public void TestllCreateLink() { TestHelpers.InMethod(); UUID ownerId = TestHelpers.ParseTail(0x1); SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); grp1.AbsolutePosition = new Vector3(10, 10, 10); m_scene.AddSceneObject(grp1); // FIXME: This should really be a script item (with accompanying script) TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); grp2.AbsolutePosition = new Vector3(20, 20, 20); // <180,0,0> grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); m_scene.AddSceneObject(grp2); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); Assert.That(grp1.Parts.Length, Is.EqualTo(4)); Assert.That(grp2.IsDeleted, Is.True); }
public void TestllBreakLink() { TestHelpers.InMethod(); UUID ownerId = TestHelpers.ParseTail(0x1); SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); grp1.AbsolutePosition = new Vector3(10, 10, 10); m_scene.AddSceneObject(grp1); // FIXME: This should really be a script item (with accompanying script) TaskInventoryItem grp1Item = TaskInventoryHelpers.AddNotecard( m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); apiGrp1.llBreakLink(2); Assert.That(grp1.Parts.Length, Is.EqualTo(1)); SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); Assert.That(grp2, Is.Not.Null); }
public override void SetUp() { base.SetUp(); // This is an unfortunate bit of clean up we have to do because MainServer manages things through static // variables and the VM is not restarted between tests. uint port = 9999; MainServer.RemoveHttpServer(port); BaseHttpServer server = new BaseHttpServer(port, false, 0, ""); MainServer.AddHttpServer(server); MainServer.Instance = server; server.Start(); m_engine = new MockScriptEngine(); m_urlModule = new UrlModule(); m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule); SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. m_lslApi = new LSL_Api(); m_lslApi.Initialize(m_engine, so.RootPart, m_scriptItem, null); }
public void TestLlGiveInventoryO2OSameOwner() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); string inventoryItemName = "item1"; SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId, "so1", 0x10); m_scene.AddSceneObject(so1); // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); // Create a second object SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); m_scene.AddSceneObject(so2); api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); // Item has copy permissions so original should stay intact. List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); Assert.That(originalItems.Count, Is.EqualTo(1)); List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); Assert.That(copiedItems.Count, Is.EqualTo(1)); Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); }
public void TestLlGiveInventoryO2ODifferentOwners() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID user1Id = TestHelpers.ParseTail(0x1); UUID user2Id = TestHelpers.ParseTail(0x2); string inventoryItemName = "item1"; SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); m_scene.AddSceneObject(so1); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); // Create a second object SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); m_scene.AddSceneObject(so2); LSL_Api api2 = new LSL_Api(); api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID); // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); { // Item has copy permissions so original should stay intact. List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); Assert.That(originalItems.Count, Is.EqualTo(1)); // Should have not copied List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); Assert.That(copiedItems.Count, Is.EqualTo(0)); } // *** Secondly, we turn on allow inventory drop in the target and retest. *** api2.llAllowInventoryDrop(1); api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); { // Item has copy permissions so original should stay intact. List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); Assert.That(originalItems.Count, Is.EqualTo(1)); // Should now have copied. List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); Assert.That(copiedItems.Count, Is.EqualTo(1)); Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); } }
public void TestLlGiveInventoryO2DifferentAvatarNoMod() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID user1Id = TestHelpers.ParseTail(0x1); UUID user2Id = TestHelpers.ParseTail(0x2); string inventoryItemName = "item1"; SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); m_scene.AddSceneObject(so1); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, so1.RootPart, null); // Create an object embedded inside the first UUID itemId = TestHelpers.ParseTail(0x20); TaskInventoryItem tii = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id); tii.NextPermissions &= ~((uint)PermissionMask.Modify); UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); api.llGiveInventory(user2Id.ToString(), inventoryItemName); InventoryItemBase receivedItem = UserInventoryHelpers.GetInventoryItem( m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName)); Assert.IsNotNull(receivedItem); Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify); }
public void TestllSetLinkPrimitiveParamsForAgent() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; part.RotationOffset = new Quaternion(0.7071068f, 0, 0, 0.7071068f); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, null); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); // sp has to be less than 10 meters away from 0, 0, 0 (default part position) Vector3 startPos = new Vector3(3, 2, 1); sp.AbsolutePosition = startPos; sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); int entityUpdates = 0; ((TestClient)sp.ControllingClient).OnReceivedEntityUpdate += (entity, flags) => { if (entity is ScenePresence) { entityUpdates++; }}; // Test position { Vector3 newPos = new Vector3(1, 2, 3); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); m_scene.Update(1); Assert.That(entityUpdates, Is.EqualTo(1)); } // Test small reposition { Vector3 newPos = new Vector3(1.001f, 2, 3); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); m_scene.Update(1); Assert.That(entityUpdates, Is.EqualTo(2)); } // Test world rotation { Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); Assert.That( sp.Rotation, new QuaternionToleranceConstraint(part.GetWorldRotation() * newRot, 0.000001)); m_scene.Update(1); Assert.That(entityUpdates, Is.EqualTo(3)); } // Test local rotation { Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROT_LOCAL, newRot)); Assert.That( sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); m_scene.Update(1); Assert.That(entityUpdates, Is.EqualTo(4)); } }
public void TestllGetLinkPrimitiveParams() { TestHelpers.InMethod(); TestHelpers.EnableLogging(); UUID ownerId = TestHelpers.ParseTail(0x1); SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); grp1.AbsolutePosition = new Vector3(10, 11, 12); m_scene.AddSceneObject(grp1); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, grp1.RootPart, null, null); // Check simple 1 prim case { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(1)); } // Check 2 prim case { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 1, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(2), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(2)); } // Check invalid parameters are ignored { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(0)); } // Check all parameters are ignored if an initial bad link is given { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 3, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(1), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(0)); } // Check only subsequent parameters are ignored when we hit the first bad link number { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 1, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(3), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(1)); } }
public void TestllSetLinkPrimitiveParamsForAgent() { TestHelpers.InMethod(); UUID userId = TestHelpers.ParseTail(0x1); new SceneHelpers().SetupScene(); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, null, null); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); // sp has to be less than 10 meters away from 0, 0, 0 (default part position) Vector3 startPos = new Vector3(3, 2, 1); sp.AbsolutePosition = startPos; sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); // Test position Vector3 newPos = new Vector3(1, 2, 3); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); // Test rotation Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); Assert.That( sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); }
// Set prim params for a sculpted prim and check results. public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) { // Set the prim params. api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); // Get params for prim to validate settings. LSL_Types.list primParams = api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); // Validate settings. CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); Assert.AreEqual(primType, api.llList2Integer(primParams, 1), "TestllSetPrimitiveParams " + primTest + " prim type check fail"); Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim map check fail"); Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3), "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); }
// Set prim params for a torus, tube or ring and check results. public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, float primRev, float primRadius, float primSkew, float primHollowCheck) { // Set the prim params. api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, ScriptBaseClass.PRIM_TYPE, primType, primHoleType, primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, primTaper, primRev, primRadius, primSkew)); // Get params for prim to validate settings. LSL_Types.list primParams = api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); // Valdate settings. CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); Assert.AreEqual(primType, api.llList2Integer(primParams, 1), "TestllSetPrimitiveParams " + primTest + " prim type check fail"); Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size"); CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut"); CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper"); Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim radius fail"); Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim skew fail"); }
// Set prim params for a sphere and check results. public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) { // Set the prim params. api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, ScriptBaseClass.PRIM_TYPE, primType, primHoleType, primCut, primHollow, primTwist, primDimple)); // Get params for prim to validate settings. LSL_Types.list primParams = api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); // Validate settings. CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); Assert.AreEqual(primType, api.llList2Integer(primParams, 1), "TestllSetPrimitiveParams " + primTest + " prim type check fail"); Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple"); }
// llSetPrimitiveParams and llGetPrimitiveParams test. public void TestllSetPrimitiveParams() { TestHelpers.InMethod(); // Create Prim1. Scene scene = new SceneHelpers().SetupScene(); string obj1Name = "Prim1"; UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); SceneObjectPart part1 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = obj1Name, UUID = objUuid }; Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part1, null, null); // Note that prim hollow check is passed with the other prim params in order to allow the // specification of a different check value from the prim param. A cylinder, prism, sphere, // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below // specifies a value of 95% and checks to see if 70% was properly returned. // Test a sphere. CheckllSetPrimitiveParams( apiGrp1, "test 1", // Prim test identification string new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut 0.80f, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple 0.80f); // Prim hollow check // Test a prism. CheckllSetPrimitiveParams( apiGrp1, "test 2", // Prim test identification string new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.90f, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.90f); // Prim hollow check // Test a box. CheckllSetPrimitiveParams( apiGrp1, "test 3", // Prim test identification string new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size ScriptBaseClass.PRIM_TYPE_BOX, // Prim type ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.99f, // Prim hollow new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.99f); // Prim hollow check // Test a tube. CheckllSetPrimitiveParams( apiGrp1, "test 4", // Prim test identification string new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.00f, // Prim hollow new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size // Expression for y selected to test precision problems during byte // cast in SetPrimitiveShapeParams. new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut // Expression for y selected to test precision problems during sbyte // cast in SetPrimitiveShapeParams. new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper 1.11f, // Prim revolutions 0.88f, // Prim radius 0.95f, // Prim skew 0.00f); // Prim hollow check // Test a prism. CheckllSetPrimitiveParams( apiGrp1, "test 5", // Prim test identification string new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut 0.99f, // Prim hollow // Expression for x selected to test precision problems during sbyte // cast in SetPrimitiveShapeBlockParams. new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist // Expression for y selected to test precision problems during sbyte // cast in SetPrimitiveShapeParams. new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear 0.70f); // Prim hollow check // Test a sculpted prim. CheckllSetPrimitiveParams( apiGrp1, "test 6", // Prim test identification string new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type }
public void TestLlRemoteLoadScriptPin() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID user1Id = TestHelpers.ParseTail(0x1); UUID user2Id = TestHelpers.ParseTail(0x2); SceneObjectGroup sourceSo = SceneHelpers.AddSceneObject(m_scene, "sourceSo", user1Id); m_scene.AddSceneObject(sourceSo); LSL_Api api = new LSL_Api(); api.Initialize(m_engine, sourceSo.RootPart, null); TaskInventoryHelpers.AddScript(m_scene.AssetService, sourceSo.RootPart, "script", "Hello World"); SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene, "targetSo", user1Id); SceneObjectGroup otherOwnedTargetSo = SceneHelpers.AddSceneObject(m_scene, "otherOwnedTargetSo", user2Id); // Test that we cannot load a script when the target pin has never been set (i.e. it is zero) api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 0, 0, 0); Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); // Test that we cannot load a script when the given pin does not match the target targetSo.RootPart.ScriptAccessPin = 5; api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); // Test that we cannot load into a prim with a different owner otherOwnedTargetSo.RootPart.ScriptAccessPin = 3; api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); // Test that we can load a script when given pin and dest pin match. targetSo.RootPart.ScriptAccessPin = 3; api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0); TaskInventoryItem insertedItem = targetSo.RootPart.Inventory.GetInventoryItem("script"); Assert.IsNotNull(insertedItem); // Test that we can no longer load if access pin is unset targetSo.RootPart.Inventory.RemoveInventoryItem(insertedItem.ItemID); Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script")); targetSo.RootPart.ScriptAccessPin = 0; api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0); Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script")); }