* ImportCommand now creates prims.
* Added SetTextures, SetLight, SetFlexible functions to ObjectManager. * Added XML defaults to ParticleSystem and TextureAnimation. * Fixed an XML default for LLQuaternion. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@698 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -3,16 +3,27 @@ using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
using libsecondlife.Packets;
|
||||
using System.Xml;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
|
||||
namespace libsecondlife.TestClient
|
||||
{
|
||||
public class ImportCommand : Command
|
||||
{
|
||||
PrimObject currentPrim;
|
||||
LLVector3 currentPosition;
|
||||
SecondLife currentClient;
|
||||
ManualResetEvent primDone;
|
||||
List<PrimObject> primsCreated;
|
||||
bool registeredCreateEvent;
|
||||
|
||||
public ImportCommand()
|
||||
{
|
||||
Name = "import";
|
||||
Description = "Import prims from an exported xml file. Usage: import [filename.xml]";
|
||||
primDone = new ManualResetEvent(false);
|
||||
registeredCreateEvent = false;
|
||||
}
|
||||
|
||||
public override string Execute(SecondLife Client, string[] args, LLUUID fromAgentID)
|
||||
@@ -21,7 +32,8 @@ namespace libsecondlife.TestClient
|
||||
return "Usage: import inputfile.xml";
|
||||
|
||||
string name = args[0];
|
||||
List<PrimObject> prims;
|
||||
|
||||
Dictionary<uint, PrimObject> prims;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -35,7 +47,13 @@ namespace libsecondlife.TestClient
|
||||
events.OnUnknownElement += new XmlElementEventHandler(OnUnknownElement);
|
||||
events.OnUnknownNode += new XmlNodeEventHandler(OnUnknownNode);
|
||||
events.OnUnreferencedObject += new UnreferencedObjectEventHandler(OnUnreferenced);
|
||||
prims = (List<PrimObject>)serializer.Deserialize(XmlReader.Create(name), events);
|
||||
List<PrimObject> listprims = (List<PrimObject>)serializer.Deserialize(XmlReader.Create(name), events);
|
||||
|
||||
prims = new Dictionary<uint, PrimObject>();
|
||||
foreach (PrimObject prim in listprims)
|
||||
{
|
||||
prims.Add(prim.LocalID, prim);
|
||||
}
|
||||
//return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -43,8 +61,51 @@ namespace libsecondlife.TestClient
|
||||
return "Deserialize failed: " + ex.ToString();
|
||||
}
|
||||
|
||||
// deserialization done, just need to code to rez and link.
|
||||
return "Deserialized " + prims.Count + " prims, rez code missing.";
|
||||
if (!registeredCreateEvent)
|
||||
{
|
||||
TestClient.OnPrimCreated += new TestClient.PrimCreatedCallback(TestClient_OnPrimCreated);
|
||||
registeredCreateEvent = true;
|
||||
}
|
||||
|
||||
primsCreated = new List<PrimObject>();
|
||||
Console.WriteLine("Importing " + prims.Count + " prims.");
|
||||
|
||||
foreach (PrimObject prim in prims.Values)
|
||||
{
|
||||
currentPrim = prim;
|
||||
currentClient = Client;
|
||||
if (prim.ParentID != 0)
|
||||
{
|
||||
if (prims.ContainsKey(prim.ParentID))
|
||||
{
|
||||
currentPosition = prims[prim.ParentID].Position + prim.Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Rez failed, a child prim did not have a matching parent prim. ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPosition = prim.Position;
|
||||
}
|
||||
Client.Objects.AddPrim(Client.Network.CurrentSim, prim, currentPosition);
|
||||
if (!primDone.WaitOne(10000, false))
|
||||
return "Rez failed, timed out while creating a prim.";
|
||||
primDone.Reset();
|
||||
}
|
||||
|
||||
return "Import complete.";
|
||||
}
|
||||
|
||||
void TestClient_OnPrimCreated(Simulator simulator, PrimObject prim)
|
||||
{
|
||||
primsCreated.Add(prim);
|
||||
currentClient.Objects.SetPosition(simulator, prim.LocalID, currentPosition);
|
||||
currentClient.Objects.SetTextures(simulator, prim.LocalID, currentPrim.Textures);
|
||||
//currentClient.Objects.SetLight(simulator, prim.LocalID, currentPrim.Light);
|
||||
//currentClient.Objects.SetFlexible(simulator, prim.LocalID, currentPrim.Flexible);
|
||||
primDone.Set();
|
||||
}
|
||||
|
||||
void OnUnknownAttribute(object obj, XmlAttributeEventArgs args)
|
||||
|
||||
Reference in New Issue
Block a user