本文整理汇总了C#中OpenSim.Region.Framework.Scenes.SceneObjectGroup.SetRootPart方法的典型用法代码示例。如果您正苦于以下问题:C# SceneObjectGroup.SetRootPart方法的具体用法?C# SceneObjectGroup.SetRootPart怎么用?C# SceneObjectGroup.SetRootPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.SceneObjectGroup
的用法示例。
在下文中一共展示了SceneObjectGroup.SetRootPart方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAdd
//.........这里部分代码省略.........
pbs.PathTaperX = (sbyte) obj.TaperX;
pbs.PathTaperY = (sbyte) obj.TaperY;
pbs.PathTwist = (sbyte) obj.Twist;
pbs.PathTwistBegin = (sbyte) obj.TwistBegin;
pbs.HollowShape = (HollowShape) obj.ProfileHollow;
pbs.PCode = (byte) PCode.Prim;
pbs.ProfileBegin = (ushort) obj.ProfileBegin;
pbs.ProfileCurve = (byte) obj.ProfileCurve;
pbs.ProfileEnd = (ushort) obj.ProfileEnd;
pbs.Scale = obj.Scale;
pbs.State = (byte) 0;
pbs.LastAttachPoint = (byte) 0;
SceneObjectPart prim = new SceneObjectPart();
prim.UUID = UUID.Random();
prim.CreatorID = AgentId;
prim.OwnerID = AgentId;
prim.GroupID = obj.GroupID;
prim.LastOwnerID = prim.OwnerID;
prim.CreationDate = Util.UnixTimeSinceEpoch();
prim.Name = obj.Name;
prim.Description = "";
prim.PayPrice[0] = -2;
prim.PayPrice[1] = -2;
prim.PayPrice[2] = -2;
prim.PayPrice[3] = -2;
prim.PayPrice[4] = -2;
Primitive.TextureEntry tmp =
new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f"));
for (int j = 0; j < obj.Faces.Length; j++)
{
UploadObjectAssetMessage.Object.Face face = obj.Faces[j];
Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j);
primFace.Bump = face.Bump;
primFace.RGBA = face.Color;
primFace.Fullbright = face.Fullbright;
primFace.Glow = face.Glow;
primFace.TextureID = face.ImageID;
primFace.Rotation = face.ImageRot;
primFace.MediaFlags = ((face.MediaFlags & 1) != 0);
primFace.OffsetU = face.OffsetS;
primFace.OffsetV = face.OffsetT;
primFace.RepeatU = face.ScaleS;
primFace.RepeatV = face.ScaleT;
primFace.TexMapType = (MappingType) (face.MediaFlags & 6);
}
pbs.TextureEntry = tmp.GetBytes();
prim.Shape = pbs;
prim.Scale = obj.Scale;
SceneObjectGroup grp = new SceneObjectGroup();
grp.SetRootPart(prim);
prim.ParentID = 0;
if (i == 0)
{
rootGroup = grp;
}
grp.AttachToScene(m_scene);
grp.AbsolutePosition = obj.Position;
prim.RotationOffset = obj.Rotation;
// Required for linking
grp.RootPart.ClearUpdateSchedule();
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
{
m_scene.AddSceneObject(grp);
grp.AbsolutePosition = obj.Position;
}
allparts[i] = grp;
}
for (int j = 1; j < allparts.Length; j++)
{
// Required for linking
rootGroup.RootPart.ClearUpdateSchedule();
allparts[j].RootPart.ClearUpdateSchedule();
rootGroup.LinkToGroup(allparts[j]);
}
rootGroup.ScheduleGroupForFullUpdate();
pos
= m_scene.GetNewRezLocation(
Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale, false);
responsedata["int_response_code"] = 200; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId));
return responsedata;
}
示例2: Xml2ToSOG
//////// Read /////////
public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
{
reader.Read();
reader.ReadStartElement("SceneObjectGroup");
SceneObjectPart root = Xml2ToSOP(reader, sog.Scene);
if (root != null)
sog.SetRootPart(root);
else
{
return false;
}
if (sog.UUID == UUID.Zero)
sog.UUID = sog.RootPart.UUID;
reader.Read(); // OtherParts
while (!reader.EOF)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == "SceneObjectPart")
{
SceneObjectPart child = Xml2ToSOP(reader, sog.Scene);
if (child != null)
sog.AddChild(child, child.LinkNum);
}
else
{
//Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
reader.Read();
}
break;
case XmlNodeType.EndElement:
default:
reader.Read();
break;
}
}
return true;
}
示例3: T013_DatabasePersistency
//.........这里部分代码省略.........
sop.Description = description;
sop.Color = color;
sop.Text = text;
sop.SitName = sitname;
sop.TouchName = touchname;
sop.LinkNum = linknum;
sop.ClickAction = clickaction;
sop.Scale = scale;
sop.UpdateFlag = updatef;
//Tests if local part accepted the parameters:
Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))");
Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))");
Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))");
Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))");
Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))");
Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))");
// Modified in-class
// Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))");
Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))");
Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))");
Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))");
Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))");
Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))");
Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))");
Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))");
Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))");
Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))");
Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))");
Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))");
Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))");
Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))");
Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))");
Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))");
Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))");
Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))");
Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))");
Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))");
Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))");
Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))");
Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))");
// This is necessary or object will not be inserted in DB
sop.ObjectFlags = 0;
SceneObjectGroup sog = new SceneObjectGroup();
sog.SetScene(scene); // Reguired by nhibernate database module.
sog.SetRootPart(sop);
// Inserts group in DB
db.StoreObject(sog,region3);
List<SceneObjectGroup> sogs = db.LoadObjects(region3);
Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
// Makes sure there are no double insertions:
db.StoreObject(sog,region3);
sogs = db.LoadObjects(region3);
Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))");
// Tests if the parameters were inserted correctly
SceneObjectPart p = sogs[0].RootPart;
Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))");
//Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))");
Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))");
Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))");
Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))");
Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))");
//Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))");
Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))");
//Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))");
Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))");
Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))");
Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))");
Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))");
Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))");
//Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))");
//Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))");
Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))");
Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))");
Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))");
Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))");
Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))");
Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))");
Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))");
Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))");
Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))");
//Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))");
Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))");
Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))");
//Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))");
Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))");
Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))");
Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))");
Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))");
Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))");
}
示例4: NewSOG
// This builds a minimalistic Prim, 1 SOG with 1 root SOP. A
// common failure case is people adding new fields that aren't
// initialized, but have non-null db constraints. We should
// honestly be passing more and more null things in here.
//
// Please note that in Sqlite.BuildPrim there is a commented out inline version
// of this so you can debug and step through the build process and check the fields
//
// Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart
// causes the application to crash at the database layer because of null values
// in NOT NULL fields
//
private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId)
{
RegionInfo regionInfo = new RegionInfo();
regionInfo.RegionID = regionId;
regionInfo.RegionLocX = 0;
regionInfo.RegionLocY = 0;
Scene scene = new Scene(regionInfo);
SceneObjectPart sop = new SceneObjectPart();
sop.Name = name;
sop.Description = name;
sop.Text = RandomName();
sop.SitName = RandomName();
sop.TouchName = RandomName();
sop.UUID = uuid;
sop.Shape = PrimitiveBaseShape.Default;
SceneObjectGroup sog = new SceneObjectGroup();
sog.SetScene(scene);
sog.SetRootPart(sop);
return sog;
}
示例5: LoadObject
private SceneObjectGroup LoadObject(UUID uuid, UUID region)
{
SceneObjectGroup group = new SceneObjectGroup();
ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart));
criteria.Add(Expression.Eq("RegionID", region));
criteria.Add(Expression.Eq("ParentUUID", uuid));
criteria.AddOrder(Order.Asc("ParentID"));
foreach (SceneObjectPart p in criteria.List())
{
// root part
if (p.UUID == uuid)
{
group.SetRootPart(p);
}
else
{
group.AddPart(p);
}
}
return group;
}
示例6: LoadObjects
/// <summary>
/// Load persisted objects from region storage.
/// </summary>
/// <param name="regionUUID">The region UUID</param>
/// <returns>List of loaded groups</returns>
public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
{
Dictionary<UUID, SceneObjectGroup> SOG = new Dictionary<UUID, SceneObjectGroup>();
List<SceneObjectGroup> ret = new List<SceneObjectGroup>();
ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart));
criteria.Add(Expression.Eq("RegionID", regionUUID));
criteria.AddOrder(Order.Asc("ParentID"));
criteria.AddOrder(Order.Asc("LinkNum"));
foreach (SceneObjectPart p in criteria.List())
{
// root part
if (p.UUID == p.ParentUUID)
{
SceneObjectGroup group = new SceneObjectGroup();
group.SetRootPart(p);
SOG.Add(p.ParentUUID, group);
}
else
{
SOG[p.ParentUUID].AddPart(p);
}
// get the inventory
ICriteria InvCriteria = manager.GetSession().CreateCriteria(typeof(TaskInventoryItem));
InvCriteria.Add(Expression.Eq("ParentPartID", p.UUID));
IList<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
foreach (TaskInventoryItem i in InvCriteria.List())
{
inventory.Add(i);
}
if (inventory.Count > 0)
p.Inventory.RestoreInventoryItems(inventory);
}
foreach (SceneObjectGroup g in SOG.Values)
{
ret.Add(g);
}
return ret;
}
示例7: NewSOG
private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
{
SceneObjectPart sop = new SceneObjectPart();
sop.Name = RandomName();
sop.Description = RandomName();
sop.Text = RandomName();
sop.SitName = RandomName();
sop.TouchName = RandomName();
sop.UUID = uuid;
sop.Shape = PrimitiveBaseShape.Default;
sop.Shape.State = 1;
sop.OwnerID = agent;
SceneObjectGroup sog = new SceneObjectGroup();
sog.SetScene(scene);
sog.SetRootPart(sop);
return sog;
}
示例8: LoadObjects
/// <summary>
/// Load persisted objects from region storage.
/// </summary>
/// <param name="regionUUID">The region UUID</param>
/// <returns>List of loaded groups</returns>
public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
{
Dictionary<UUID, SceneObjectGroup> createdObjects = new Dictionary<UUID, SceneObjectGroup>();
List<SceneObjectGroup> retvals = new List<SceneObjectGroup>();
DataTable prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"];
string byRegion = "RegionUUID = '" + regionUUID + "'";
lock (ds)
{
DataRow[] primsForRegion = prims.Select(byRegion);
m_log.Info("[REGION DB]: Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
// First, create all groups
foreach (DataRow primRow in primsForRegion)
{
try
{
SceneObjectPart prim = null;
string uuid = (string) primRow["UUID"];
string objID = (string) primRow["SceneGroupID"];
if (uuid == objID) //is new SceneObjectGroup ?
{
SceneObjectGroup group = new SceneObjectGroup();
prim = buildPrim(primRow);
DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString());
if (shapeRow != null)
{
prim.Shape = buildShape(shapeRow);
}
else
{
m_log.Info(
"[REGION DB]: No shape found for prim in storage, so setting default box shape");
prim.Shape = PrimitiveBaseShape.Default;
}
group.SetRootPart(prim);
createdObjects.Add(group.UUID, group);
retvals.Add(group);
LoadItems(prim);
}
}
catch (Exception e)
{
m_log.Error("[REGION DB]: Failed create prim object in new group, exception and data follows");
m_log.Info("[REGION DB]: " + e.ToString());
foreach (DataColumn col in prims.Columns)
{
m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]);
}
}
}
// Now fill the groups with part data
foreach (DataRow primRow in primsForRegion)
{
try
{
SceneObjectPart prim = null;
string uuid = (string) primRow["UUID"];
string objID = (string) primRow["SceneGroupID"];
if (uuid != objID) //is new SceneObjectGroup ?
{
prim = buildPrim(primRow);
DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString());
if (shapeRow != null)
{
prim.Shape = buildShape(shapeRow);
}
else
{
m_log.Warn(
"[REGION DB]: No shape found for prim in storage, so setting default box shape");
prim.Shape = PrimitiveBaseShape.Default;
}
createdObjects[new UUID(objID)].AddPart(prim);
LoadItems(prim);
}
}
catch (Exception e)
{
m_log.Error("[REGION DB]: Failed create prim object in group, exception and data follows");
m_log.Info("[REGION DB]: " + e.ToString());
foreach (DataColumn col in prims.Columns)
{
m_log.Info("[REGION DB]: Col: " + col.ColumnName + " => " + primRow[col]);
}
//.........这里部分代码省略.........
示例9: ToSceneObjectGroup
internal SceneObjectGroup ToSceneObjectGroup()
{
SceneObjectGroup sog = new SceneObjectGroup();
SceneObjectPart rootPart = RootPart.ToSceneObjectPart();
sog.SetRootPart(rootPart);
if (ChildParts != null)
{
foreach (var partSnap in ChildParts)
{
SceneObjectPart childPart = partSnap.ToSceneObjectPart();
int originalLinkNum = childPart.LinkNum;
sog.AddPart(childPart);
// SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
// We override that here
if (originalLinkNum != 0)
childPart.LinkNum = originalLinkNum;
childPart.StoreUndoState();
}
}
sog.TaintedAttachment = this.TaintedAttachment;
sog.IsTempAttachment = this.TempAttachment;
return sog;
}
示例10: FromOriginalXmlFormat
/// <summary>
/// Deserialize a scene object from the original xml format
/// </summary>
/// <param name="serialization"></param>
/// <returns></returns>
public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string xmlData)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
SceneObjectGroup sceneObject = new SceneObjectGroup();
// libomv.types changes UUID to Guid
xmlData = xmlData.Replace("<UUID>", "<Guid>");
xmlData = xmlData.Replace("</UUID>", "</Guid>");
// Handle Nested <UUID><UUID> property
xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
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");
}
else
{
sr = new StringReader(parts[0].InnerXml);
reader = new XmlTextReader(sr);
sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, 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();
part.StoreUndoState();
reader.Close();
sr.Close();
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject.LoadScriptState(doc);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
}
//m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
return sceneObject;
}
示例11: FromXml2Format
public static SceneObjectGroup FromXml2Format(string xmlData)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
SceneObjectGroup sceneObject = new SceneObjectGroup();
// libomv.types changes UUID to Guid
xmlData = xmlData.Replace("<UUID>", "<Guid>");
xmlData = xmlData.Replace("</UUID>", "</Guid>");
// Handle Nested <UUID><UUID> property
xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlData);
XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
// Process the root part first
if (parts.Count > 0)
{
StringReader sr = new StringReader(parts[0].OuterXml);
XmlTextReader reader = new XmlTextReader(sr);
sceneObject.SetRootPart(SceneObjectPart.FromXml(reader));
reader.Close();
sr.Close();
}
// Then deal with the rest
for (int i = 1; i < parts.Count; i++)
{
StringReader sr = new StringReader(parts[i].OuterXml);
XmlTextReader reader = new XmlTextReader(sr);
SceneObjectPart part = SceneObjectPart.FromXml(reader);
sceneObject.AddPart(part);
part.StoreUndoState();
reader.Close();
sr.Close();
}
// Script state may, or may not, exist. Not having any, is NOT
// ever a problem.
sceneObject.LoadScriptState(doc);
}
catch (Exception e)
{
m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
}
//m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
return sceneObject;
}
示例12: CreatePointEntity
private void CreatePointEntity(Scene scene, UUID uuid, Vector3 groupPos)
{
SceneObjectGroup x = new SceneObjectGroup();
SceneObjectPart y = new SceneObjectPart();
//Initialize part
y.Name = "Very Small Point";
y.RegionHandle = scene.RegionInfo.RegionHandle;
y.CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
y.OwnerID = UUID.Zero;
y.CreatorID = UUID.Zero;
y.LastOwnerID = UUID.Zero;
y.UUID = uuid;
y.Shape = PrimitiveBaseShape.CreateBox();
y.Scale = new Vector3(0.01f,0.01f,0.01f);
y.LastOwnerID = UUID.Zero;
y.GroupPosition = groupPos;
y.OffsetPosition = new Vector3(0, 0, 0);
y.RotationOffset = new Quaternion(0,0,0,0);
y.Velocity = new Vector3(0, 0, 0);
y.RotationalVelocity = new Vector3(0, 0, 0);
y.AngularVelocity = new Vector3(0, 0, 0);
y.Acceleration = new Vector3(0, 0, 0);
y.Flags = 0;
y.TrimPermissions();
//Initialize group and add part as root part
x.SetScene(scene);
x.SetRootPart(y);
x.RegionHandle = scene.RegionInfo.RegionHandle;
x.SetScene(scene);
m_Entity = x;
}
示例13: DecodeSceneObject
/// <summary>
/// Decode & create a SOG data structure. Due to the fact that PhysActor
/// is only created when SOG.AttachToScene() is called, the returned SOG
/// here only have non PhysActor properties decoded and values set. The
/// PhysActor properties should be set later by the caller.
/// </summary>
/// <param name="data"></param>
/// <param name="sog"></param>
/// <param name="syncInfos"></param>
/// <returns>True of decoding sucessfully</returns>
protected bool DecodeSceneObject(OSDMap data, out SceneObjectGroup sog, out Dictionary<UUID, SyncInfoBase> syncInfos, Scene scene)
{
sog = new SceneObjectGroup();
syncInfos = new Dictionary<UUID, SyncInfoBase>();
bool ret = true;
try{
OSDMap rootPart = (OSDMap)data["RootPart"];
UUID uuid = rootPart["uuid"].AsUUID();
OSDArray properties = (OSDArray)rootPart["properties"];
//m_log.WarnFormat("{0} DecodeSceneObject for RootPart uuid: {1}", LogHeader, uuid);
//Decode and copy to the list of PrimSyncInfo
SyncInfoPrim sip = new SyncInfoPrim(uuid, properties, scene);
SceneObjectPart root = (SceneObjectPart)sip.SceneThing;
sog.SetRootPart(root);
sip.SetPropertyValues(SyncableProperties.GroupProperties);
syncInfos.Add(root.UUID, sip);
if (sog.UUID == UUID.Zero)
sog.UUID = sog.RootPart.UUID;
//Decode the remaining parts and add them to the object group
if (data.ContainsKey("OtherParts"))
{
//int otherPartsCount = data["OtherPartsCount"].AsInteger();
OSDArray otherPartsArray = (OSDArray)data["OtherParts"];
foreach (OSDMap otherPart in otherPartsArray)
{
uuid = otherPart["uuid"].AsUUID();
properties = (OSDArray)otherPart["properties"];
//m_log.WarnFormat("{0} DecodeSceneObject for OtherParts[{1}] uuid: {2}", LogHeader, i, uuid);
sip = new SyncInfoPrim(uuid, properties, scene);
SceneObjectPart part = (SceneObjectPart)sip.SceneThing;
if (part == null)
{
m_log.ErrorFormat("{0} DecodeSceneObject could not decode root part.", LogHeader);
sog = null;
return false;
}
sog.AddPart(part);
// Should only need to set group properties from the root part, not other parts
//sip.SetPropertyValues(SyncableProperties.GroupProperties);
syncInfos.Add(part.UUID, sip);
}
}
sog.IsAttachment = data["IsAttachment"].AsBoolean();
sog.AttachedAvatar = data["AttachedAvatar"].AsUUID();
uint ap = data["AttachmentPoint"].AsUInteger();
if (sog.RootPart == null)
{
//m_log.WarnFormat("{0} DecodeSceneObject - ROOT PART IS NULL", LogHeader);
}
else if (sog.RootPart.Shape == null)
{
//m_log.WarnFormat("{0} DecodeSceneObject - ROOT PART SHAPE IS NULL", LogHeader);
}
else
{
sog.AttachmentPoint = ap;
//m_log.WarnFormat("{0}: DecodeSceneObject AttachmentPoint = {1}", LogHeader, sog.AttachmentPoint);
}
}
catch (Exception e)
{
m_log.WarnFormat("{0} Encountered an exception: {1} {2} {3}", "DecodeSceneObject", e.Message, e.TargetSite, e.ToString());
ret = false;
}
//else
// m_log.WarnFormat("{0}: DecodeSceneObject AttachmentPoint = null", LogHeader);
return ret;
}