本文整理汇总了C#中OpenSim.Region.Framework.Scenes.SceneObjectGroup类的典型用法代码示例。如果您正苦于以下问题:C# SceneObjectGroup类的具体用法?C# SceneObjectGroup怎么用?C# SceneObjectGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SceneObjectGroup类属于OpenSim.Region.Framework.Scenes命名空间,在下文中一共展示了SceneObjectGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPartSerialzationDeserialization
public void TestPartSerialzationDeserialization()
{
SceneObjectPart rootPart = new SceneObjectPart(UUID.Zero, new OpenSim.Framework.PrimitiveBaseShape(), new Vector3(1, 2, 3), Quaternion.Identity, Vector3.Zero, false);
rootPart.Name = "RootPart";
SceneObjectPart part = Util.RandomSOP("ChildPart", 2);
var pgrp1 = new SceneObjectGroup(rootPart);
pgrp1.AddPart(part);
part.InventorySerial = 1;
part.Rezzed = DateTime.Now;
part.TextColor = System.Drawing.Color.FromArgb(1,2,3,4);
byte[] bytes = serEngine.SceneObjectSerializer.SerializePartToBytes(part, OpenSim.Region.Framework.Scenes.Serialization.SerializationFlags.None);
SceneObjectPart rootPart2 = new SceneObjectPart(UUID.Zero, new OpenSim.Framework.PrimitiveBaseShape(), new Vector3(1, 2, 3), Quaternion.Identity, Vector3.Zero, false);
rootPart2.Name = "RootPart2";
SceneObjectPart deserPart = serEngine.SceneObjectSerializer.DeserializePartFromBytes(bytes);
var pgrp2 = new SceneObjectGroup(rootPart2);
pgrp2.AddPart(deserPart);
deserPart.Rezzed = part.Rezzed;
CompareObjects comp = new CompareObjects();
comp.CompareStaticFields = false;
comp.CompareStaticProperties = false;
comp.ElementsToIgnore = PrimCompareIgnoreList;
Assert.IsTrue(comp.Compare(part, deserPart), comp.DifferencesString);
}
示例2: DeleteToInventory
/// <summary>
/// Delete the given object from the scene
/// </summary>
public void DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient,
bool permissionToDelete)
{
if (Enabled)
lock (m_inventoryTicker)
m_inventoryTicker.Stop();
lock (m_inventoryDeletes)
{
DeleteToInventoryHolder dtis = new DeleteToInventoryHolder();
dtis.action = action;
dtis.folderID = folderID;
dtis.objectGroup = objectGroup;
dtis.remoteClient = remoteClient;
dtis.permissionToDelete = permissionToDelete;
m_inventoryDeletes.Enqueue(dtis);
}
if (Enabled)
lock (m_inventoryTicker)
m_inventoryTicker.Start();
// Visually remove it, even if it isnt really gone yet. This means that if we crash before the object
// has gone to inventory, it will reappear in the region again on restart instead of being lost.
// This is not ideal since the object will still be available for manipulation when it should be, but it's
// better than losing the object for now.
if (permissionToDelete)
objectGroup.DeleteGroup(false);
}
示例3: Connect
// Connect the Telehub
public void Connect(SceneObjectGroup grp)
{
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID;
m_Scene.RegionInfo.RegionSettings.Save();
}
示例4: TestGroupSerializationDeserialization
public void TestGroupSerializationDeserialization()
{
var sop1 = SceneUtil.RandomSOP("Root", 1);
var sop2 = SceneUtil.RandomSOP("Child1", 2);
var sop3 = SceneUtil.RandomSOP("Child2", 3);
SceneObjectGroup group = new SceneObjectGroup(sop1);
group.AddPart(sop2);
group.AddPart(sop3);
SceneObjectGroup deserGroup = null;
string grpBytes = null;
Assert.DoesNotThrow(() =>
{
grpBytes = SceneObjectSerializer.ToXml2Format(group, true);
});
Assert.NotNull(grpBytes);
Assert.DoesNotThrow(() =>
{
deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes);
});
CompareObjects comp = new CompareObjects();
comp.CompareStaticFields = false;
comp.CompareStaticProperties = false;
comp.ElementsToIgnore = PrimCompareIgnoreList;
Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString);
}
示例5: AddObject
public void AddObject(SceneObjectGroup obj)
{
if (m_childNodes == null)
{
if (!m_objects.Contains(obj))
{
m_objects.Add(obj);
}
}
else
{
if (obj.AbsolutePosition.X < (m_leftX + (m_width/2)))
{
if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
{
m_childNodes[0].AddObject(obj);
}
else
{
m_childNodes[2].AddObject(obj);
}
}
else
{
if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2)))
{
m_childNodes[1].AddObject(obj);
}
else
{
m_childNodes[3].AddObject(obj);
}
}
}
}
示例6: T010_AddObjects
public void T010_AddObjects()
{
TestHelpers.InMethod();
random = new Random();
SceneObjectGroup found;
EntityManager entman = new EntityManager();
SceneObjectGroup sog = NewSOG();
UUID obj1 = sog.UUID;
uint li1 = sog.LocalId;
entman.Add(sog);
sog = NewSOG();
UUID obj2 = sog.UUID;
uint li2 = sog.LocalId;
entman.Add(sog);
found = (SceneObjectGroup)entman[obj1];
Assert.That(found.UUID ,Is.EqualTo(obj1));
found = (SceneObjectGroup)entman[li1];
Assert.That(found.UUID ,Is.EqualTo(obj1));
found = (SceneObjectGroup)entman[obj2];
Assert.That(found.UUID ,Is.EqualTo(obj2));
found = (SceneObjectGroup)entman[li2];
Assert.That(found.UUID ,Is.EqualTo(obj2));
entman.Remove(obj1);
entman.Remove(li2);
Assert.That(entman.ContainsKey(obj1), Is.False);
Assert.That(entman.ContainsKey(li1), Is.False);
Assert.That(entman.ContainsKey(obj2), Is.False);
Assert.That(entman.ContainsKey(li2), Is.False);
}
示例7: CreateAsset
/// <summary>
/// Create an asset from the given scene object.
/// </summary>
/// <param name="assetUuid"></param>
/// <param name="sog"></param>
/// <returns></returns>
public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog)
{
return CreateAsset(
assetUuid,
AssetType.Object,
Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)),
sog.OwnerID);
}
示例8: AddInventoryItem
/// <summary>
/// Add an existing scene object as an item in the user's inventory.
/// </summary>
/// <remarks>
/// Will be added to the system Objects folder.
/// </remarks>
/// <param name='scene'></param>
/// <param name='so'></param>
/// <param name='inventoryIdTail'></param>
/// <param name='assetIdTail'></param>
/// <returns>The inventory item created.</returns>
public static InventoryItemBase AddInventoryItem(
Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail)
{
return AddInventoryItem(
scene,
so.Name,
TestHelpers.ParseTail(inventoryIdTail),
InventoryType.Object,
AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
so.OwnerID);
}
示例9: FromSceneObjectGroup
/// <summary>
/// Creates a new snapshot from the given group
/// </summary>
/// <param name="sog"></param>
/// <returns></returns>
public static SceneObjectGroupSnapshot FromSceneObjectGroup(SceneObjectGroup sog, SerializationFlags flags)
{
SceneObjectGroupSnapshot snapshot = new SceneObjectGroupSnapshot
{
RootPart = SceneObjectPartSnapshot.FromSceneObjectPart(sog.RootPart, flags)
};
var parts = sog.GetParts();
SceneObjectPartSnapshot[] partsSnap;
//do we have more than just the root?
if (parts.Count > 1)
{
List<SceneObjectPartSnapshot> partsCollect = new List<SceneObjectPartSnapshot>();
foreach (SceneObjectPart part in parts)
{
if (!part.IsRootPart())
{
partsCollect.Add(SceneObjectPartSnapshot.FromSceneObjectPart(part, flags));
}
}
partsSnap = partsCollect.ToArray();
}
else
{
//nope, just the root
partsSnap = new SceneObjectPartSnapshot[0];
}
snapshot.ChildParts = partsSnap;
if (sog.IsAttachment && sog.HasGroupChanged)
{
snapshot.TaintedAttachment = true;
}
else
{
snapshot.TaintedAttachment = false;
}
if (sog.IsAttachment && sog.IsTempAttachment)
{
snapshot.TempAttachment = true;
}
else
{
snapshot.TempAttachment = false;
}
return snapshot;
}
示例10: FromOriginalXmlFormat
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="xmlData"></param>
/// <returns>The scene object deserialized. Null on failure.</returns>
public static SceneObjectGroup FromOriginalXmlFormat(string xmlData)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
try
{
StringReader sr;
XmlTextReader reader;
XmlNodeList parts;
XmlDocument doc;
int linkNum;
doc = new XmlDocument();
doc.LoadXml(xmlData);
parts = doc.GetElementsByTagName("RootPart");
if (parts.Count == 0)
throw new Exception("Invalid Xml format - no root part");
sr = new StringReader(parts[0].InnerXml);
reader = new XmlTextReader(sr);
SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
reader.Close();
sr.Close();
parts = doc.GetElementsByTagName("Part");
for (int i = 0; i < parts.Count; i++)
{
sr = new StringReader(parts[i].InnerXml);
reader = new XmlTextReader(sr);
SceneObjectPart part = SceneObjectPart.FromXml(reader);
linkNum = part.LinkNum;
sceneObject.AddPart(part);
part.LinkNum = linkNum;
part.TrimPermissions();
reader.Close();
sr.Close();
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject.LoadScriptState(doc);
return sceneObject;
}
catch (Exception e)
{
m_log.ErrorFormat(
"[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
return null;
}
}
示例11: TestDuplicateObject
public void TestDuplicateObject()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
Scene scene = new SceneHelpers().SetupScene();
UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
string part1Name = "part1";
UUID part1Id = new UUID("00000000-0000-0000-0000-000000000001");
string part2Name = "part2";
UUID part2Id = new UUID("00000000-0000-0000-0000-000000000002");
SceneObjectPart part1
= new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = part1Name, UUID = part1Id };
SceneObjectGroup so = new SceneObjectGroup(part1);
SceneObjectPart part2
= new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = part2Name, UUID = part2Id };
so.AddPart(part2);
scene.AddNewSceneObject(so, false);
SceneObjectGroup dupeSo
= scene.SceneGraph.DuplicateObject(
part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity);
Assert.That(dupeSo.Parts.Length, Is.EqualTo(2));
SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1);
SceneObjectPart dupePart2 = dupeSo.GetLinkNumPart(2);
Assert.That(dupePart1.LocalId, Is.Not.EqualTo(part1.LocalId));
Assert.That(dupePart2.LocalId, Is.Not.EqualTo(part2.LocalId));
Assert.That(dupePart1.Flags, Is.EqualTo(part1.Flags));
Assert.That(dupePart2.Flags, Is.EqualTo(part2.Flags));
/*
Assert.That(part1.PhysActor, Is.Not.Null);
Assert.That(part2.PhysActor, Is.Not.Null);
Assert.That(dupePart1.PhysActor, Is.Not.Null);
Assert.That(dupePart2.PhysActor, Is.Not.Null);
*/
// TestHelpers.DisableLogging();
}
示例12: FromOriginalXmlFormat
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="xmlData"></param>
/// <returns>The scene object deserialized. Null on failure.</returns>
public static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
SceneObjectGroup sceneObject = null;
try
{
int linkNum;
reader.ReadToFollowing("RootPart");
reader.ReadToFollowing("SceneObjectPart");
sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
reader.ReadToFollowing("OtherParts");
if (reader.ReadToDescendant("Part"))
{
do
{
if (reader.ReadToDescendant("SceneObjectPart"))
{
SceneObjectPart part = SceneObjectPart.FromXml(reader);
linkNum = part.LinkNum;
sceneObject.AddPart(part);
part.LinkNum = linkNum;
part.TrimPermissions();
}
}
while (reader.ReadToNextSibling("Part"));
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject.LoadScriptState(reader);
}
catch (Exception e)
{
m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed. Exception {0}", e);
return null;
}
return sceneObject;
}
示例13: TestDelinkPersistence
public void TestDelinkPersistence()
{
TestHelpers.InMethod();
//log4net.Config.XmlConfigurator.Configure();
TestScene scene = new SceneHelpers().SetupScene();
string rootPartName = "rootpart";
UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
string linkPartName = "linkpart";
UUID linkPartUuid = new UUID("00000000-0000-0000-0001-000000000000");
SceneObjectPart rootPart
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = rootPartName, UUID = rootPartUuid };
SceneObjectPart linkPart
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = linkPartName, UUID = linkPartUuid };
SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart);
scene.AddNewSceneObject(linkGroup, true);
SceneObjectGroup sog = new SceneObjectGroup(rootPart);
scene.AddNewSceneObject(sog, true);
Assert.IsFalse(sog.GroupContainsForeignPrims);
sog.LinkToGroup(linkGroup);
Assert.IsTrue(sog.GroupContainsForeignPrims);
scene.Backup(true);
Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count);
// These changes should occur immediately without waiting for a backup pass
SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false);
Assert.IsFalse(groupToDelete.GroupContainsForeignPrims);
scene.DeleteSceneObject(groupToDelete, false);
List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);
Assert.AreEqual(1, storedObjects.Count);
Assert.AreEqual(1, storedObjects[0].Parts.Length);
Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid));
}
示例14: TestGroupInventorySerializationDeserialization
public void TestGroupInventorySerializationDeserialization()
{
var sop1 = Util.RandomSOP("Root", 1);
var sop2 = Util.RandomSOP("Child1", 2);
var sop3 = Util.RandomSOP("Child2", 3);
SceneObjectGroup group = new SceneObjectGroup(sop1);
group.AddPart(sop2);
group.AddPart(sop3);
var grpBytes = serEngine.InventoryObjectSerializer.SerializeGroupToInventoryBytes(group, SerializationFlags.None);
SceneObjectGroup deserGroup = serEngine.InventoryObjectSerializer.DeserializeGroupFromInventoryBytes(grpBytes);
CompareObjects comp = new CompareObjects();
comp.CompareStaticFields = false;
comp.CompareStaticProperties = false;
comp.ElementsToIgnore = PrimCompareIgnoreList;
Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString);
}
示例15: CreateEntity
public SceneObjectGroup CreateEntity(
UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
{
if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
{
m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
return null;
}
SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
// if grass or tree, make phantom
//rootPart.TrimPermissions();
rootPart.AddFlag(PrimFlags.Phantom);
if (rootPart.Shape.PCode != (byte)PCode.Grass)
AdaptTree(ref shape);
m_scene.AddNewSceneObject(sceneObject, true);
sceneObject.SetGroup(groupID, null);
return sceneObject;
}