From 778e302133283e3c4ea9c26431b46b3abe23dc1a Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 7 Mar 2007 22:25:13 +0000 Subject: Primitives movement and rotation updates are now sent to all clients --- src/world/Avatar.cs | 2 -- src/world/Primitive.cs | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/world/World.cs | 1 - 3 files changed, 91 insertions(+), 3 deletions(-) (limited to 'src/world') diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs index 1a53acc..cf95f76 100644 --- a/src/world/Avatar.cs +++ b/src/world/Avatar.cs @@ -104,7 +104,6 @@ namespace OpenSim.world public static void SetupTemplate(string name) { - int i = 0; FileInfo fInfo = new FileInfo(name); long numBytes = fInfo.Length; @@ -127,7 +126,6 @@ namespace OpenSim.world Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); Avatar.AvatarTemplate = objdata; - } public void CompleteMovement(World RegionInfo) { diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs index 7b1f69a..1fb7142 100644 --- a/src/world/Primitive.cs +++ b/src/world/Primitive.cs @@ -13,8 +13,21 @@ namespace OpenSim.world protected float mesh_cutend; protected PrimData primData; protected bool newPrimFlag; + protected bool updateFlag; protected ObjectUpdatePacket OurPacket; + public bool UpdateFlag + { + get + { + return updateFlag; + } + set + { + updateFlag = value; + } + } + public Primitive() { mesh_cutbegin = 0.0f; @@ -44,6 +57,18 @@ namespace OpenSim.world } this.newPrimFlag = false; } + else if(this.updateFlag) + { + ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); + terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME + terse.RegionData.TimeDilation = 64096; + terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; + terse.ObjectData[0] = this.CreateImprovedBlock(); + foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { + client.OutPacket(terse); + } + this.updateFlag = false; + } } public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) @@ -109,6 +134,72 @@ namespace OpenSim.world this.position = pos1; this.OurPacket = objupdate; } + + public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() + { + uint ID = this.localid; + byte[] bytes = new byte[60]; + + + int i = 0; + ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); + dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry; + + 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; + + byte[] pb = this.position.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 * (this.rotation.w+1)); + rx = (ushort)(32768 * (this.rotation.x+1)); + ry = (ushort)(32768 * (this.rotation.y+1)); + rz = (ushort)(32768 * (this.rotation.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; + } } public class PrimData diff --git a/src/world/World.cs b/src/world/World.cs index 41a7a34..f6f58c7 100644 --- a/src/world/World.cs +++ b/src/world/World.cs @@ -29,7 +29,6 @@ namespace OpenSim.world ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); TerrainManager = new TerrainManager(new SecondLife()); Avatar.SetupTemplate("avatar-template.dat"); - // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance"); // Initialise this only after the world has loaded // Scripts = new ScriptEngine(this); -- cgit v1.1