* Worked some more on SimpleApp
* Removed SceneObject references to RegionHandle, ParcelManager, EventManager as they are public on Scene * Moved PulseScript behaviour into MySceneObjectafrisby
parent
423d03eaef
commit
811d2b69c9
|
@ -454,18 +454,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <param name="ownerID"></param>
|
/// <param name="ownerID"></param>
|
||||||
public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
|
public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
|
||||||
{
|
{
|
||||||
try
|
SceneObject sceneOb = new SceneObject(this, ownerID, this.PrimIDAllocate(), pos, shape);
|
||||||
{
|
AddNewEntity(sceneOb);
|
||||||
SceneObject sceneOb = new SceneObject(m_regionHandle, this, this.m_eventManager,this.m_parcelManager, ownerID, this.PrimIDAllocate(), pos, shape);
|
}
|
||||||
this.Entities.Add(sceneOb.rootUUID, sceneOb);
|
|
||||||
|
|
||||||
// Trigger event for listeners
|
public void AddNewEntity(SceneObject sceneObject)
|
||||||
// eventManager.TriggerOnNewPrimitive(prim);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
|
this.Entities.Add(sceneObject.rootUUID, sceneObject);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -579,13 +574,17 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
|
client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
|
||||||
});
|
});
|
||||||
|
|
||||||
lock (Avatars) {
|
lock (Avatars)
|
||||||
if (Avatars.ContainsKey(agentID)) {
|
{
|
||||||
|
if (Avatars.ContainsKey(agentID))
|
||||||
|
{
|
||||||
Avatars.Remove(agentID);
|
Avatars.Remove(agentID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock (Entities) {
|
lock (Entities)
|
||||||
if (Entities.ContainsKey(agentID)) {
|
{
|
||||||
|
if (Entities.ContainsKey(agentID))
|
||||||
|
{
|
||||||
Entities.Remove(agentID);
|
Entities.Remove(agentID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,12 +79,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </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_world = world;
|
||||||
m_eventManager = eventManager;
|
m_eventManager = world.EventManager;
|
||||||
m_parcelManager = parcelManager;
|
m_parcelManager = world.ParcelManager;
|
||||||
|
|
||||||
this.Pos = pos;
|
this.Pos = pos;
|
||||||
this.CreateRootFromShape(ownerID, localID, shape, pos);
|
this.CreateRootFromShape(ownerID, localID, shape, pos);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,22 +22,6 @@ namespace SimpleApp
|
||||||
m_avatars = new List<Avatar>();
|
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()
|
public override void LoadWorldMap()
|
||||||
{
|
{
|
||||||
float[] map = new float[65536];
|
float[] map = new float[65536];
|
||||||
|
@ -87,27 +71,6 @@ namespace SimpleApp
|
||||||
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ using OpenSim.Region.Capabilities;
|
||||||
using OpenSim.Region.ClientStack;
|
using OpenSim.Region.ClientStack;
|
||||||
using OpenSim.Region.Communications.Local;
|
using OpenSim.Region.Communications.Local;
|
||||||
using OpenSim.Region.GridInterfaces.Local;
|
using OpenSim.Region.GridInterfaces.Local;
|
||||||
using OpenSim.Framework.Data;
|
using System.Timers;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace SimpleApp
|
namespace SimpleApp
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,7 @@ namespace SimpleApp
|
||||||
AuthenticateSessionsBase m_circuitManager;
|
AuthenticateSessionsBase m_circuitManager;
|
||||||
uint m_localId;
|
uint m_localId;
|
||||||
public MyWorld world;
|
public MyWorld world;
|
||||||
|
private SceneObject m_sceneObject;
|
||||||
|
|
||||||
private void Run()
|
private void Run()
|
||||||
{
|
{
|
||||||
|
@ -50,7 +52,6 @@ namespace SimpleApp
|
||||||
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);
|
PacketServer packetServer = new PacketServer(udpServer);
|
||||||
|
|
||||||
|
|
||||||
ClientView.TerrainManager = new TerrainManager(new SecondLife());
|
ClientView.TerrainManager = new TerrainManager(new SecondLife());
|
||||||
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
|
BaseHttpServer httpServer = new BaseHttpServer(internalEndPoint.Port);
|
||||||
|
|
||||||
|
@ -63,23 +64,22 @@ namespace SimpleApp
|
||||||
world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
|
world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
|
||||||
|
|
||||||
world.LoadWorldMap();
|
world.LoadWorldMap();
|
||||||
|
world.ParcelManager.NoParcelDataFromStorage();
|
||||||
|
|
||||||
udpServer.LocalWorld = world;
|
udpServer.LocalWorld = world;
|
||||||
|
|
||||||
httpServer.Start();
|
httpServer.Start();
|
||||||
udpServer.ServerListener();
|
udpServer.ServerListener();
|
||||||
|
|
||||||
UserProfileData masterAvatar = communicationsManager.UserServer.SetupMasterUser("Test", "User", "test");
|
PrimitiveBaseShape shape = PrimitiveBaseShape.DefaultBox();
|
||||||
if (masterAvatar != null)
|
shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
|
||||||
{
|
LLVector3 pos = new LLVector3(129, 129, 27);
|
||||||
world.RegionInfo.MasterAvatarAssignedUUID = masterAvatar.UUID;
|
|
||||||
world.ParcelManager.NoParcelDataFromStorage();
|
m_sceneObject = new MySceneObject(world, LLUUID.Zero, world.PrimIDAllocate(), pos, shape);
|
||||||
}
|
world.AddNewEntity(m_sceneObject);
|
||||||
|
|
||||||
world.CustomStartup();
|
|
||||||
m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
|
m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");
|
||||||
m_log.ReadLine();
|
m_log.ReadLine();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
|
private bool AddNewSessionHandler(ulong regionHandle, Login loginData)
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue