aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Examples
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs50
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs14
-rw-r--r--OpenSim/Region/Examples/SimpleApp/PulseScript.cs52
3 files changed, 110 insertions, 6 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index 39666fb..1f40052 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -7,12 +7,14 @@ using OpenSim.Framework.Servers;
7using OpenSim.Framework.Types; 7using 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 Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; 11using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
11 12
12namespace SimpleApp 13namespace SimpleApp
13{ 14{
14 public class MyWorld : Scene 15 public class MyWorld : Scene
15 { 16 {
17 private bool firstlogin = true;
16 private List<ScenePresence> m_avatars; 18 private List<ScenePresence> m_avatars;
17 19
18 public MyWorld(ClientManager clientManager, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) 20 public MyWorld(ClientManager clientManager, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer)
@@ -21,6 +23,7 @@ namespace SimpleApp
21 m_avatars = new List<Avatar>(); 23 m_avatars = new List<Avatar>();
22 } 24 }
23 25
26 /*
24 public override void SendLayerData(IClientAPI remoteClient) 27 public override void SendLayerData(IClientAPI remoteClient)
25 { 28 {
26 float[] map = new float[65536]; 29 float[] map = new float[65536];
@@ -34,6 +37,22 @@ namespace SimpleApp
34 } 37 }
35 38
36 remoteClient.SendLayerData(map); 39 remoteClient.SendLayerData(map);
40 }*/
41
42 public override void LoadWorldMap()
43 {
44 float[] map = new float[65536];
45
46 for (int i = 0; i < 65536; i++)
47 {
48 int x = i % 256;
49 int y = i / 256;
50
51 map[i] = 25f;
52 }
53
54 this.Terrain.setHeights1D(map);
55 this.CreateTerrainTexture();
37 } 56 }
38 57
39 #region IWorld Members 58 #region IWorld Members
@@ -41,6 +60,8 @@ namespace SimpleApp
41 override public void AddNewClient(IClientAPI client, bool child) 60 override public void AddNewClient(IClientAPI client, bool child)
42 61
43 { 62 {
63 NewLoggin();
64
44 LLVector3 pos = new LLVector3(128, 128, 128); 65 LLVector3 pos = new LLVector3(128, 128, 128);
45 66
46 client.OnRegionHandShakeReply += SendLayerData; 67 client.OnRegionHandShakeReply += SendLayerData;
@@ -66,8 +87,33 @@ namespace SimpleApp
66 87
67 client.SendRegionHandshake(m_regInfo); 88 client.SendRegionHandshake(m_regInfo);
68 89
69 CreateAndAddScenePresence(client); 90 ScenePresence avatar =CreateAndAddScenePresence(client);
70 91 avatar.Pos = new LLVector3(128, 128, 26);
92 }
93
94 public void NewLoggin()
95 {
96 if (firstlogin)
97 {
98 this.StartTimer();
99
100 scriptManager.AddPreCompiledScript(new PulseScript());
101
102 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
103 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
104 LLVector3 pos1 = new LLVector3(129, 129, 27);
105 AddNewPrim(LLUUID.Random(), pos1, shape);
106 firstlogin = false;
107 }
108 }
109
110 public override void Update()
111 {
112 foreach (LLUUID UUID in Entities.Keys)
113 {
114 Entities[UUID].update();
115 }
116 eventManager.TriggerOnFrame();
71 } 117 }
72 118
73 #endregion 119 #endregion
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index e5e2234..3723c3d 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -21,6 +21,7 @@ namespace SimpleApp
21 private LogBase m_log; 21 private LogBase m_log;
22 AuthenticateSessionsBase m_circuitManager; 22 AuthenticateSessionsBase m_circuitManager;
23 uint m_localId; 23 uint m_localId;
24 public MyWorld world;
24 25
25 private void Run() 26 private void Run()
26 { 27 {
@@ -57,8 +58,9 @@ namespace SimpleApp
57 58
58 RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "127.0.0.1" ); 59 RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "127.0.0.1" );
59 60
60 MyWorld world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer); 61 world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer);
61 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null; 62 world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
63 world.LoadWorldMap();
62 udpServer.LocalWorld = world; 64 udpServer.LocalWorld = world;
63 65
64 httpServer.Start(); 66 httpServer.Start();
@@ -66,13 +68,16 @@ namespace SimpleApp
66 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit."); 68 m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
67 m_log.ReadLine(); 69 m_log.ReadLine();
68 70
71
72 /*
69 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox(); 73 PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
70 74
71 shape.Scale = new LLVector3(10, 10, 10); 75 shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
72 76
73 LLVector3 pos = new LLVector3(128,128,72); 77 LLVector3 pos = new LLVector3(129,130,25);
74 78
75 world.AddNewPrim( LLUUID.Zero, pos, shape ); 79 world.AddNewPrim( LLUUID.Random(), pos, shape );
80 */
76 81
77 } 82 }
78 83
@@ -129,6 +134,7 @@ namespace SimpleApp
129 Program app = new Program(); 134 Program app = new Program();
130 135
131 app.Run(); 136 app.Run();
137
132 } 138 }
133 } 139 }
134} 140}
diff --git a/OpenSim/Region/Examples/SimpleApp/PulseScript.cs b/OpenSim/Region/Examples/SimpleApp/PulseScript.cs
new file mode 100644
index 0000000..01a9bda
--- /dev/null
+++ b/OpenSim/Region/Examples/SimpleApp/PulseScript.cs
@@ -0,0 +1,52 @@
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}