From 0a377238f8e645f708b67bca1d6bb7ce879bd4a4 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 4 Apr 2007 19:55:31 +0000 Subject: [PATCH] more work on Primitive2 --- OpenSim.RegionServer/OpenSimMain.cs | 7 +- OpenSim.RegionServer/RegionInfo.cs | 33 +++-- OpenSim.RegionServer/world/Primitive2.cs | 155 +++++++++++++++++++---- 3 files changed, 152 insertions(+), 43 deletions(-) diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index e609b6c7ae..7b0bd4babe 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -54,7 +54,7 @@ namespace OpenSim public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback { - //private SimConfig Cfg; + //private SimConfig Cfg; private IGenericConfig localConfig; //private IGenericConfig remoteConfig; private PhysicsManager physManager; @@ -110,8 +110,9 @@ namespace OpenSim } m_console.WriteLine("Main.cs:Startup() - Loading configuration"); this.regionData.InitConfig(this.m_sandbox, this.localConfig); - regionData.SimUUID = new LLUUID(localConfig.GetAttribute("SimUUID")); - this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change + //regionData.SimUUID = new LLUUID(localConfig.GetAttribute("SimUUID")); //don't need as regionData.SimUUID is already set through the above line + this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change + GridServers = new Grid(); if (m_sandbox) diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs index 15998cf4b5..cf0c075856 100644 --- a/OpenSim.RegionServer/RegionInfo.cs +++ b/OpenSim.RegionServer/RegionInfo.cs @@ -9,9 +9,8 @@ namespace OpenSim { public class RegionInfo // could inherit from SimProfileBase { + public LLUUID SimUUID; public string RegionName; - public LLUUID SimUUID; - public uint RegionLocX; public uint RegionLocY; public ulong RegionHandle; @@ -42,21 +41,21 @@ namespace OpenSim this.isSandbox = sandboxMode; try { - // Sim UUID - string attri =""; - attri = configData.GetAttribute("SimUUID"); - if (attri == "") - { - this.SimUUID = LLUUID.Random(); - configData.SetAttribute("SimUUID", this.SimUUID.ToString()); - } - else - { - this.SimUUID = new LLUUID(attri); - } + // Sim UUID + string attri = ""; + attri = configData.GetAttribute("SimUUID"); + if (attri == "") + { + this.SimUUID = LLUUID.Random(); + configData.SetAttribute("SimUUID", this.SimUUID.ToString()); + } + else + { + this.SimUUID = new LLUUID(attri); + } // Sim name - attri =""; + attri = ""; attri = configData.GetAttribute("SimName"); if (attri == "") { @@ -116,7 +115,7 @@ namespace OpenSim } else { - this.IPListenAddr = attri; + this.IPListenAddr = attri; } if (!isSandbox) @@ -231,7 +230,7 @@ namespace OpenSim OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("UUID: " + this.SimUUID.ToStringHyphenated()); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs index 4a190401c7..2ab147042d 100644 --- a/OpenSim.RegionServer/world/Primitive2.cs +++ b/OpenSim.RegionServer/world/Primitive2.cs @@ -24,6 +24,8 @@ namespace OpenSim.world private Dictionary inventoryItems; private string inventoryFileName = ""; + #region Properties + public LLVector3 Scale { set @@ -45,6 +47,7 @@ namespace OpenSim.world } } + #endregion public Primitive2(Dictionary clientThreads, ulong regionHandle, World world) { @@ -88,16 +91,44 @@ namespace OpenSim.world return result; } + #region Overridden Methods + public override void update() { LLVector3 pos2 = new LLVector3(0, 0, 0); } - public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) + public override void BackUp() { } + #endregion + + #region Packet handlers + + public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) + { + this.primData.PathBegin = addPacket.PathBegin; + this.primData.PathEnd = addPacket.PathEnd; + this.primData.PathScaleX = addPacket.PathScaleX; + this.primData.PathScaleY = addPacket.PathScaleY; + this.primData.PathShearX = addPacket.PathShearX; + this.primData.PathShearY = addPacket.PathShearY; + this.primData.PathSkew = addPacket.PathSkew; + this.primData.ProfileBegin = addPacket.ProfileBegin; + this.primData.ProfileEnd = addPacket.ProfileEnd; + this.primData.PathCurve = addPacket.PathCurve; + this.primData.ProfileCurve = addPacket.ProfileCurve; + this.primData.ProfileHollow = addPacket.ProfileHollow; + this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; + this.primData.PathRevolutions = addPacket.PathRevolutions; + this.primData.PathTaperX = addPacket.PathTaperX; + this.primData.PathTaperY = addPacket.PathTaperY; + this.primData.PathTwist = addPacket.PathTwist; + this.primData.PathTwistBegin = addPacket.PathTwistBegin; + } + public void UpdateTexture(byte[] tex) { this.OurPacket.ObjectData[0].TextureEntry = tex; @@ -115,6 +146,10 @@ namespace OpenSim.world } + #endregion + + # region Inventory Methods + public bool AddToInventory(InventoryItem item) { return false; @@ -164,39 +199,57 @@ namespace OpenSim.world } - public override void BackUp() + #endregion + + #region Update viewers methods + + public void SendFullUpdateToClient(SimClient remoteClient) + { + LLVector3 lPos; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + else + { + lPos = this.Pos; + } + byte[] pb = lPos.GetBytes(); + Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); + + this.UpdatePacketShapeData(); + remoteClient.OutPacket(OurPacket); + } + + public void SendTerseUpdateToClient(SimClient RemoteClient) { } + public void SendTerseUpdateToALLClients() + { + + } + + #endregion + + #region Create Methods + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; - objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; PrimData PData = new PrimData(); this.primData = PData; this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock(); - objupdate.ObjectData[0].PSBlock = new byte[0]; - objupdate.ObjectData[0].ExtraParams = new byte[1]; - objupdate.ObjectData[0].MediaURL = new byte[0]; - objupdate.ObjectData[0].NameValue = new byte[0]; - objupdate.ObjectData[0].Text = new byte[0]; - objupdate.ObjectData[0].TextColor = new byte[4]; - objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0); - objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); - objupdate.ObjectData[0].Material = 3; + this.SetDefaultPacketValues(objupdate.ObjectData[0]); + objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; - objupdate.ObjectData[0].TextureAnim = new byte[0]; - objupdate.ObjectData[0].Sound = LLUUID.Zero; - LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes(); - objupdate.ObjectData[0].State = 0; - objupdate.ObjectData[0].Data = new byte[0]; PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID; PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode; PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin; @@ -221,9 +274,6 @@ namespace OpenSim.world PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin; objupdate.ObjectData[0].ID = (uint)(localID); objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000")); - objupdate.ObjectData[0].ObjectData = new byte[60]; - objupdate.ObjectData[0].ObjectData[46] = 128; - objupdate.ObjectData[0].ObjectData[47] = 63; LLVector3 pos1 = addPacket.ObjectData.RayEnd; //update position byte[] pb = pos1.GetBytes(); @@ -235,12 +285,71 @@ namespace OpenSim.world this.OurPacket = objupdate; } - public void SendFullUpdateToClient(SimClient RemoteClient) + public void CreateFromBytes(byte[] data) { } - public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() + public void CreateFromPrimData(PrimData primData) + { + + } + + #endregion + + #region Packet Update Methods + protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) + { + objdata.PSBlock = new byte[0]; + objdata.ExtraParams = new byte[1]; + objdata.MediaURL = new byte[0]; + objdata.NameValue = new byte[0]; + objdata.Text = new byte[0]; + objdata.TextColor = new byte[4]; + objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); + objdata.JointPivot = new LLVector3(0, 0, 0); + objdata.Material = 3; + objdata.TextureAnim = new byte[0]; + objdata.Sound = LLUUID.Zero; + LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); + this.primData.Texture = objdata.TextureEntry = ntex.ToBytes(); + objdata.State = 0; + objdata.Data = new byte[0]; + + objdata.ObjectData = new byte[60]; + objdata.ObjectData[46] = 128; + objdata.ObjectData[47] = 63; + } + + protected void UpdatePacketShapeData() + { + OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; + OurPacket.ObjectData[0].PCode = this.primData.PCode; + OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; + OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; + OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; + OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; + OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; + OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; + OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; + OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; + OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; + OurPacket.ObjectData[0].Scale = this.primData.Scale; + OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; + OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; + OurPacket.ObjectData[0].ParentID = this.primData.ParentID; + OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; + OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; + OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; + OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; + OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; + OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; + OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; + } + + #endregion + + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() { uint ID = this.localid; byte[] bytes = new byte[60];