diff options
author | MW | 2007-07-14 13:18:02 +0000 |
---|---|---|
committer | MW | 2007-07-14 13:18:02 +0000 |
commit | a04602d9c136b882a6c72d4c3c09c3ca0d526c37 (patch) | |
tree | 5ff7df736ea67a6ab7830fa0d41a85610d900bbb | |
parent | *Moved the OnSignificantClientMovement event to ScenePresence. (diff) | |
download | opensim-SC_OLD-a04602d9c136b882a6c72d4c3c09c3ca0d526c37.zip opensim-SC_OLD-a04602d9c136b882a6c72d4c3c09c3ca0d526c37.tar.gz opensim-SC_OLD-a04602d9c136b882a6c72d4c3c09c3ca0d526c37.tar.bz2 opensim-SC_OLD-a04602d9c136b882a6c72d4c3c09c3ca0d526c37.tar.xz |
Added AddPreCompiledScript method to ScriptManager.
Done some work on lbsa71's simpleApp(hope he doesn't mind):
now have the avatar showing up and the terrain and his pulsating box (well except its not a box, as there seems to be something wrong with our PrimitiveBaseShape..DefaultBox() settings).
Also noticed a few other problems that I had to work around, so these need looking into.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/General/Types/PrimitiveBaseShape.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 50 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/Program.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/PulseScript.cs | 52 | ||||
-rw-r--r-- | prebuild.xml | 1 |
9 files changed, 126 insertions, 11 deletions
diff --git a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs index 1844caa..a085a44 100644 --- a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs | |||
@@ -100,6 +100,8 @@ namespace OpenSim.Framework.Types | |||
100 | primShape.PathTaperY = 0; | 100 | primShape.PathTaperY = 0; |
101 | primShape.PathTwist = 0; | 101 | primShape.PathTwist = 0; |
102 | primShape.PathTwistBegin = 0; | 102 | primShape.PathTwistBegin = 0; |
103 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); | ||
104 | primShape.TextureEntry = ntex.ToBytes(); | ||
103 | 105 | ||
104 | return primShape; | 106 | return primShape; |
105 | } | 107 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index f9b3145..bf98b0d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -146,6 +146,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | avatar = this.Avatars[fromAgentID]; | 146 | avatar = this.Avatars[fromAgentID]; |
147 | fromPos = avatar.Pos; | 147 | fromPos = avatar.Pos; |
148 | fromName = avatar.firstname + " " + avatar.lastname; | 148 | fromName = avatar.firstname + " " + avatar.lastname; |
149 | avatar = null; | ||
149 | } | 150 | } |
150 | 151 | ||
151 | m_clientManager.ForEachClient(delegate(IClientAPI client) | 152 | m_clientManager.ForEachClient(delegate(IClientAPI client) |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 318b025..737e8fe 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -487,7 +487,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
487 | 487 | ||
488 | } | 488 | } |
489 | 489 | ||
490 | protected void CreateAndAddScenePresence(IClientAPI client) | 490 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) |
491 | { | 491 | { |
492 | ScenePresence newAvatar = null; | 492 | ScenePresence newAvatar = null; |
493 | 493 | ||
@@ -524,6 +524,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
524 | this.Avatars.Add(client.AgentId, newAvatar); | 524 | this.Avatars.Add(client.AgentId, newAvatar); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | newAvatar.OnSignificantClientMovement += parcelManager.handleSignificantClientMovement; | ||
528 | return newAvatar; | ||
527 | } | 529 | } |
528 | 530 | ||
529 | 531 | ||
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 8559caf..6966989 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -40,9 +40,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
40 | { | 40 | { |
41 | public partial class ScenePresence : Entity | 41 | public partial class ScenePresence : Entity |
42 | { | 42 | { |
43 | |||
44 | |||
45 | |||
46 | public static bool PhysicsEngineFlying = false; | 43 | public static bool PhysicsEngineFlying = false; |
47 | public static AvatarAnimations Animations; | 44 | public static AvatarAnimations Animations; |
48 | public static byte[] DefaultTexture; | 45 | public static byte[] DefaultTexture; |
@@ -151,7 +148,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
151 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); | 148 | // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); |
152 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 149 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
153 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 150 | //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
154 | OnSignificantClientMovement += new SignificantClientMovement(m_world.parcelManager.handleSignificantClientMovement); | 151 | |
155 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD | 152 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD |
156 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK | 153 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK |
157 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT | 154 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT |
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs index 736d18b..7a08735 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs | |||
@@ -89,6 +89,14 @@ namespace OpenSim.Region.Scripting | |||
89 | break; | 89 | break; |
90 | } | 90 | } |
91 | } | 91 | } |
92 | |||
93 | public void AddPreCompiledScript(IScript script) | ||
94 | { | ||
95 | MainLog.Instance.Verbose("Loading script " + script.getName()); | ||
96 | ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. | ||
97 | script.Initialise(scriptInfo); | ||
98 | scripts.Add(script); | ||
99 | } | ||
92 | } | 100 | } |
93 | 101 | ||
94 | interface IScriptCompiler | 102 | interface IScriptCompiler |
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; | |||
7 | using OpenSim.Framework.Types; | 7 | using OpenSim.Framework.Types; |
8 | using OpenSim.Region.Caches; | 8 | using OpenSim.Region.Caches; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Terrain; | ||
10 | using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; | 11 | using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; |
11 | 12 | ||
12 | namespace SimpleApp | 13 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Region.Scripting; | ||
5 | using OpenSim.Region.Environment.Scenes; | ||
6 | namespace 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 | } | ||
diff --git a/prebuild.xml b/prebuild.xml index 26d7b42..90eca77 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -726,6 +726,7 @@ | |||
726 | <Reference name="OpenSim.Region.Caches"/> | 726 | <Reference name="OpenSim.Region.Caches"/> |
727 | <Reference name="OpenSim.Region.ClientStack"/> | 727 | <Reference name="OpenSim.Region.ClientStack"/> |
728 | <Reference name="OpenSim.Region.Environment"/> | 728 | <Reference name="OpenSim.Region.Environment"/> |
729 | <Reference name="OpenSim.Region.Terrain.BasicTerrain"/> | ||
729 | 730 | ||
730 | 731 | ||
731 | <Files> | 732 | <Files> |