* Worked some more on SimpleApp

* Removed SceneObject references to RegionHandle, ParcelManager, EventManager as they are public on Scene
* Moved PulseScript behaviour into MySceneObject
afrisby
lbsa71 2007-07-14 15:33:25 +00:00
parent 423d03eaef
commit 811d2b69c9
6 changed files with 108 additions and 158 deletions

View File

@ -41,8 +41,8 @@ using OpenSim.Physics.Manager;
using OpenSim.Region.Caches;
using OpenSim.Region.Scripting;
using OpenSim.Region.Terrain;
using Caps=OpenSim.Region.Capabilities.Caps;
using Timer=System.Timers.Timer;
using Caps = OpenSim.Region.Capabilities.Caps;
using Timer = System.Timers.Timer;
namespace OpenSim.Region.Environment.Scenes
{
@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes
//Perform parcel update of prim count
performParcelPrimCountUpdate();
this.parcelPrimCheckCount = 0;
}
}
}
}
@ -267,7 +267,7 @@ namespace OpenSim.Region.Environment.Scenes
{
this.SendLayerData(client);
});
foreach (LLUUID UUID in Entities.Keys)
{
Entities[UUID].LandRenegerated();
@ -454,18 +454,13 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="ownerID"></param>
public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
{
try
{
SceneObject sceneOb = new SceneObject(m_regionHandle, this, this.m_eventManager,this.m_parcelManager, ownerID, this.PrimIDAllocate(), pos, shape);
this.Entities.Add(sceneOb.rootUUID, sceneOb);
SceneObject sceneOb = new SceneObject(this, ownerID, this.PrimIDAllocate(), pos, shape);
AddNewEntity(sceneOb);
}
// Trigger event for listeners
// eventManager.TriggerOnNewPrimitive(prim);
}
catch (Exception e)
{
MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
}
public void AddNewEntity(SceneObject sceneObject)
{
this.Entities.Add(sceneObject.rootUUID, sceneObject);
}
#endregion
@ -484,7 +479,7 @@ namespace OpenSim.Region.Environment.Scenes
this.m_estateManager.sendRegionHandshake(client);
CreateAndAddScenePresence(client);
this.m_parcelManager.sendParcelOverlay(client);
}
protected virtual void SubscribeToClientEvents(IClientAPI client)
@ -512,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnObjectName += this.PrimName;
client.OnLinkObjects += this.LinkObjects;
client.OnObjectDuplicate += this.DuplicateObject;
client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_parcelManager.handleParcelPropertiesRequest);
client.OnParcelDivideRequest += new ParcelDivideRequest(m_parcelManager.handleParcelDivideRequest);
client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest);
@ -571,26 +566,30 @@ namespace OpenSim.Region.Environment.Scenes
{
m_eventManager.TriggerOnRemovePresence(agentID);
ScenePresence avatar = this.RequestAvatar(agentID);
ScenePresence avatar = this.RequestAvatar(agentID);
m_clientManager.ForEachClient(
delegate(IClientAPI client)
delegate(IClientAPI client)
{
client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
});
lock (Avatars)
{
if (Avatars.ContainsKey(agentID))
{
client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
});
lock (Avatars) {
if (Avatars.ContainsKey(agentID)) {
Avatars.Remove(agentID);
}
}
lock (Entities) {
if (Entities.ContainsKey(agentID)) {
lock (Entities)
{
if (Entities.ContainsKey(agentID))
{
Entities.Remove(agentID);
}
}
// TODO: Add the removal from physics ?
return;
@ -685,7 +684,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void RegisterRegionWithComms()
{
this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo);
if (this.regionCommsHost != null)
{

View File

@ -79,12 +79,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
///
/// </summary>
public SceneObject(ulong regionHandle, Scene world, EventManager eventManager, ParcelManager parcelManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
public SceneObject(Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
{
m_regionHandle = regionHandle;
m_regionHandle = world.RegionInfo.RegionHandle;
m_world = world;
m_eventManager = eventManager;
m_parcelManager = parcelManager;
m_eventManager = world.EventManager;
m_parcelManager = world.ParcelManager;
this.Pos = pos;
this.CreateRootFromShape(ownerID, localID, shape, pos);

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Scenes;
using libsecondlife;
using OpenSim.Framework.Types;
using System.Timers;
namespace SimpleApp
{
public class MySceneObject : SceneObject
{
LLVector3 delta = new LLVector3(0.1f, 0.1f, 0.1f);
public MySceneObject(Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
: base(world, ownerID, localID, pos, shape )
{
Timer timer = new Timer();
timer.Enabled = true;
timer.Interval = 100;
timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
public void Heartbeat(object sender, EventArgs e)
{
if (rootPrimitive.Scale.X > 1)
{
delta = new LLVector3(-0.1f, -0.1f, -0.1f);
}
if (rootPrimitive.Scale.X < 0.2f)
{
delta = new LLVector3(0.1f, 0.1f, 0.1f);
}
rootPrimitive.ResizeGoup(rootPrimitive.Scale + delta);
update();
}
}
}

View File

@ -8,7 +8,7 @@ using OpenSim.Framework.Types;
using OpenSim.Region.Caches;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Terrain;
using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence;
namespace SimpleApp
{
@ -22,22 +22,6 @@ namespace SimpleApp
m_avatars = new List<Avatar>();
}
/*
public override void SendLayerData(IClientAPI remoteClient)
{
float[] map = new float[65536];
for (int i = 0; i < 65536; i++)
{
int x = i % 256;
int y = i / 256;
map[i] = 0f;
}
remoteClient.SendLayerData(map);
}*/
public override void LoadWorldMap()
{
float[] map = new float[65536];
@ -59,55 +43,34 @@ namespace SimpleApp
override public void AddNewClient(IClientAPI client, bool child)
{
LLVector3 pos = new LLVector3(128, 128, 128);
client.OnRegionHandShakeReply += SendLayerData;
client.OnChatFromViewer +=
delegate(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
{
// Echo it (so you know what you typed)
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero);
};
{
// Echo it (so you know what you typed)
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
client.SendChatMessage("Ready.", 1, pos, "System", LLUUID.Zero );
};
client.OnAddPrim += AddNewPrim;
client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
client.OnRequestMapBlocks += this.RequestMapBlocks;
client.OnTeleportLocationRequest += this.RequestTeleportLocation;
client.OnGrapUpdate += this.MoveObject;
client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
client.OnCompleteMovementToRegion += delegate()
{
client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero);
client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero );
};
client.SendRegionHandshake(m_regInfo);
ScenePresence avatar = CreateAndAddScenePresence(client);
avatar.Pos = new LLVector3(128, 128, 26);
avatar.Pos = new LLVector3(128, 128, 26);
}
public void CustomStartup()
{
this.StartTimer();
ScriptManager.AddPreCompiledScript(new PulseScript());
PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
LLVector3 pos1 = new LLVector3(129, 129, 27);
AddNewPrim(LLUUID.Random(), pos1, shape);
}
public override void Update()
{
foreach (LLUUID UUID in Entities.Keys)
{
Entities[UUID].update();
}
EventManager.TriggerOnFrame();
}
#endregion
}
}

View File

@ -13,7 +13,8 @@ using OpenSim.Region.Capabilities;
using OpenSim.Region.ClientStack;
using OpenSim.Region.Communications.Local;
using OpenSim.Region.GridInterfaces.Local;
using OpenSim.Framework.Data;
using System.Timers;
using OpenSim.Region.Environment.Scenes;
namespace SimpleApp
{
@ -23,16 +24,17 @@ namespace SimpleApp
AuthenticateSessionsBase m_circuitManager;
uint m_localId;
public MyWorld world;
private SceneObject m_sceneObject;
private void Run()
{
m_log = new LogBase(null, "SimpleApp", this, false);
MainLog.Instance = m_log;
// CheckSumServer checksumServer = new CheckSumServer(12036);
// checksumServer.ServerListener();
// CheckSumServer checksumServer = new CheckSumServer(12036);
// checksumServer.ServerListener();
IPEndPoint internalEndPoint = new IPEndPoint( IPAddress.Parse( "127.0.0.1" ), 9000 );
IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000);
m_circuitManager = new AuthenticateSessionsBase();
@ -46,42 +48,40 @@ namespace SimpleApp
PhysicsManager physManager = new PhysicsManager();
physManager.LoadPlugins();
UDPServer udpServer = new UDPServer( internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager );
UDPServer udpServer = new UDPServer(internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager);
PacketServer packetServer = new PacketServer(udpServer);
ClientView.TerrainManager = new TerrainManager(new SecondLife());
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
NetworkServersInfo serverInfo = new NetworkServersInfo();
CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo, httpServer);
RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "127.0.0.1" );
RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "127.0.0.1");
world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer);
world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
world.LoadWorldMap();
world.ParcelManager.NoParcelDataFromStorage();
udpServer.LocalWorld = world;
httpServer.Start();
udpServer.ServerListener();
UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
if (masterAvatar != null)
{
world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
world.ParcelManager.NoParcelDataFromStorage();
}
PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
LLVector3 pos = new LLVector3(129, 129, 27);
world.CustomStartup();
m_log.WriteLine( LogPriority.NORMAL, "Press enter to quit.");
m_sceneObject = new MySceneObject(world, LLUUID.Zero, world.PrimIDAllocate(), pos, shape);
world.AddNewEntity(m_sceneObject);
m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
m_log.ReadLine();
}
private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
{
m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last);
@ -101,15 +101,15 @@ namespace SimpleApp
return true;
}
#region IAssetReceiver Members
public void AssetReceived( AssetBase asset, bool IsTexture)
public void AssetReceived(AssetBase asset, bool IsTexture)
{
throw new Exception("The method or operation is not implemented.");
}
public void AssetNotFound( AssetBase asset)
public void AssetNotFound(AssetBase asset)
{
throw new Exception("The method or operation is not implemented.");
}
@ -134,7 +134,7 @@ namespace SimpleApp
{
Program app = new Program();
app.Run();
app.Run();
}
}
}

View File

@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Scripting;
using OpenSim.Region.Environment.Scenes;
namespace SimpleApp
{
public class PulseScript : IScript
{
ScriptInfo script;
private libsecondlife.LLVector3 pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
public string getName()
{
return "pulseScript 0.1";
}
public void Initialise(ScriptInfo scriptInfo)
{
script = scriptInfo;
script.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
}
void events_OnNewPresence(ScenePresence presence)
{
script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
}
void events_OnFrame()
{
foreach (EntityBase ent in this.script.world.Entities.Values)
{
if (ent is SceneObject)
{
SceneObject prim = (SceneObject)ent;
if ((prim.rootPrimitive.Scale.X > 1) && (prim.rootPrimitive.Scale.Y > 1) && (prim.rootPrimitive.Scale.Z > 1))
{
this.pulse = new libsecondlife.LLVector3(-0.1f, -0.1f, -0.1f);
}
else if ((prim.rootPrimitive.Scale.X < 0.2f) && (prim.rootPrimitive.Scale.Y < 0.2f) && (prim.rootPrimitive.Scale.Z < 0.2f))
{
pulse = new libsecondlife.LLVector3(0.1f, 0.1f, 0.1f);
}
prim.rootPrimitive.ResizeGoup(prim.rootPrimitive.Scale + pulse);
}
}
}
}
}