aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/world/Entity.cs (renamed from src/world/Entity.cs)2
-rw-r--r--OpenSim.RegionServer/world/ScriptEngine.cs (renamed from src/world/ScriptEngine.cs)0
-rw-r--r--OpenSim.RegionServer/world/SurfacePatch.cs (renamed from src/world/SurfacePatch.cs)0
-rw-r--r--OpenSim.RegionServer/world/World.cs (renamed from src/world/World.cs)47
-rw-r--r--OpenSim.RegionServer/world/scripting/IScript.cs (renamed from src/world/scripting/IScript.cs)0
-rw-r--r--src/world/Avatar.cs487
-rw-r--r--src/world/Primitive.cs429
7 files changed, 27 insertions, 938 deletions
diff --git a/src/world/Entity.cs b/OpenSim.RegionServer/world/Entity.cs
index ee4b2e4..780f3a0 100644
--- a/src/world/Entity.cs
+++ b/OpenSim.RegionServer/world/Entity.cs
@@ -20,7 +20,7 @@ namespace OpenSim.world
20 public Entity() 20 public Entity()
21 { 21 {
22 uuid = new libsecondlife.LLUUID(); 22 uuid = new libsecondlife.LLUUID();
23 localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! 23 localid = 0;
24 position = new LLVector3(); 24 position = new LLVector3();
25 velocity = new LLVector3(); 25 velocity = new LLVector3();
26 rotation = new Quaternion(); 26 rotation = new Quaternion();
diff --git a/src/world/ScriptEngine.cs b/OpenSim.RegionServer/world/ScriptEngine.cs
index f20a08e..f20a08e 100644
--- a/src/world/ScriptEngine.cs
+++ b/OpenSim.RegionServer/world/ScriptEngine.cs
diff --git a/src/world/SurfacePatch.cs b/OpenSim.RegionServer/world/SurfacePatch.cs
index 71e4116..71e4116 100644
--- a/src/world/SurfacePatch.cs
+++ b/OpenSim.RegionServer/world/SurfacePatch.cs
diff --git a/src/world/World.cs b/OpenSim.RegionServer/world/World.cs
index e1c84bc..ba99233 100644
--- a/src/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -5,8 +5,10 @@ using System.Collections.Generic;
5using System.Text; 5using System.Text;
6using System.Reflection; 6using System.Reflection;
7using System.IO; 7using System.IO;
8using PhysicsSystem; 8using OpenSim.Physics.Manager;
9using GridInterfaces; 9using OpenSim.Framework.Interfaces;
10using OpenSim.Framework.Assets;
11using OpenSim.Framework.Terrain;
10 12
11namespace OpenSim.world 13namespace OpenSim.world
12{ 14{
@@ -26,10 +28,10 @@ namespace OpenSim.world
26 28
27 public World() 29 public World()
28 { 30 {
29 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 31 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
30 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 32 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
31 33
32 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); 34 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
33 TerrainManager = new TerrainManager(new SecondLife()); 35 TerrainManager = new TerrainManager(new SecondLife());
34 Avatar.SetupTemplate("avatar-template.dat"); 36 Avatar.SetupTemplate("avatar-template.dat");
35 // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance"); 37 // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
@@ -71,7 +73,7 @@ namespace OpenSim.world
71 73
72 //backup world data 74 //backup world data
73 this.storageCount++; 75 this.storageCount++;
74 if(storageCount> 300) //set to how often you want to backup 76 if(storageCount> 1200) //set to how often you want to backup
75 { 77 {
76 this.Backup(); 78 this.Backup();
77 storageCount =0; 79 storageCount =0;
@@ -112,15 +114,15 @@ namespace OpenSim.world
112 HeightmapGenHills hills = new HeightmapGenHills(); 114 HeightmapGenHills hills = new HeightmapGenHills();
113 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); 115 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
114 this.phyScene.SetTerrain(this.LandMap); 116 this.phyScene.SetTerrain(this.LandMap);
115 OpenSim_Main.cfg.SaveMap(); 117 OpenSimRoot.Instance.Cfg.SaveMap(this.LandMap);
116 118
117 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { 119 foreach(SimClient client in OpenSimRoot.Instance.ClientThreads.Values) {
118 this.SendLayerData(client); 120 this.SendLayerData(client);
119 } 121 }
120 } 122 }
121 public void LoadPrimsFromStorage() 123 public void LoadPrimsFromStorage()
122 { 124 {
123 ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives"); 125 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
124 this.localStorage.LoadPrimitives(this); 126 this.localStorage.LoadPrimitives(this);
125 } 127 }
126 128
@@ -130,7 +132,7 @@ namespace OpenSim.world
130 { 132 {
131 _primCount = prim.LocalID + 1; 133 _primCount = prim.LocalID + 1;
132 } 134 }
133 ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); 135 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage");
134 Primitive nPrim = new Primitive(); 136 Primitive nPrim = new Primitive();
135 nPrim.CreateFromStorage(prim); 137 nPrim.CreateFromStorage(prim);
136 this.Entities.Add(nPrim.uuid, nPrim); 138 this.Entities.Add(nPrim.uuid, nPrim);
@@ -141,7 +143,7 @@ namespace OpenSim.world
141 this.localStorage.ShutDown(); 143 this.localStorage.ShutDown();
142 } 144 }
143 145
144 public void SendLayerData(OpenSimClient RemoteClient) { 146 public void SendLayerData(SimClient RemoteClient) {
145 int[] patches = new int[4]; 147 int[] patches = new int[4];
146 148
147 for (int y = 0; y < 16; y++) 149 for (int y = 0; y < 16; y++)
@@ -159,7 +161,7 @@ namespace OpenSim.world
159 } 161 }
160 } 162 }
161 163
162 public void GetInitialPrims(OpenSimClient RemoteClient) 164 public void GetInitialPrims(SimClient RemoteClient)
163 { 165 {
164 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 166 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
165 { 167 {
@@ -170,33 +172,36 @@ namespace OpenSim.world
170 } 172 }
171 } 173 }
172 174
173 public void AddViewerAgent(OpenSimClient AgentClient) { 175 public void AddViewerAgent(SimClient AgentClient) {
174 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); 176 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
175 Avatar NewAvatar = new Avatar(AgentClient); 177 Avatar NewAvatar = new Avatar(AgentClient);
176 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); 178 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
177 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); 179 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
178 NewAvatar.SendRegionHandshake(this); 180 NewAvatar.SendRegionHandshake(this);
179 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z); 181 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z);
180 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec); 182 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
181 this.Entities.Add(AgentClient.AgentID, NewAvatar); 183 this.Entities.Add(AgentClient.AgentID, NewAvatar);
182 } 184 }
183 185
184 public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient) 186 public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient)
185 { 187 {
186 ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); 188 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
187 Primitive prim = new Primitive(); 189 Primitive prim = new Primitive();
188 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); 190 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
189 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z); 191 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z);
190 PhysicsVector pSize = new PhysicsVector( 0.25f, 0.25f, 0.25f); 192 PhysicsVector pSize = new PhysicsVector( 0.255f, 0.255f, 0.255f);
191 //prim.PhysActor = this.phyScene.AddPrim(pVec, pSize ); 193 if(OpenSim.world.Avatar.PhysicsEngineFlying)
194 {
195 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize );
196 }
192 //prim.PhysicsEnabled = true; 197 //prim.PhysicsEnabled = true;
193 this.Entities.Add(prim.uuid, prim); 198 this.Entities.Add(prim.uuid, prim);
194 this._primCount++; 199 this._primCount++;
195 } 200 }
196 201
197 public bool Backup() { 202 public bool Backup() {
198 /* TODO: Save the current world entities state. */ 203
199 ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives"); 204 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives");
200 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 205 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
201 { 206 {
202 Entities[UUID].BackUp(); 207 Entities[UUID].BackUp();
diff --git a/src/world/scripting/IScript.cs b/OpenSim.RegionServer/world/scripting/IScript.cs
index 550594d..550594d 100644
--- a/src/world/scripting/IScript.cs
+++ b/OpenSim.RegionServer/world/scripting/IScript.cs
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
deleted file mode 100644
index facfeee..0000000
--- a/src/world/Avatar.cs
+++ /dev/null
@@ -1,487 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7using PhysicsSystem;
8using Axiom.MathLib;
9
10namespace OpenSim.world
11{
12 public class Avatar : Entity
13 {
14 public static bool PhysicsEngineFlying;
15 public string firstname;
16 public string lastname;
17 public OpenSimClient ControllingClient;
18 private PhysicsActor _physActor;
19 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
20 private bool updateflag;
21 private byte movementflag;
22 private List<NewForce> forcesList = new List<NewForce>();
23 private short _updateCount;
24 private Axiom.MathLib.Quaternion bodyRot;
25
26 public Avatar(OpenSimClient TheClient) {
27 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
28 ControllingClient=TheClient;
29 position = new LLVector3(100.0f,100.0f,30.0f);
30 position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1;
31 }
32
33 public PhysicsActor PhysActor
34 {
35 set
36 {
37 this._physActor = value;
38 }
39 }
40 public override void addForces()
41 {
42 lock(this.forcesList)
43 {
44 if(this.forcesList.Count>0)
45 {
46 for(int i=0 ; i < this.forcesList.Count; i++)
47 {
48 NewForce force = this.forcesList[i];
49 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
50 this._physActor.Velocity = phyVector;
51 this.updateflag = true;
52 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
53 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
54 }
55 for(int i=0 ; i < this.forcesList.Count; i++)
56 {
57 this.forcesList.RemoveAt(0);
58 }
59 }
60 }
61 }
62
63 public override void update()
64 {
65
66 if(this.updateflag)
67 {
68 //need to send movement info
69 //so create the improvedterseobjectupdate packet
70 //use CreateTerseBlock()
71 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
72 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
73 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
74 terse.RegionData.TimeDilation = 64096;
75 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
76 terse.ObjectData[0] = terseBlock;
77 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
78 client.OutPacket(terse);
79 }
80
81 updateflag =false;
82 //this._updateCount = 0;
83 }
84 else
85 {
86 //if((movementflag & 1) !=0)
87 //{
88 _updateCount++;
89 if(( (!PhysicsEngineFlying) && (_updateCount>3)) || (_updateCount>0))
90 {
91 //It has been a while since last update was sent so lets send one.
92 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
93 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
94 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
95 terse.RegionData.TimeDilation = 64096;
96 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
97 terse.ObjectData[0] = terseBlock;
98 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
99 client.OutPacket(terse);
100 }
101 _updateCount = 0;
102 }
103 //}
104 }
105 }
106
107 public static void SetupTemplate(string name)
108 {
109 int i = 0;
110 FileInfo fInfo = new FileInfo(name);
111 long numBytes = fInfo.Length;
112 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
113 BinaryReader br = new BinaryReader(fStream);
114 byte [] data1 = br.ReadBytes((int)numBytes);
115 br.Close();
116 fStream.Close();
117
118 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
119
120 System.Text.Encoding enc = System.Text.Encoding.ASCII;
121 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
122 pos.X = 100f;
123 objdata.ID = 8880000;
124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
125 libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f);
126 //objdata.FullID=user.AgentID;
127 byte[] pb = pos.GetBytes();
128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
129
130 Avatar.AvatarTemplate = objdata;
131 }
132
133 public void CompleteMovement(World RegionInfo) {
134 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
135 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
136 mov.AgentData.SessionID = this.ControllingClient.SessionID;
137 mov.AgentData.AgentID = this.ControllingClient.AgentID;
138 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
139 // TODO - dynamicalise this stuff
140 mov.Data.Timestamp = 1172750370;
141 mov.Data.Position = new LLVector3(100f, 100f, 23f);
142 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
143
144 ControllingClient.OutPacket(mov);
145 }
146
147 public void SendInitialPosition() {
148
149 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
150 //send a objectupdate packet with information about the clients avatar
151 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
152 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
153 objupdate.RegionData.TimeDilation = 64096;
154 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
155
156 objupdate.ObjectData[0] = AvatarTemplate;
157 //give this avatar object a local id and assign the user a name
158 objupdate.ObjectData[0].ID = this.localid;
159 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
160 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
161
162 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
163
164 byte[] pb = pos2.GetBytes();
165
166 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
167 OpenSim_Main.local_world._localNumber++;
168
169 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
170 {
171 client.OutPacket(objupdate);
172 if(client.AgentID != ControllingClient.AgentID)
173 {
174 SendAppearanceToOtherAgent(client);
175 }
176 }
177 //this.ControllingClient.OutPacket(objupdate);
178 }
179
180 public void SendInitialAppearance() {
181 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
182 aw.AgentData.AgentID = this.ControllingClient.AgentID;
183 aw.AgentData.SerialNum = 0;
184 aw.AgentData.SessionID = ControllingClient.SessionID;
185
186 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
187 AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock();
188 awb.WearableType = (byte)0;
189 awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
190 awb.ItemID = LLUUID.Random();
191 aw.WearableData[0] = awb;
192
193 for(int i=1; i<13; i++)
194 {
195 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
196 awb.WearableType = (byte)i;
197 awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
198 awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
199 aw.WearableData[i] = awb;
200 }
201
202 ControllingClient.OutPacket(aw);
203 }
204
205 public ObjectUpdatePacket CreateUpdatePacket()
206 {
207 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
208 //send a objectupdate packet with information about the clients avatar
209 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
210 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
211 objupdate.RegionData.TimeDilation = 64096;
212 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
213
214 objupdate.ObjectData[0] = AvatarTemplate;
215 //give this avatar object a local id and assign the user a name
216 objupdate.ObjectData[0].ID = this.localid;
217 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
218 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
219
220 libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
221
222 byte[] pb = pos2.GetBytes();
223
224 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
225 return objupdate;
226 }
227
228 public void SendAppearanceToOtherAgent(OpenSimClient userInfo)
229 {
230 AvatarAppearancePacket avp = new AvatarAppearancePacket();
231
232
233 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
234 //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
235
236 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005"));
237 avp.ObjectData.TextureEntry = ntex.ToBytes();
238
239 AvatarAppearancePacket.VisualParamBlock avblock = null;
240 for(int i = 0; i < 218; i++)
241 {
242 avblock = new AvatarAppearancePacket.VisualParamBlock();
243 avblock.ParamValue = (byte)100;
244 avp.VisualParam[i] = avblock;
245 }
246
247 avp.Sender.IsTrial = false;
248 avp.Sender.ID = ControllingClient.AgentID;
249 userInfo.OutPacket(avp);
250
251 }
252
253 public void HandleUpdate(AgentUpdatePacket pack) {
254 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) !=0)
255 {
256 this._physActor.Flying = true;
257 }
258 else
259 {
260 this._physActor.Flying = false;
261 }
262 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) {
263 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
264 if(((movementflag & 1) ==0) || (q!= this.bodyRot))
265 {
266 //we should add a new force to the list
267 // but for now we will deal with velocities
268 NewForce newVelocity = new NewForce();
269 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
270 Axiom.MathLib.Vector3 direc = q * v3;
271 direc.Normalize();
272
273 //work out velocity for sim physics system
274 direc = direc * ((0.03f) * 128f);
275 if(this._physActor.Flying)
276 direc *=2;
277
278 newVelocity.X = direc.x;
279 newVelocity.Y = direc.y;
280 newVelocity.Z = direc.z;
281 this.forcesList.Add(newVelocity);
282 movementflag = 1;
283 this.bodyRot = q;
284 }
285 }
286 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) !=0) &&(PhysicsEngineFlying)) {
287 if(((movementflag & 2) ==0) && this._physActor.Flying)
288 {
289 //we should add a new force to the list
290 // but for now we will deal with velocities
291 NewForce newVelocity = new NewForce();
292 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
293 Axiom.MathLib.Vector3 direc = v3;
294 direc.Normalize();
295
296 //work out velocity for sim physics system
297 direc = direc * ((0.03f) * 128f *2);
298 newVelocity.X = direc.x;
299 newVelocity.Y = direc.y;
300 newVelocity.Z = direc.z;
301 this.forcesList.Add(newVelocity);
302 movementflag = 2;
303 }
304 }
305 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) !=0) && (PhysicsEngineFlying)) {
306 if(((movementflag & 4) ==0) && this._physActor.Flying)
307 {
308 //we should add a new force to the list
309 // but for now we will deal with velocities
310 NewForce newVelocity = new NewForce();
311 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
312 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
313 Axiom.MathLib.Vector3 direc = v3;
314 direc.Normalize();
315
316 //work out velocity for sim physics system
317 direc = direc * ((0.03f) * 128f *2);
318 newVelocity.X = direc.x;
319 newVelocity.Y = direc.y;
320 newVelocity.Z = direc.z;
321 this.forcesList.Add(newVelocity);
322 movementflag = 4;
323 }
324 }
325 else if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) !=0) {
326 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
327 if(((movementflag & 8) ==0) || (q!= this.bodyRot))
328 {
329 //we should add a new force to the list
330 // but for now we will deal with velocities
331 NewForce newVelocity = new NewForce();
332 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
333 Axiom.MathLib.Vector3 direc = q * v3;
334 direc.Normalize();
335
336 //work out velocity for sim physics system
337 direc = direc * ((0.03f) * 128f);
338 if(this._physActor.Flying)
339 direc *=2;
340
341 newVelocity.X = direc.x;
342 newVelocity.Y = direc.y;
343 newVelocity.Z = direc.z;
344 this.forcesList.Add(newVelocity);
345 movementflag = 8;
346 this.bodyRot = q;
347 }
348 }
349 else
350 {
351 if((movementflag) !=0)
352 {
353 NewForce newVelocity = new NewForce();
354 newVelocity.X = 0;
355 newVelocity.Y = 0;
356 newVelocity.Z = 0;
357 this.forcesList.Add(newVelocity);
358 movementflag = 0;
359 }
360 }
361 }
362
363 //should be moved somewhere else
364 public void SendRegionHandshake(World RegionInfo) {
365 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
366 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
367 RegionHandshakePacket handshake = new RegionHandshakePacket();
368
369 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
370 handshake.RegionInfo.BillableFactor = 0;
371 handshake.RegionInfo.IsEstateManager = false;
372 handshake.RegionInfo.TerrainHeightRange00 = 60;
373 handshake.RegionInfo.TerrainHeightRange01 = 60;
374 handshake.RegionInfo.TerrainHeightRange10 = 60;
375 handshake.RegionInfo.TerrainHeightRange11 = 60;
376 handshake.RegionInfo.TerrainStartHeight00 = 10;
377 handshake.RegionInfo.TerrainStartHeight01 = 10;
378 handshake.RegionInfo.TerrainStartHeight10 = 10;
379 handshake.RegionInfo.TerrainStartHeight11 = 10;
380 handshake.RegionInfo.SimAccess = 13;
381 handshake.RegionInfo.WaterHeight = 20;
382 handshake.RegionInfo.RegionFlags = 72458694;
383 handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0");
384 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
385 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
386 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
387 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
388 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
389 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
390 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
391 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
392 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
393 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
394
395 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
396 this.ControllingClient.OutPacket(handshake);
397 }
398
399 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
400 {
401 byte[] bytes = new byte[60];
402 int i=0;
403 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
404
405 dat.TextureEntry = AvatarTemplate.TextureEntry;
406 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
407
408 uint ID = this.localid;
409
410 bytes[i++] = (byte)(ID % 256);
411 bytes[i++] = (byte)((ID >> 8) % 256);
412 bytes[i++] = (byte)((ID >> 16) % 256);
413 bytes[i++] = (byte)((ID >> 24) % 256);
414 bytes[i++] = 0;
415 bytes[i++] = 1;
416 i += 14;
417 bytes[i++] = 128;
418 bytes[i++] = 63;
419
420 byte[] pb = pos2.GetBytes();
421 Array.Copy(pb, 0, bytes, i, pb.Length);
422 i += 12;
423 ushort InternVelocityX;
424 ushort InternVelocityY;
425 ushort InternVelocityZ;
426
427 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
428 internDirec = internDirec /128.0f;
429 internDirec.x += 1;
430 internDirec.y += 1;
431 internDirec.z += 1;
432
433 InternVelocityX = (ushort)(32768 * internDirec.x);
434 InternVelocityY = (ushort)(32768 * internDirec.y);
435 InternVelocityZ = (ushort)(32768 * internDirec.z);
436
437 ushort ac = 32767;
438 bytes[i++] = (byte)(InternVelocityX % 256);
439 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
440 bytes[i++] = (byte)(InternVelocityY % 256);
441 bytes[i++] = (byte)((InternVelocityY>> 8) % 256);
442 bytes[i++] = (byte)(InternVelocityZ % 256);
443 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
444
445 //accel
446 bytes[i++] = (byte)(ac % 256);
447 bytes[i++] = (byte)((ac >> 8) % 256);
448 bytes[i++] = (byte)(ac % 256);
449 bytes[i++] = (byte)((ac >> 8) % 256);
450 bytes[i++] = (byte)(ac % 256);
451 bytes[i++] = (byte)((ac >> 8) % 256);
452
453 //rot
454 bytes[i++] = (byte)(ac % 256);
455 bytes[i++] = (byte)((ac >> 8) % 256);
456 bytes[i++] = (byte)(ac % 256);
457 bytes[i++] = (byte)((ac >> 8) % 256);
458 bytes[i++] = (byte)(ac % 256);
459 bytes[i++] = (byte)((ac >> 8) % 256);
460 bytes[i++] = (byte)(ac % 256);
461 bytes[i++] = (byte)((ac >> 8) % 256);
462
463 //rotation vel
464 bytes[i++] = (byte)(ac % 256);
465 bytes[i++] = (byte)((ac >> 8) % 256);
466 bytes[i++] = (byte)(ac % 256);
467 bytes[i++] = (byte)((ac >> 8) % 256);
468 bytes[i++] = (byte)(ac % 256);
469 bytes[i++] = (byte)((ac >> 8) % 256);
470
471 dat.Data=bytes;
472 return(dat);
473 }
474 }
475
476 public class NewForce
477 {
478 public float X;
479 public float Y;
480 public float Z;
481
482 public NewForce()
483 {
484
485 }
486 }
487}
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs
deleted file mode 100644
index 6be33ef..0000000
--- a/src/world/Primitive.cs
+++ /dev/null
@@ -1,429 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7using GridInterfaces;
8using PhysicsSystem;
9
10namespace OpenSim.world
11{
12 public class Primitive : Entity
13 {
14 protected float mesh_cutbegin;
15 protected float mesh_cutend;
16 protected PrimData primData;
17 protected bool newPrimFlag;
18 protected bool updateFlag;
19 protected bool dirtyFlag;
20 private ObjectUpdatePacket OurPacket;
21 private PhysicsActor _physActor;
22 private bool physicsEnabled;
23
24 public bool PhysicsEnabled
25 {
26 get
27 {
28 return physicsEnabled;
29 }
30 set
31 {
32 physicsEnabled = value;
33 }
34 }
35 public bool UpdateFlag
36 {
37 get
38 {
39 return updateFlag;
40 }
41 set
42 {
43 updateFlag = value;
44 }
45 }
46 public LLVector3 Scale
47 {
48 set
49 {
50 this.primData.Scale = value;
51 this.dirtyFlag = true;
52 }
53 get
54 {
55 return this.primData.Scale;
56 }
57 }
58 public PhysicsActor PhysActor
59 {
60 set
61 {
62 this._physActor = value;
63 }
64 }
65
66 public Primitive()
67 {
68 mesh_cutbegin = 0.0f;
69 mesh_cutend = 1.0f;
70 }
71
72 public override Mesh getMesh()
73 {
74 Mesh mesh = new Mesh();
75 Triangle tri = new Triangle(
76 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
77 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
78 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
79
80 mesh.AddTri(tri);
81 mesh += base.getMesh();
82
83 return mesh;
84 }
85
86 public void UpdatePosition( LLVector3 pos)
87 {
88 this.position = pos;
89 if(this._physActor != null && this.physicsEnabled)
90 {
91 this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
92 }
93 this.updateFlag = true;
94 }
95
96 public override void update()
97 {
98 if(this.newPrimFlag)
99 {
100 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
101 client.OutPacket(OurPacket);
102 }
103 this.newPrimFlag = false;
104 }
105 else if(this.updateFlag)
106 {
107 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
108 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
109 terse.RegionData.TimeDilation = 64096;
110 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
111 terse.ObjectData[0] = this.CreateImprovedBlock();
112 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
113 client.OutPacket(terse);
114 }
115 this.updateFlag = false;
116 }
117 else if(this.dirtyFlag)
118 {
119 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
120 UpdateClient(client);
121 }
122 this.dirtyFlag = false;
123 }
124 else
125 {
126 if(this._physActor != null && this.physicsEnabled)
127 {
128 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
129 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
130 terse.RegionData.TimeDilation = 64096;
131 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
132 terse.ObjectData[0] = this.CreateImprovedBlock();
133 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
134 client.OutPacket(terse);
135 }
136 }
137 }
138 }
139
140 public void UpdateClient(OpenSimClient RemoteClient)
141 {
142
143 LLVector3 lPos;
144 if( this._physActor != null && this.physicsEnabled)
145 {
146 PhysicsVector pPos = this._physActor.Position;
147 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
148 }
149 else
150 {
151 lPos = this.position;
152 }
153 byte[] pb = lPos.GetBytes();
154 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
155
156 // OurPacket should be update with the follwing in updateShape() rather than having to do it here
157 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
158 OurPacket.ObjectData[0].PCode = this.primData.PCode;
159 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
160 OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd;
161 OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX;
162 OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY;
163 OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX;
164 OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY;
165 OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew;
166 OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
167 OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
168 OurPacket.ObjectData[0].Scale = this.primData.Scale;
169 OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve;
170 OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
171 OurPacket.ObjectData[0].ParentID = 0;
172 OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
173 //finish off copying rest of shape data
174 OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
175 OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
176 OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX;
177 OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY;
178 OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist;
179 OurPacket.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
180
181 RemoteClient.OutPacket(OurPacket);
182 }
183
184 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
185 {
186 this.primData.PathBegin = addPacket.PathBegin;
187 this.primData.PathEnd = addPacket.PathEnd;
188 this.primData.PathScaleX = addPacket.PathScaleX;
189 this.primData.PathScaleY = addPacket.PathScaleY;
190 this.primData.PathShearX = addPacket.PathShearX;
191 this.primData.PathShearY = addPacket.PathShearY;
192 this.primData.PathSkew = addPacket.PathSkew;
193 this.primData.ProfileBegin = addPacket.ProfileBegin;
194 this.primData.ProfileEnd = addPacket.ProfileEnd;
195 this.primData.PathCurve = addPacket.PathCurve;
196 this.primData.ProfileCurve = addPacket.ProfileCurve;
197 this.primData.ProfileHollow = addPacket.ProfileHollow;
198 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
199 this.primData.PathRevolutions = addPacket.PathRevolutions;
200 this.primData.PathTaperX = addPacket.PathTaperX;
201 this.primData.PathTaperY = addPacket.PathTaperY;
202 this.primData.PathTwist = addPacket.PathTwist;
203 this.primData.PathTwistBegin =addPacket.PathTwistBegin;
204 this.dirtyFlag = true;
205 }
206
207 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
208 {
209 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
210 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
211 objupdate.RegionData.TimeDilation = 64096;
212
213 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
214 PrimData PData = new PrimData();
215 this.primData = PData;
216 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
217 objupdate.ObjectData[0].PSBlock = new byte[0];
218 objupdate.ObjectData[0].ExtraParams = new byte[1];
219 objupdate.ObjectData[0].MediaURL = new byte[0];
220 objupdate.ObjectData[0].NameValue = new byte[0];
221 objupdate.ObjectData[0].Text = new byte[0];
222 objupdate.ObjectData[0].TextColor = new byte[4];
223 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
224 objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
225 objupdate.ObjectData[0].Material = 3;
226 objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
227 objupdate.ObjectData[0].TextureAnim = new byte[0];
228 objupdate.ObjectData[0].Sound = LLUUID.Zero;
229 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
230 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
231 objupdate.ObjectData[0].State = 0;
232 objupdate.ObjectData[0].Data = new byte[0];
233 PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
234 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
235 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
236 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
237 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
238 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
239 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
240 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
241 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
242 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
243 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
244 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
245 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
246 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
247 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
248 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
249
250 PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
251 PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
252 PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
253 PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
254 PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
255 PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
256
257 //finish off copying rest of shape data
258
259 objupdate.ObjectData[0].ID = (uint)(localID);
260 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000"));
261 objupdate.ObjectData[0].ObjectData = new byte[60];
262 objupdate.ObjectData[0].ObjectData[46] = 128;
263 objupdate.ObjectData[0].ObjectData[47] = 63;
264 LLVector3 pos1= addPacket.ObjectData.RayEnd;
265 //update position
266 byte[] pb = pos1.GetBytes();
267 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
268
269 this.newPrimFlag = true;
270 this.uuid = objupdate.ObjectData[0].FullID;
271 this.localid = objupdate.ObjectData[0].ID;
272 this.position = pos1;
273 this.OurPacket = objupdate;
274 }
275
276 public void CreateFromStorage(PrimData store)
277 {
278 //need to clean this up as it shares a lot of code with CreateFromPacket()
279 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
280 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
281 objupdate.RegionData.TimeDilation = 64096;
282 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
283
284 this.primData = store;
285 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
286 objupdate.ObjectData[0].PSBlock = new byte[0];
287 objupdate.ObjectData[0].ExtraParams = new byte[1];
288 objupdate.ObjectData[0].MediaURL = new byte[0];
289 objupdate.ObjectData[0].NameValue = new byte[0];
290 objupdate.ObjectData[0].Text = new byte[0];
291 objupdate.ObjectData[0].TextColor = new byte[4];
292 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
293 objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
294 objupdate.ObjectData[0].Material = 3;
295 objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
296 objupdate.ObjectData[0].TextureAnim = new byte[0];
297 objupdate.ObjectData[0].Sound = LLUUID.Zero;
298 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
299 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
300 objupdate.ObjectData[0].State = 0;
301 objupdate.ObjectData[0].Data = new byte[0];
302 objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
303 objupdate.ObjectData[0].PCode = this.primData.PCode;
304 objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
305 objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
306 objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
307 objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
308 objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
309 objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
310 objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
311 objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
312 objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
313 objupdate.ObjectData[0].Scale = this.primData.Scale;
314 objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
315 objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
316 objupdate.ObjectData[0].ParentID = 0;
317 objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
318 //finish off copying rest of shape data
319 objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
320 objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
321 objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX;
322 objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY;
323 objupdate.ObjectData[0].PathTwist = this.primData.PathTwist;
324 objupdate.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
325
326 objupdate.ObjectData[0].ID = (uint)store.LocalID;
327 objupdate.ObjectData[0].FullID = store.FullID;
328
329 objupdate.ObjectData[0].ObjectData = new byte[60];
330 objupdate.ObjectData[0].ObjectData[46] = 128;
331 objupdate.ObjectData[0].ObjectData[47] = 63;
332 LLVector3 pos1= store.Position;
333 //update position
334 byte[] pb = pos1.GetBytes();
335 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
336
337 this.uuid = objupdate.ObjectData[0].FullID;
338 this.localid = objupdate.ObjectData[0].ID;
339 this.position = pos1;
340 this.OurPacket = objupdate;
341
342 }
343 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
344 {
345 uint ID = this.localid;
346 byte[] bytes = new byte[60];
347
348 int i = 0;
349 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
350 dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
351
352 bytes[i++] = (byte)(ID % 256);
353 bytes[i++] = (byte)((ID >> 8) % 256);
354 bytes[i++] = (byte)((ID >> 16) % 256);
355 bytes[i++] = (byte)((ID >> 24) % 256);
356 bytes[i++]= 0;
357 bytes[i++]= 0;
358
359 LLVector3 lPos;
360 if( this._physActor != null && this.physicsEnabled)
361 {
362 PhysicsVector pPos = this._physActor.Position;
363 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
364 }
365 else
366 {
367 lPos = this.position;
368 }
369 byte[] pb = lPos.GetBytes();
370 Array.Copy(pb, 0, bytes, i, pb.Length);
371 i += 12;
372 ushort ac = 32767;
373
374 //vel
375 bytes[i++] = (byte)(ac % 256);
376 bytes[i++] = (byte)((ac >> 8) % 256);
377 bytes[i++] = (byte)(ac % 256);
378 bytes[i++] = (byte)((ac >> 8) % 256);
379 bytes[i++] = (byte)(ac % 256);
380 bytes[i++] = (byte)((ac >> 8) % 256);
381
382 //accel
383 bytes[i++] = (byte)(ac % 256);
384 bytes[i++] = (byte)((ac >> 8) % 256);
385 bytes[i++] = (byte)(ac % 256);
386 bytes[i++] = (byte)((ac >> 8) % 256);
387 bytes[i++] = (byte)(ac % 256);
388 bytes[i++] = (byte)((ac >> 8) % 256);
389
390 ushort rw, rx,ry,rz;
391 rw = (ushort)(32768 * (this.rotation.w+1));
392 rx = (ushort)(32768 * (this.rotation.x+1));
393 ry = (ushort)(32768 * (this.rotation.y+1));
394 rz = (ushort)(32768 * (this.rotation.z+1));
395
396 //rot
397 bytes[i++] = (byte)(rx % 256);
398 bytes[i++] = (byte)((rx >> 8) % 256);
399 bytes[i++] = (byte)(ry % 256);
400 bytes[i++] = (byte)((ry >> 8) % 256);
401 bytes[i++] = (byte)(rz % 256);
402 bytes[i++] = (byte)((rz >> 8) % 256);
403 bytes[i++] = (byte)(rw % 256);
404 bytes[i++] = (byte)((rw >> 8) % 256);
405
406 //rotation vel
407 bytes[i++] = (byte)(ac % 256);
408 bytes[i++] = (byte)((ac >> 8) % 256);
409 bytes[i++] = (byte)(ac % 256);
410 bytes[i++] = (byte)((ac >> 8) % 256);
411 bytes[i++] = (byte)(ac % 256);
412 bytes[i++] = (byte)((ac >> 8) % 256);
413
414 dat.Data=bytes;
415 return dat;
416 }
417
418 public override void BackUp()
419 {
420
421 this.primData.FullID = this.uuid;
422 this.primData.LocalID = this.localid;
423 this.primData.Position = this.position;
424 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w);
425 OpenSim_Main.local_world.localStorage.StorePrim(this.primData);
426 }
427 }
428
429}