public void TestOsNpcCreateUsingAppearanceFromNotecard() { TestHelpers.InMethod(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); // Try creating a bot using the appearance in the notecard. string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName); Assert.That(npcRaw, Is.Not.Null); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); }
public void TestOsNpcCreateNotExistingNotecard() { TestHelpers.InMethod(); UUID userId = TestHelpers.ParseTail(0x1); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, so.RootPart, null); bool gotExpectedException = false; try { osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name"); } catch (ScriptException) { gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); }
private void loadSession(string sessionId, int maxPiece) { log(string.Format("loading session {0}", sessionId)); string data = ""; OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(xEngine, aarBox.RootPart, null, null); for (int n = 0; n <= maxPiece; n++) { string notecardName = string.Format("session-{0}-{1}", sessionId, n); log(string.Format("pulling notecard {0}", notecardName)); data += osslApi.osGetNotecard(notecardName); } byte[] rawData = Convert.FromBase64String(data); using (MemoryStream msCompressed = new MemoryStream(rawData)) using (GZipStream gZipStream = new GZipStream(msCompressed, CompressionMode.Decompress)) using (MemoryStream msDecompressed = new MemoryStream()) { gZipStream.CopyTo(msDecompressed); msDecompressed.Seek(0, SeekOrigin.Begin); BinaryFormatter bf = new BinaryFormatter(); recordedActions = (Queue <AAREvent>)bf.Deserialize(msDecompressed); } log(string.Format("Loaded {0} actions", recordedActions.Count)); while (!(recordedActions.Peek() is EventStart)) { var e = recordedActions.Dequeue(); processedActions.Enqueue(e); dispatchEvent(e); } }
public void TestOsNpcRemoveUnowned() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); string npcRaw = osslApi.osNpcCreate( "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); osslApi.osNpcRemove(npcRaw); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Null); }
public void saveSession(string module, string[] args) { if (aarBox == null) { aarBox = AAR.findAarBox(m_scene); } if (isRecording) { log("Error saving session, module is still recording"); return; } if (!hasRecording) { log("Error saving session, there is no recorded session"); return; } //persist the session string session = ""; using (MemoryStream msCompressed = new MemoryStream()) using (GZipStream gZipStream = new GZipStream(msCompressed, CompressionMode.Compress)) using (MemoryStream msDecompressed = new MemoryStream()) { new BinaryFormatter().Serialize(msDecompressed, recordedActions); byte[] byteArray = msDecompressed.ToArray(); gZipStream.Write(byteArray, 0, byteArray.Length); gZipStream.Close(); session = Convert.ToBase64String(msCompressed.ToArray()); } //the recorded session events are all compressed and encoded into the string in session OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(xEngine, aarBox.RootPart, null, null); for (int i = 0, n = 0; i < session.Length; i += CHUNKSIZE, n++) { string sessionChunk; if (i + CHUNKSIZE > session.Length) { sessionChunk = session.Substring(i, session.Length - i); } else { sessionChunk = session.Substring(i, CHUNKSIZE); } OpenSim.Region.ScriptEngine.Shared.LSL_Types.list l = new OpenSim.Region.ScriptEngine.Shared.LSL_Types.list(); l.Add(sessionChunk); string notecardName = string.Format("session-{0}-{1}", sessionId, n); osslApi.osMakeNotecard(notecardName, l); } log(string.Format("{0} bytes", System.Text.ASCIIEncoding.ASCII.GetByteCount(session))); foreach (AvatarActor a in avatars.Values) { a.appearances.Clear(); a.appearanceCount = 0; } hasRecording = false; }
public void TestOsForceAttachToOtherAvatarFromInventory() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); string taskInvObjItemName = "sphere"; UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); AttachmentPoint attachPoint = AttachmentPoint.Chin; UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass"); UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass"); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); // Create an object embedded inside the first TaskInventoryHelpers.AddSceneObject( m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint); // Check scene presence status Assert.That(sp.HasAttachments(), Is.False); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); Assert.That(sp2.HasAttachments(), Is.True); List <SceneObjectGroup> attachments2 = sp2.GetAttachments(); Assert.That(attachments2.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments2[0]; Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName)); Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); // Check appearance status List <AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); List <AvatarAttachment> attachmentsInAppearance2 = sp2.Appearance.GetAttachments(); Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1)); Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint)); }
public void TestOsNpcRemoveOwned() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); UUID otherUserId = TestHelpers.ParseTail(0x2); float newHeight = 1.9f; SceneHelpers.AddScenePresence(m_scene, otherUserId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId); SceneObjectPart otherPart = otherSo.RootPart; m_scene.AddSceneObject(otherSo); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); OSSL_Api otherOsslApi = new OSSL_Api(); otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, otherPart.UUID); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); string npcRaw = osslApi.osNpcCreate( "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_CREATOR_OWNED); otherOsslApi.osNpcRemove(npcRaw); // Should still be around UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Not.Null); osslApi.osNpcRemove(npcRaw); npc = m_scene.GetScenePresence(npcId); // Now the owner deleted it and it's gone Assert.That(npc, Is.Null); }
private string persistAppearance(UUID avatarID, int appearanceVersion) { OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(xEngine, aarBox.RootPart, null, null); string notecardName = string.Format("{0}-appearance-{1}-{2}", sessionId, avatarID, appearanceVersion); osslApi.osAgentSaveAppearance(avatarID.ToString(), notecardName); return(notecardName); }
private AvatarAppearance loadAvatarAppearance(string notecard) { OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(xEngine, aarBox.RootPart, null, null); string data = osslApi.osGetNotecard(notecard); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(data); AvatarAppearance appearance = new AvatarAppearance(); appearance.Unpack(appearanceOsd); return(appearance); }
public void TestOsNpcLoadAppearanceNotExistingNotecard() { TestHelpers.InMethod(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float firstHeight = 1.9f; // float secondHeight = 2.1f; string firstAppearanceNcName = "appearanceNc1"; string secondAppearanceNcName = "appearanceNc2"; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = firstHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); osslApi.osOwnerSaveAppearance(firstAppearanceNcName); string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); bool gotExpectedException = false; try { osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); } catch (ScriptException) { gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight)); }
public void TestOsAgentSaveAppearance() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID ownerId = TestHelpers.ParseTail(0x1); UUID nonOwnerId = TestHelpers.ParseTail(0x2); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null, null); string notecardName = "appearanceNc"; osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName); IList <TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName); Assert.That(items.Count, Is.EqualTo(1)); TaskInventoryItem ncItem = items[0]; Assert.That(ncItem.Name, Is.EqualTo(notecardName)); AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); Assert.That(ncAsset, Is.Not.Null); AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); anc.Decode(); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); AvatarAppearance savedAppearance = new AvatarAppearance(); savedAppearance.Unpack(appearanceOsd); Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); }
public void TestOsForceAttachToAvatarFromInventoryNotObject() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); string taskInvObjItemName = "sphere"; UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); AttachmentPoint attachPoint = AttachmentPoint.Chin; UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null); // Create an object embedded inside the first TaskInventoryHelpers.AddNotecard( m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!"); bool exceptionCaught = false; try { osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); } catch (Exception) { exceptionCaught = true; } Assert.That(exceptionCaught, Is.True); // Check scene presence status Assert.That(sp.HasAttachments(), Is.False); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check appearance status List <AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments(); Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0)); }