aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples
diff options
context:
space:
mode:
authorlbsa712007-07-14 15:33:25 +0000
committerlbsa712007-07-14 15:33:25 +0000
commit811d2b69c9c5d07dbb196cd2ee6353916d0b51c5 (patch)
treead6cb65aee221bdab5a0cd7deddb49950ba98241 /OpenSim/Region/Examples
parent*Added support for prim counting on parcels (diff)
downloadopensim-SC_OLD-811d2b69c9c5d07dbb196cd2ee6353916d0b51c5.zip
opensim-SC_OLD-811d2b69c9c5d07dbb196cd2ee6353916d0b51c5.tar.gz
opensim-SC_OLD-811d2b69c9c5d07dbb196cd2ee6353916d0b51c5.tar.bz2
opensim-SC_OLD-811d2b69c9c5d07dbb196cd2ee6353916d0b51c5.tar.xz
* Worked some more on SimpleApp
* Removed SceneObject references to RegionHandle, ParcelManager, EventManager as they are public on Scene * Moved PulseScript behaviour into MySceneObject
Diffstat (limited to 'OpenSim/Region/Examples')
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MySceneObject.cs40
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs61
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs50
-rw-r--r--OpenSim/Region/Examples/SimpleApp/PulseScript.cs52
4 files changed, 77 insertions, 126 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs b/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
new file mode 100644
index 0000000..8508dac
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
@@ -0,0 +1,40 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Region.Environment.Scenes;
5using libsecondlife;
6using OpenSim.Framework.Types;
7using System.Timers;
8
9namespace SimpleApp
10{
11 public class MySceneObject : SceneObject
12 {
13 LLVector3 delta = new LLVector3(0.1f, 0.1f, 0.1f);
14
15 public MySceneObject(Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
16 : base(world, ownerID, localID, pos, shape )
17 {
18 Timer timer = new Timer();
19 timer.Enabled = true;
20 timer.Interval = 100;
21 timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
22 }
23
24 public void Heartbeat(object sender, EventArgs e)
25 {
26 if (rootPrimitive.Scale.X > 1)
27 {
28 delta = new LLVector3(-0.1f, -0.1f, -0.1f);
29 }
30
31 if (rootPrimitive.Scale.X < 0.2f)
32 {
33 delta = new LLVector3(0.1f, 0.1f, 0.1f);
34 }
35
36 rootPrimitive.ResizeGoup(rootPrimitive.Scale + delta);
37 update();
38 }
39 }
40}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index d7a0ab2..d0e3fed 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -8,7 +8,7 @@ using OpenSim.Framework.Types;
8using OpenSim.Region.Caches; 8using OpenSim.Region.Caches;
9using OpenSim.Region.Environment.Scenes; 9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Terrain; 10using OpenSim.Region.Terrain;
11using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; 11using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
12 12
13namespace SimpleApp 13namespace SimpleApp
14{ 14{
@@ -22,22 +22,6 @@ namespace SimpleApp
22 m_avatars = new List<Avatar>(); 22 m_avatars = new List<Avatar>();
23 } 23 }
24 24
25 /*
26 public override void SendLayerData(IClientAPI remoteClient)
27 {
28 float[] map = new float[65536];
29
30 for (int i = 0; i < 65536; i++)
31 {
32 int x = i % 256;
33 int y = i / 256;
34
35 map[i] = 0f;
36 }
37
38 remoteClient.SendLayerData(map);
39 }*/
40
41 public override void LoadWorldMap() 25 public override void LoadWorldMap()
42 { 26 {
43 float[] map = new float[65536]; 27 float[] map = new float[65536];
@@ -59,55 +43,34 @@ namespace SimpleApp
59 override public void AddNewClient(IClientAPI client, bool child) 43 override public void AddNewClient(IClientAPI client, bool child)
60 { 44 {
61 LLVector3 pos = new LLVector3(128, 128, 128); 45 LLVector3 pos = new LLVector3(128, 128, 128);
62 46
63 client.OnRegionHandShakeReply += SendLayerData; 47 client.OnRegionHandShakeReply += SendLayerData;
64 client.OnChatFromViewer += 48 client.OnChatFromViewer +=
65 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 49 delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
66 { 50 {
67 // Echo it (so you know what you typed) 51 // Echo it (so you know what you typed)
68 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); 52 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
69 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero); 53 client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
70 }; 54 };
71 55
72 client.OnAddPrim += AddNewPrim; 56 client.OnAddPrim += AddNewPrim;
73 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; 57 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
74 client.OnRequestMapBlocks += this.RequestMapBlocks; 58 client.OnRequestMapBlocks += this.RequestMapBlocks;
75 client.OnTeleportLocationRequest += this.RequestTeleportLocation; 59 client.OnTeleportLocationRequest += this.RequestTeleportLocation;
76 client.OnGrapUpdate += this.MoveObject; 60 client.OnGrapUpdate += this.MoveObject;
77 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; 61 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
78 62
79 client.OnCompleteMovementToRegion += delegate() 63 client.OnCompleteMovementToRegion += delegate()
80 { 64 {
81 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero); 65 client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
82 }; 66 };
83 67
84 client.SendRegionHandshake(m_regInfo); 68 client.SendRegionHandshake(m_regInfo);
85 69
86 ScenePresence avatar = CreateAndAddScenePresence(client); 70 ScenePresence avatar = CreateAndAddScenePresence(client);
87 avatar.Pos = new LLVector3(128, 128, 26); 71 avatar.Pos = new LLVector3(128, 128, 26);
88 }
89
90 public void CustomStartup()
91 {
92 this.StartTimer();
93
94 ScriptManager.AddPreCompiledScript(new PulseScript());
95
96 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
97 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
98 LLVector3 pos1 = new LLVector3(129, 129, 27);
99 AddNewPrim(LLUUID.Random(), pos1, shape);
100 } 72 }
101 73
102 public override void Update()
103 {
104 foreach (LLUUID UUID in Entities.Keys)
105 {
106 Entities[UUID].update();
107 }
108 EventManager.TriggerOnFrame();
109 }
110
111 #endregion 74 #endregion
112 } 75 }
113} 76}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index f30f444..42a7add 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -13,7 +13,8 @@ using OpenSim.Region.Capabilities;
13using OpenSim.Region.ClientStack; 13using OpenSim.Region.ClientStack;
14using OpenSim.Region.Communications.Local; 14using OpenSim.Region.Communications.Local;
15using OpenSim.Region.GridInterfaces.Local; 15using OpenSim.Region.GridInterfaces.Local;
16using OpenSim.Framework.Data; 16using System.Timers;
17using OpenSim.Region.Environment.Scenes;
17 18
18namespace SimpleApp 19namespace SimpleApp
19{ 20{
@@ -23,16 +24,17 @@ namespace SimpleApp
23 AuthenticateSessionsBase m_circuitManager; 24 AuthenticateSessionsBase m_circuitManager;
24 uint m_localId; 25 uint m_localId;
25 public MyWorld world; 26 public MyWorld world;
27 private SceneObject m_sceneObject;
26 28
27 private void Run() 29 private void Run()
28 { 30 {
29 m_log = new LogBase(null, "SimpleApp", this, false); 31 m_log = new LogBase(null, "SimpleApp", this, false);
30 MainLog.Instance = m_log; 32 MainLog.Instance = m_log;
31 33
32 // CheckSumServer checksumServer = new CheckSumServer(12036); 34 // CheckSumServer checksumServer = new CheckSumServer(12036);
33 // checksumServer.ServerListener(); 35 // checksumServer.ServerListener();
34 36
35 IPEndPoint internalEndPoint = new IPEndPoint( IPAddress.Parse( "127.0.0.1" ), 9000 ); 37 IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
36 38
37 m_circuitManager = new AuthenticateSessionsBase(); 39 m_circuitManager = new AuthenticateSessionsBase();
38 40
@@ -46,42 +48,40 @@ namespace SimpleApp
46 48
47 PhysicsManager physManager = new PhysicsManager(); 49 PhysicsManager physManager = new PhysicsManager();
48 physManager.LoadPlugins(); 50 physManager.LoadPlugins();
49 51
50 UDPServer udpServer = new UDPServer( internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager ); 52 UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
51 PacketServer packetServer = new PacketServer(udpServer); 53 PacketServer packetServer = new PacketServer(udpServer);
52 54
53
54 ClientView.TerrainManager = new TerrainManager(new SecondLife()); 55 ClientView.TerrainManager = new TerrainManager(new SecondLife());
55 BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port); 56 BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
56 57
57 NetworkServersInfo serverInfo = new NetworkServersInfo(); 58 NetworkServersInfo serverInfo = new NetworkServersInfo();
58 CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer); 59 CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
59 60
60 RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "127.0.0.1" ); 61 RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1");
61 62
62 world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer); 63 world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer);
63 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; 64 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
64 65
65 world.LoadWorldMap(); 66 world.LoadWorldMap();
66 67 world.ParcelManager.NoParcelDataFromStorage();
68
67 udpServer.LocalWorld = world; 69 udpServer.LocalWorld = world;
68 70
69 httpServer.Start(); 71 httpServer.Start();
70 udpServer.ServerListener(); 72 udpServer.ServerListener();
71 73
72 UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test"); 74 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
73 if (masterAvatar != null) 75 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
74 { 76 LLVector3 pos = new LLVector3(129, 129, 27);
75 world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
76 world.ParcelManager.NoParcelDataFromStorage();
77 }
78 77
79 world.CustomStartup(); 78 m_sceneObject = new MySceneObject(world, LLUUID.Zero, world.PrimIDAllocate(), pos, shape);
80 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); 79 world.AddNewEntity(m_sceneObject);
80
81 m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
81 m_log.ReadLine(); 82 m_log.ReadLine();
82
83 } 83 }
84 84
85 private bool AddNewSessionHandler(ulong regionHandle, Login loginData) 85 private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
86 { 86 {
87 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); 87 m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
@@ -101,15 +101,15 @@ namespace SimpleApp
101 101
102 return true; 102 return true;
103 } 103 }
104 104
105 #region IAssetReceiver Members 105 #region IAssetReceiver Members
106 106
107 public void AssetReceived( AssetBase asset, bool IsTexture) 107 public void AssetReceived(AssetBase asset, bool IsTexture)
108 { 108 {
109 throw new Exception("The method or operation is not implemented."); 109 throw new Exception("The method or operation is not implemented.");
110 } 110 }
111 111
112 public void AssetNotFound( AssetBase asset) 112 public void AssetNotFound(AssetBase asset)
113 { 113 {
114 throw new Exception("The method or operation is not implemented."); 114 throw new Exception("The method or operation is not implemented.");
115 } 115 }
@@ -134,7 +134,7 @@ namespace SimpleApp
134 { 134 {
135 Program app = new Program(); 135 Program app = new Program();
136 136
137 app.Run(); 137 app.Run();
138 } 138 }
139 } 139 }
140} 140}
diff --git a/OpenSim/Region/Examples/SimpleApp/PulseScript.cs b/OpenSim/Region/Examples/SimpleApp/PulseScript.cs
deleted file mode 100644
index b65765c..0000000
--- a/OpenSim/Region/Examples/SimpleApp/PulseScript.cs
+++ /dev/null
@@ -1,52 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Region.Scripting;
5using OpenSim.Region.Environment.Scenes;
6namespace SimpleApp
7{
8 public class PulseScript : IScript
9 {
10 ScriptInfo script;
11
12 private libsecondlife.LLVector3 pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
13 public string getName()
14 {
15 return "pulseScript 0.1";
16 }
17
18 public void Initialise(ScriptInfo scriptInfo)
19 {
20 script = scriptInfo;
21 script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
22 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
23 }
24
25 void events_OnNewPresence(ScenePresence presence)
26 {
27 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
28 }
29
30 void events_OnFrame()
31 {
32 foreach (EntityBase ent in this.script.world.Entities.Values)
33 {
34 if (ent is SceneObject)
35 {
36 SceneObject prim = (SceneObject)ent;
37 if ((prim.rootPrimitive.Scale.X > 1) && (prim.rootPrimitive.Scale.Y > 1) && (prim.rootPrimitive.Scale.Z > 1))
38 {
39 this.pulse = new libsecondlife.LLVector3(-0.1f, -0.1f, -0.1f);
40 }
41 else if ((prim.rootPrimitive.Scale.X < 0.2f) && (prim.rootPrimitive.Scale.Y < 0.2f) && (prim.rootPrimitive.Scale.Z < 0.2f))
42 {
43 pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
44 }
45
46 prim.rootPrimitive.ResizeGoup(prim.rootPrimitive.Scale + pulse);
47 }
48 }
49 }
50
51 }
52}