mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
* Worked some more on SimpleApp
* Removed SceneObject references to RegionHandle, ParcelManager, EventManager as they are public on Scene * Moved PulseScript behaviour into MySceneObject
This commit is contained in:
40
OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
Normal file
40
OpenSim/Region/Examples/SimpleApp/MySceneObject.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user