From 488e71620866c0749a0347d878f0707de2b8eb15 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 10 Jun 2007 15:43:04 +0000 Subject: Prim creation working. --- OpenSim/OpenSim.Region/World/Avatar.cs | 10 +-- OpenSim/OpenSim.Region/World/Primitive.cs | 141 +++++++++++++----------------- OpenSim/OpenSim.Region/World/World.cs | 23 ++++- 3 files changed, 82 insertions(+), 92 deletions(-) (limited to 'OpenSim/OpenSim.Region') diff --git a/OpenSim/OpenSim.Region/World/Avatar.cs b/OpenSim/OpenSim.Region/World/Avatar.cs index 88a7969..65af5a6 100644 --- a/OpenSim/OpenSim.Region/World/Avatar.cs +++ b/OpenSim/OpenSim.Region/World/Avatar.cs @@ -66,7 +66,6 @@ namespace OpenSim.Region Wearables = AvatarWearable.DefaultWearables; this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - Console.WriteLine("avatar point 4"); //register for events ControllingClient.OnRequestWearables += new GenericCall(this.SendOurAppearance); @@ -77,14 +76,7 @@ namespace OpenSim.Region ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - * */ - - ControllingClient.OnParcelPropertiesRequest +=new ParcelPropertiesRequest(this.m_world.parcelManager.handleParcelPropertiesRequest); - ControllingClient.OnParcelDivideRequest += new ParcelDivideRequest(this.m_world.parcelManager.handleParcelDivideRequest); - ControllingClient.OnParcelJoinRequest += new ParcelJoinRequest(this.m_world.parcelManager.handleParcelJoinRequest); - ControllingClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(this.m_world.parcelManager.handleParcelPropertiesUpdateRequest); - - ControllingClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(this.m_world.estateManager.handleEstateOwnerMessage); + */ } /// diff --git a/OpenSim/OpenSim.Region/World/Primitive.cs b/OpenSim/OpenSim.Region/World/Primitive.cs index 1f70550..d540a3b 100644 --- a/OpenSim/OpenSim.Region/World/Primitive.cs +++ b/OpenSim/OpenSim.Region/World/Primitive.cs @@ -14,12 +14,12 @@ namespace OpenSim.Region public class Primitive : Entity { protected PrimData primData; - //private ObjectUpdatePacket OurPacket; private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); private Dictionary m_clientThreads; private ulong m_regionHandle; private const uint FULL_MASK_PERMISSIONS = 2147483647; private bool physicsEnabled = false; + private byte updateFlag = 0; private Dictionary inventoryItems; @@ -66,7 +66,7 @@ namespace OpenSim.Region inventoryItems = new Dictionary(); } - public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner) + public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID) { m_clientThreads = clientThreads; m_regionHandle = regionHandle; @@ -75,8 +75,34 @@ namespace OpenSim.Region this.primData = new PrimData(); this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; this.primData.OwnerID = owner; + this.primData.FullID = this.uuid = fullID; + this.primData.LocalID = this.localid = localID; } + /// + /// Constructor to create a default cube + /// + /// + /// + /// + /// + /// + /// + public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position) + { + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + this.primData = PrimData.DefaultCube(); + this.primData.OwnerID = owner; + this.primData.LocalID = this.localid = localID; + this.Pos = this.primData.Position = position; + + this.updateFlag = 1; + } + + public byte[] GetByteArray() { byte[] result = null; @@ -115,7 +141,11 @@ namespace OpenSim.Region public override void update() { - LLVector3 pos2 = new LLVector3(0, 0, 0); + if (this.updateFlag == 1) + { + this.SendFullUpdateToAllClients(); + this.updateFlag = 0; + } } public override void BackUp() @@ -275,17 +305,39 @@ namespace OpenSim.Region public void SendFullUpdateToAllClients() { - + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendFullUpdateToClient(avatars[i].ControllingClient); + } } public void SendTerseUpdateToClient(IClientAPI RemoteClient) { + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.Pos; + lRot = this.rotation; + } + } public void SendTerseUpdateToALLClients() { - + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendTerseUpdateToClient(avatars[i].ControllingClient); + } } #endregion @@ -324,6 +376,8 @@ namespace OpenSim.Region this.primData.FullID = this.uuid = LLUUID.Random(); this.localid = (uint)(localID); this.primData.Position = this.Pos = pos1; + + this.updateFlag = 1; } public void CreateFromBytes(byte[] data) @@ -343,82 +397,5 @@ namespace OpenSim.Region #endregion - - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() - { - uint ID = this.localid; - byte[] bytes = new byte[60]; - - int i = 0; - ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - dat.TextureEntry = new byte[0]; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = 0; - bytes[i++] = 0; - - LLVector3 lPos; - Axiom.MathLib.Quaternion lRot; - if (this._physActor != null && this.physicsEnabled) - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); - lRot = this._physActor.Orientation; - } - else - { - lPos = this.Pos; - lRot = this.rotation; - } - byte[] pb = lPos.GetBytes(); - Array.Copy(pb, 0, bytes, i, pb.Length); - i += 12; - ushort ac = 32767; - - //vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (lRot.w + 1)); - rx = (ushort)(32768 * (lRot.x + 1)); - ry = (ushort)(32768 * (lRot.y + 1)); - rz = (ushort)(32768 * (lRot.z + 1)); - - //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); - - //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - - dat.Data = bytes; - return dat; - } } } diff --git a/OpenSim/OpenSim.Region/World/World.cs b/OpenSim/OpenSim.Region/World/World.cs index c5c554d..49ba8fa 100644 --- a/OpenSim/OpenSim.Region/World/World.cs +++ b/OpenSim/OpenSim.Region/World/World.cs @@ -450,7 +450,19 @@ namespace OpenSim.Region /// public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID) { - + try + { + // MainConsole.Instance.Notice("World.cs: AddNewPrim() - Creating new prim"); + Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); + prim.CreateFromPacket(addPacket, ownerID, this._primCount); + + this.Entities.Add(prim.uuid, prim); + this._primCount++; + } + catch (Exception e) + { + // MainConsole.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); + } } #endregion @@ -469,6 +481,15 @@ namespace OpenSim.Region //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours); + remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim); + + /* + remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); + remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); + remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); + remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); + remoteClient.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage); + */ Avatar newAvatar = null; try -- cgit v1.1