From bd8018fa1cb32aa42e2a1a41ebb01fc0f1b0a04b Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 3 Jul 2007 20:10:20 +0000 Subject: Today's work on Building support/tools. Think I am slowly getting there. --- OpenSim/Region/Environment/Scenes/EntityBase.cs | 2 +- OpenSim/Region/Environment/Scenes/Primitive.cs | 130 ++++++++++++++++++--- .../Environment/Scenes/Scene.PacketHandlers.cs | 82 +++++++++++-- OpenSim/Region/Environment/Scenes/Scene.cs | 17 ++- OpenSim/Region/Environment/Scenes/SceneObject.cs | 24 +++- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 1 + 6 files changed, 229 insertions(+), 27 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index a8eb9ce..2874ae2 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes } } - public Quaternion _rotation; + public Quaternion _rotation = new Quaternion(0,0,1,0); public virtual Quaternion rotation { diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index a767bd2..803bd28 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes private PrimitiveBaseShape m_Shape; public SceneObject m_RootParent; - public bool isRootPrim; + public bool isRootPrim; public EntityBase m_Parent; public override LLVector3 Pos @@ -60,7 +60,11 @@ namespace OpenSim.Region.Environment.Scenes } set { - this.m_pos = m_Parent.Pos - value; //should we being subtracting the parent position + if (isRootPrim) + { + m_Parent.Pos = value; + } + this.m_pos = value - m_Parent.Pos; } } @@ -77,7 +81,19 @@ namespace OpenSim.Region.Environment.Scenes } } - public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent , SceneObject rootObject) + public LLVector3 Scale + { + set + { + this.m_Shape.Scale = value; + } + get + { + return this.m_Shape.Scale; + } + } + + public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject) { m_regionHandle = regionHandle; m_world = world; @@ -86,12 +102,13 @@ namespace OpenSim.Region.Environment.Scenes this.isRootPrim = isRoot; this.m_RootParent = rootObject; this.CreateFromPacket(addPacket, ownerID, localID); + this.rotation = Axiom.MathLib.Quaternion.Identity; } /// /// /// - public override void update() + public override void update() { if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes { @@ -104,7 +121,10 @@ namespace OpenSim.Region.Environment.Scenes this.updateFlag = 0; } - base.update(); + foreach (EntityBase child in children) + { + child.update(); + } } /// @@ -150,9 +170,13 @@ namespace OpenSim.Region.Environment.Scenes this.updateFlag = 1; } + /// + /// + /// + /// public void AddNewChildren(SceneObject linkObject) { - // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); + // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); //TODO check permissions this.children.Add(linkObject.rootPrimitive); linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); @@ -161,30 +185,73 @@ namespace OpenSim.Region.Environment.Scenes linkObject.DeleteAllChildren(); } + /// + /// + /// + /// + /// public void SetNewParent(Primitive newParent, SceneObject rootParent) { LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); - //Console.WriteLine("have a new parent and my old position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); this.isRootPrim = false; this.m_Parent = newParent; this.ParentID = newParent.LocalId; this.SetRootParent(rootParent); - // Console.WriteLine("have a new parent and its position is " + this.m_Parent.Pos.X + " , " + this.m_Parent.Pos.Y + " , " + this.m_Parent.Pos.Z); this.Pos = oldPos; - // Console.WriteLine("have a new parent so my new offset position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); + Axiom.MathLib.Vector3 axPos = new Axiom.MathLib.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); + axPos = this.m_Parent.rotation.Inverse() * axPos; + this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); + this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); this.updateFlag = 1; } + /// + /// + /// + /// public void SetRootParent(SceneObject newRoot) { this.m_RootParent = newRoot; + this.m_RootParent.AddChildToList(this); foreach (Primitive child in children) { child.SetRootParent(newRoot); } } + public void AddOffsetToChildren(LLVector3 offset) + { + foreach (Primitive prim in this.children) + { + prim.m_pos += offset; + prim.updateFlag = 2; + } + } + + #region Resizing/Scale + public void ResizeGoup(LLVector3 scale) + { + LLVector3 offset = (scale - this.m_Shape.Scale); + offset.X /= 2; + offset.Y /= 2; + offset.Z /= 2; + if (this.isRootPrim) + { + this.m_Parent.Pos += offset; + } + else + { + this.m_pos += offset; + } + + this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); + this.m_Shape.Scale = scale; + + this.updateFlag = 1; + } + #endregion + /// /// /// @@ -192,14 +259,47 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePosition(LLVector3 pos) { LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - if (this.isRootPrim) - { - this.m_Parent.Pos = newPos; - } + this.Pos = newPos; this.updateFlag = 2; } + public void UpdateRotation(LLQuaternion rot) + { + this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); + this.updateFlag = 2; + } + + public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) + { + this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); + this.Pos = pos; + this.updateFlag = 2; + } + + public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) + { + this.m_Shape.PathBegin = shapeBlock.PathBegin; + this.m_Shape.PathEnd = shapeBlock.PathEnd; + this.m_Shape.PathScaleX = shapeBlock.PathScaleX; + this.m_Shape.PathScaleY = shapeBlock.PathScaleY; + this.m_Shape.PathShearX = shapeBlock.PathShearX; + this.m_Shape.PathShearY = shapeBlock.PathShearY; + this.m_Shape.PathSkew = shapeBlock.PathSkew; + this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; + this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; + this.m_Shape.PathCurve = shapeBlock.PathCurve; + this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; + this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; + this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; + this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; + this.m_Shape.PathTaperX = shapeBlock.PathTaperX; + this.m_Shape.PathTaperY = shapeBlock.PathTaperY; + this.m_Shape.PathTwist = shapeBlock.PathTwist; + this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; + this.updateFlag = 1; + } + #region Client Update Methods /// @@ -226,8 +326,10 @@ namespace OpenSim.Region.Environment.Scenes { LLVector3 lPos; lPos = this.Pos; + LLQuaternion lRot; + lRot = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); - remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID, this.Text, this.ParentID); + remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID, this.Text, this.ParentID); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 669039f..0927903 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -233,7 +233,19 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) { - + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(primLocalID); + if (prim != null) + { + prim.UpdateShape(shapeBlock); + break; + } + } + } } /// @@ -263,7 +275,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void PrimDescription(uint primLocalID, string description) { - Primitive prim = null; + Primitive prim = null; foreach (EntityBase ent in Entities.Values) { if (ent is SceneObject) @@ -271,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes prim = ((SceneObject)ent).HasChildPrim(primLocalID); if (prim != null) { - prim.Description = description; + prim.Description = description; break; } } @@ -341,12 +353,41 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) { - foreach (Entity ent in Entities.Values) + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) { - if (ent.LocalId == localID) + if (ent is SceneObject) { - ((PrimitiveOld)ent).UpdatePosition(pos); - break; + prim = ((SceneObject)ent).HasChildPrim(localID); + if (prim != null) + { + prim.UpdatePosition(pos); + break; + } + } + } + } + + /// + /// + /// + /// + /// + /// + /// + public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) + { + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(localID); + if (prim != null) + { + prim.UpdateGroupMouseRotation( pos, rot); + break; + } } } } @@ -359,7 +400,19 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) { - + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(localID); + if (prim != null) + { + prim.UpdateRotation(rot); + break; + } + } + } } /// @@ -370,6 +423,19 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) { + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(localID); + if (prim != null) + { + prim.ResizeGoup(scale); + break; + } + } + } } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d13b3ab..838d722 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -452,7 +452,11 @@ namespace OpenSim.Region.Environment.Scenes client.OnChatFromViewer += this.SimChat; client.OnRequestWearables += this.InformClientOfNeighbours; client.OnAddPrim += this.AddNewPrim; - //client.OnUpdatePrimPosition += this.UpdatePrimPosition; + client.OnUpdatePrimPosition += this.UpdatePrimPosition; + client.OnUpdatePrimRotation += this.UpdatePrimRotation; + client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation; + client.OnUpdatePrimScale += this.UpdatePrimScale; + client.OnUpdatePrimShape += this.UpdatePrimShape; client.OnRequestMapBlocks += this.RequestMapBlocks; client.OnTeleportLocationRequest += this.RequestTeleportLocation; client.OnObjectSelect += this.SelectPrim; @@ -596,6 +600,17 @@ namespace OpenSim.Region.Environment.Scenes return false; } + public void SendAllSceneObjectsToClient(IClientAPI client) + { + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + ((SceneObject)ent).SendAllChildPrimsToClient(client); + } + } + } + #region RegionCommsHost /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 04ed408..3d97a06 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -63,6 +63,7 @@ namespace OpenSim.Region.Environment.Scenes return this.LocalId; } } + /// /// /// @@ -72,8 +73,8 @@ namespace OpenSim.Region.Environment.Scenes m_world = world; this.Pos = addPacket.ObjectData.RayEnd; this.CreateRootFromPacket(addPacket, ownerID, localID); - } + /// /// /// @@ -115,6 +116,13 @@ namespace OpenSim.Region.Environment.Scenes this.rootPrimitive.AddNewChildren(primObject); } + public void AddChildToList(Primitive prim) + { + if (!this.ChildPrimitives.ContainsKey(prim.uuid)) + { + this.ChildPrimitives.Add(prim.uuid, prim); + } + } /// /// /// @@ -130,10 +138,15 @@ namespace OpenSim.Region.Environment.Scenes return null; } + /// + /// + /// + /// + /// public Primitive HasChildPrim(uint localID) { Primitive returnPrim = null; - foreach (Primitive prim in this.children) + foreach (Primitive prim in this.ChildPrimitives.Values) { if (prim.LocalId == localID) { @@ -144,6 +157,11 @@ namespace OpenSim.Region.Environment.Scenes return returnPrim; } + public void SendAllChildPrimsToClient(IClientAPI client) + { + this.rootPrimitive.SendFullUpdateForAllChildren(client); + } + /// /// /// @@ -160,7 +178,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - this.Pos = pos; + //this.Pos = pos; this.rootPrimitive.Pos = pos; this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index dcca848..98fa2ed 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -384,6 +384,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendOurAppearance(IClientAPI OurClient) { this.ControllingClient.SendWearables(this.Wearables); + this.m_world.SendAllSceneObjectsToClient(this.ControllingClient); } /// -- cgit v1.1