aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world
diff options
context:
space:
mode:
authorgareth2007-02-27 23:00:49 +0000
committergareth2007-02-27 23:00:49 +0000
commit09dd4bd6834861791008e66652826a66724efa0e (patch)
treeae2b10c3b6ce3fab4c516c6710d4fa0adafedb77 /src/world
parentRemoved old trunk code (diff)
downloadopensim-SC-09dd4bd6834861791008e66652826a66724efa0e.zip
opensim-SC-09dd4bd6834861791008e66652826a66724efa0e.tar.gz
opensim-SC-09dd4bd6834861791008e66652826a66724efa0e.tar.bz2
opensim-SC-09dd4bd6834861791008e66652826a66724efa0e.tar.xz
Brought in code from branches/gareth
Diffstat (limited to '')
-rw-r--r--src/world/Avatar.cs70
-rw-r--r--src/world/Entity.cs53
-rw-r--r--src/world/Primitive.cs33
-rw-r--r--src/world/ScriptEngine.cs18
-rw-r--r--src/world/SurfacePatch.cs22
-rw-r--r--src/world/World.cs57
-rw-r--r--src/world/scripting/IScript.cs16
7 files changed, 269 insertions, 0 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
new file mode 100644
index 0000000..863ce29
--- /dev/null
+++ b/src/world/Avatar.cs
@@ -0,0 +1,70 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace OpenSim.world
8{
9 public class Avatar : Entity
10 {
11 public string firstname;
12 public string lastname;
13 public OpenSimClient ControllingClient;
14
15 public Avatar(OpenSimClient TheClient) {
16 Console.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
17 ControllingClient=TheClient;
18 }
19
20 public void CompleteMovement(World RegionInfo) {
21 Console.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
22 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
23 mov.AgentData.SessionID = this.ControllingClient.SessionID;
24 mov.AgentData.AgentID = this.ControllingClient.AgentID;
25 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
26 // TODO - dynamicalise this stuff
27 mov.Data.Timestamp = 1169838966;
28 mov.Data.Position = new LLVector3(100f, 100f, 22f);
29 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
30
31 Console.WriteLine("Sending AgentMovementComplete packet");
32 ControllingClient.OutPacket(mov);
33 }
34
35 public void SendRegionHandshake(World RegionInfo) {
36 Console.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
37 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
38 RegionHandshakePacket handshake = new RegionHandshakePacket();
39
40 Console.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
41 handshake.RegionInfo.BillableFactor = 0;
42 handshake.RegionInfo.IsEstateManager = false;
43 handshake.RegionInfo.TerrainHeightRange00 = 60;
44 handshake.RegionInfo.TerrainHeightRange01 = 60;
45 handshake.RegionInfo.TerrainHeightRange10 = 60;
46 handshake.RegionInfo.TerrainHeightRange11 = 60;
47 handshake.RegionInfo.TerrainStartHeight00 = 20;
48 handshake.RegionInfo.TerrainStartHeight01 = 20;
49 handshake.RegionInfo.TerrainStartHeight10 = 20;
50 handshake.RegionInfo.TerrainStartHeight11 = 20;
51 handshake.RegionInfo.SimAccess = 13;
52 handshake.RegionInfo.WaterHeight = 5;
53 handshake.RegionInfo.RegionFlags = 72458694;
54 handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0");
55 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
56 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
57 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
58 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
59 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
60 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
61 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
62 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
63 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
64 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
65
66 Console.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
67 this.ControllingClient.OutPacket(handshake);
68 }
69 }
70}
diff --git a/src/world/Entity.cs b/src/world/Entity.cs
new file mode 100644
index 0000000..ab07fd6
--- /dev/null
+++ b/src/world/Entity.cs
@@ -0,0 +1,53 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Axiom.MathLib;
5using OpenSim.types;
6
7namespace OpenSim.world
8{
9 public class Entity
10 {
11 protected libsecondlife.LLUUID uuid;
12 protected Vector3 position;
13 protected Vector3 velocity;
14 protected Quaternion rotation;
15 protected string name;
16 protected List<Entity> children;
17
18 public Entity()
19 {
20 uuid = new libsecondlife.LLUUID();
21 position = new Vector3();
22 velocity = new Vector3();
23 rotation = new Quaternion();
24 name = "(basic entity)";
25 children = new List<Entity>();
26 }
27
28 public virtual void update() {
29 // Do any per-frame updates needed that are applicable to every type of entity
30 foreach (Entity child in children)
31 {
32 child.update();
33 }
34 }
35
36 public virtual string getName()
37 {
38 return name;
39 }
40
41 public virtual Mesh getMesh()
42 {
43 Mesh mesh = new Mesh();
44
45 foreach (Entity child in children)
46 {
47 mesh += child.getMesh();
48 }
49
50 return mesh;
51 }
52 }
53}
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs
new file mode 100644
index 0000000..143fa55
--- /dev/null
+++ b/src/world/Primitive.cs
@@ -0,0 +1,33 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5
6namespace OpenSim.world
7{
8 public class Primitive : Entity
9 {
10 protected float mesh_cutbegin;
11 protected float mesh_cutend;
12
13 public Primitive()
14 {
15 mesh_cutbegin = 0.0f;
16 mesh_cutend = 1.0f;
17 }
18
19 public override Mesh getMesh()
20 {
21 Mesh mesh = new Mesh();
22 Triangle tri = new Triangle(
23 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
24 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
25 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
26
27 mesh.AddTri(tri);
28 mesh += base.getMesh();
29
30 return mesh;
31 }
32 }
33}
diff --git a/src/world/ScriptEngine.cs b/src/world/ScriptEngine.cs
new file mode 100644
index 0000000..f20a08e
--- /dev/null
+++ b/src/world/ScriptEngine.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world
6{
7 public class ScriptEngine
8 {
9 public ScriptEngine(World env)
10 {
11 }
12
13 public void LoadScript()
14 {
15
16 }
17 }
18}
diff --git a/src/world/SurfacePatch.cs b/src/world/SurfacePatch.cs
new file mode 100644
index 0000000..71e4116
--- /dev/null
+++ b/src/world/SurfacePatch.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world
6{
7 public class SurfacePatch
8 {
9 public float[] HeightMap;
10
11 public SurfacePatch() {
12 HeightMap = new float[16*16];
13
14 int xinc;
15 int yinc;
16 for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) {
17 HeightMap[xinc+(yinc*16)]=100.0f;
18 }
19
20 }
21 }
22}
diff --git a/src/world/World.cs b/src/world/World.cs
new file mode 100644
index 0000000..cf337a8
--- /dev/null
+++ b/src/world/World.cs
@@ -0,0 +1,57 @@
1using System;
2using libsecondlife;
3using System.Collections.Generic;
4using System.Text;
5
6namespace OpenSim.world
7{
8 public class World
9 {
10 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
11 public SurfacePatch[] LandMap;
12 public ScriptEngine Scripts;
13
14 public World()
15 {
16 Console.WriteLine("World.cs - creating new entitities instance");
17 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
18
19 // We need a 16x16 array of 16m2 surface patches for a 256m2 sim
20 Console.WriteLine("World.cs - creating LandMap");
21 LandMap = new SurfacePatch[16*16];
22 int xinc;
23 int yinc;
24 for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) {
25 LandMap[xinc+(yinc*16)]=new SurfacePatch();
26 }
27
28 Console.WriteLine("World.cs - Creating script engine instance");
29 // Initialise this only after the world has loaded
30 Scripts = new ScriptEngine(this);
31 }
32
33 public void Update()
34 {
35 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
36 {
37 Entities[UUID].update();
38 }
39 }
40
41 public void AddViewerAgent(OpenSimClient AgentClient) {
42 Console.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
43 Avatar NewAvatar = new Avatar(AgentClient);
44 Console.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
45 this.Entities.Add(AgentClient.AgentID, NewAvatar);
46 Console.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
47 NewAvatar.SendRegionHandshake(this);
48 this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user
49 }
50
51 public bool Backup() {
52 /* TODO: Save the current world entities state. */
53
54 return false;
55 }
56 }
57}
diff --git a/src/world/scripting/IScript.cs b/src/world/scripting/IScript.cs
new file mode 100644
index 0000000..550594d
--- /dev/null
+++ b/src/world/scripting/IScript.cs
@@ -0,0 +1,16 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world.scripting
6{
7 public interface IScriptHost {
8 bool Register(IScript iscript);
9 }
10 public interface IScript
11 {
12 string Name{get;set;}
13 IScriptHost Host{get;set;}
14 void Show();
15 }
16}