aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/Primitive.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world/Primitive.cs')
-rw-r--r--src/world/Primitive.cs91
1 files changed, 91 insertions, 0 deletions
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
13 protected float mesh_cutend; 13 protected float mesh_cutend;
14 protected PrimData primData; 14 protected PrimData primData;
15 protected bool newPrimFlag; 15 protected bool newPrimFlag;
16 protected bool updateFlag;
16 protected ObjectUpdatePacket OurPacket; 17 protected ObjectUpdatePacket OurPacket;
17 18
19 public bool UpdateFlag
20 {
21 get
22 {
23 return updateFlag;
24 }
25 set
26 {
27 updateFlag = value;
28 }
29 }
30
18 public Primitive() 31 public Primitive()
19 { 32 {
20 mesh_cutbegin = 0.0f; 33 mesh_cutbegin = 0.0f;
@@ -44,6 +57,18 @@ namespace OpenSim.world
44 } 57 }
45 this.newPrimFlag = false; 58 this.newPrimFlag = false;
46 } 59 }
60 else if(this.updateFlag)
61 {
62 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
63 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
64 terse.RegionData.TimeDilation = 64096;
65 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
66 terse.ObjectData[0] = this.CreateImprovedBlock();
67 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
68 client.OutPacket(terse);
69 }
70 this.updateFlag = false;
71 }
47 } 72 }
48 73
49 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) 74 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
@@ -109,6 +134,72 @@ namespace OpenSim.world
109 this.position = pos1; 134 this.position = pos1;
110 this.OurPacket = objupdate; 135 this.OurPacket = objupdate;
111 } 136 }
137
138 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
139 {
140 uint ID = this.localid;
141 byte[] bytes = new byte[60];
142
143
144 int i = 0;
145 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
146 dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
147
148 bytes[i++] = (byte)(ID % 256);
149 bytes[i++] = (byte)((ID >> 8) % 256);
150 bytes[i++] = (byte)((ID >> 16) % 256);
151 bytes[i++] = (byte)((ID >> 24) % 256);
152 bytes[i++]= 0;
153 bytes[i++]= 0;
154
155 byte[] pb = this.position.GetBytes();
156 Array.Copy(pb, 0, bytes, i, pb.Length);
157 i += 12;
158 ushort ac = 32767;
159
160 //vel
161 bytes[i++] = (byte)(ac % 256);
162 bytes[i++] = (byte)((ac >> 8) % 256);
163 bytes[i++] = (byte)(ac % 256);
164 bytes[i++] = (byte)((ac >> 8) % 256);
165 bytes[i++] = (byte)(ac % 256);
166 bytes[i++] = (byte)((ac >> 8) % 256);
167
168 //accel
169 bytes[i++] = (byte)(ac % 256);
170 bytes[i++] = (byte)((ac >> 8) % 256);
171 bytes[i++] = (byte)(ac % 256);
172 bytes[i++] = (byte)((ac >> 8) % 256);
173 bytes[i++] = (byte)(ac % 256);
174 bytes[i++] = (byte)((ac >> 8) % 256);
175
176 ushort rw, rx,ry,rz;
177 rw = (ushort)(32768 * (this.rotation.w+1));
178 rx = (ushort)(32768 * (this.rotation.x+1));
179 ry = (ushort)(32768 * (this.rotation.y+1));
180 rz = (ushort)(32768 * (this.rotation.z+1));
181
182 //rot
183 bytes[i++] = (byte)(rx % 256);
184 bytes[i++] = (byte)((rx >> 8) % 256);
185 bytes[i++] = (byte)(ry % 256);
186 bytes[i++] = (byte)((ry >> 8) % 256);
187 bytes[i++] = (byte)(rz % 256);
188 bytes[i++] = (byte)((rz >> 8) % 256);
189 bytes[i++] = (byte)(rw % 256);
190 bytes[i++] = (byte)((rw >> 8) % 256);
191
192 //rotation vel
193 bytes[i++] = (byte)(ac % 256);
194 bytes[i++] = (byte)((ac >> 8) % 256);
195 bytes[i++] = (byte)(ac % 256);
196 bytes[i++] = (byte)((ac >> 8) % 256);
197 bytes[i++] = (byte)(ac % 256);
198 bytes[i++] = (byte)((ac >> 8) % 256);
199
200 dat.Data=bytes;
201 return dat;
202 }
112 } 203 }
113 204
114 public class PrimData 205 public class PrimData