| 11 |
using OpenSim.Region.Framework.Scenes; |
using OpenSim.Region.Framework.Scenes; |
| 12 |
using OpenSim.Data.NHibernate; |
using OpenSim.Data.NHibernate; |
| 13 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 14 |
|
using ModularRex.NHibernate; |
| 15 |
|
using OpenSim.Framework.Communications.Cache; |
| 16 |
|
|
| 17 |
namespace ModularRex.RexParts |
namespace ModularRex.RexParts |
| 18 |
{ |
{ |
| 34 |
{ |
{ |
| 35 |
m_scenes.Add(scene); |
m_scenes.Add(scene); |
| 36 |
|
|
| 37 |
|
scene.RegisterModuleInterface<ModrexObjects>(this); |
| 38 |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
| 39 |
scene.m_sceneGraph.OnObjectDuplicate += SceneGraph_OnObjectDuplicate; |
scene.SceneContents.OnObjectDuplicate += SceneGraph_OnObjectDuplicate; |
| 40 |
scene.m_sceneGraph.OnObjectRemove += SceneGraph_OnObjectRemove; |
scene.SceneContents.OnObjectRemove += SceneGraph_OnObjectRemove; |
| 41 |
|
|
| 42 |
|
scene.AddCommand(this, "modreximport", "load 0.4 rex database <connstring>", "conn string example: SQLiteDialect;SQLite20Driver;Data Source=beneath_the_waves.db;Version=3", HandleLoadRexLegacyData); |
| 43 |
|
|
| 44 |
if (m_db == null) |
if (m_db == null) |
| 45 |
{ |
{ |
| 67 |
|
|
| 68 |
void EventManager_OnClientConnect(OpenSim.Framework.Client.IClientCore client) |
void EventManager_OnClientConnect(OpenSim.Framework.Client.IClientCore client) |
| 69 |
{ |
{ |
| 70 |
RexClientView rcv; |
RexClientViewBase rcv; |
| 71 |
if (client.TryGet(out rcv)) |
if (client.TryGet(out rcv)) |
| 72 |
{ |
{ |
| 73 |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
| 74 |
|
rcv.OnPrimFreeData += rcv_OnPrimFreeData; |
| 75 |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
| 76 |
|
|
| 77 |
// Send them the current Scene. |
// Send them the current Scene. |
| 79 |
} |
} |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
|
private void rcv_OnPrimFreeData(IClientAPI sender, List<string> parameters) |
| 83 |
|
{ |
| 84 |
|
m_log.Info("[REXOBJS] Received Prim free data"); |
| 85 |
|
if (parameters.Count == 2) |
| 86 |
|
{ |
| 87 |
|
UUID primID = new UUID(parameters[0]); |
| 88 |
|
string data = parameters[1]; |
| 89 |
|
|
| 90 |
|
RexObjectProperties props = GetObject(primID); |
| 91 |
|
props.RexData = data; |
| 92 |
|
} |
| 93 |
|
else |
| 94 |
|
{ |
| 95 |
|
m_log.Warn("[REXOBJS] unexpected number of parameters"); |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|
| 99 |
void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone) |
void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone) |
| 100 |
{ |
{ |
| 101 |
RexObjectProperties origprops = GetObject(original.UUID); |
RexObjectProperties origprops = GetObject(original.UUID); |
| 132 |
scene.ForEachScenePresence( |
scene.ForEachScenePresence( |
| 133 |
delegate(ScenePresence avatar) |
delegate(ScenePresence avatar) |
| 134 |
{ |
{ |
| 135 |
RexClientView rex; |
RexClientViewBase rex; |
| 136 |
if (avatar.ClientView.TryGet(out rex)) |
if (avatar.ClientView.TryGet(out rex)) |
| 137 |
{ |
{ |
| 138 |
rex.SendRexObjectProperties(id,props); |
rex.SendRexObjectProperties(id,props); |
| 141 |
} |
} |
| 142 |
} |
} |
| 143 |
|
|
| 144 |
private void SendPreloadAssetsToUser(RexClientView user) |
private void SendPreloadAssetsToUser(RexClientViewBase user) |
| 145 |
{ |
{ |
| 146 |
try |
try |
| 147 |
{ |
{ |
| 170 |
} |
} |
| 171 |
} |
} |
| 172 |
|
|
| 173 |
void SendAllPropertiesToUser(RexClientView user) |
void SendAllPropertiesToUser(RexClientViewBase user) |
| 174 |
{ |
{ |
| 175 |
SendPreloadAssetsToUser(user); |
SendPreloadAssetsToUser(user); |
| 176 |
|
|
| 180 |
} |
} |
| 181 |
} |
} |
| 182 |
|
|
| 183 |
void rcv_OnRexObjectProperties(RexClientView sender, UUID id, RexObjectProperties props) |
void rcv_OnRexObjectProperties(IClientAPI sender, UUID id, RexObjectProperties props) |
| 184 |
{ |
{ |
| 185 |
m_log.Info("[REXOBJS] Received RexObjData for " + id); |
m_log.Info("[REXOBJS] Received RexObjData for " + id); |
| 186 |
if (props.ParentObjectID == UUID.Zero) |
if (props.ParentObjectID == UUID.Zero) |
| 306 |
|
|
| 307 |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor is IRexPhysicsActor) |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor is IRexPhysicsActor) |
| 308 |
{ |
{ |
| 309 |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetCache.GetAsset(p.RexCollisionMeshUUID, false); |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetService.Get(p.RexCollisionMeshUUID.ToString()); |
| 310 |
if (tempmodel != null) |
if (tempmodel != null) |
| 311 |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(tempmodel.Data, tempmodel.Metadata.Name, p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(tempmodel.Data, tempmodel.Name, p.RexScaleToPrim); |
| 312 |
} |
} |
| 313 |
} |
} |
| 314 |
|
|
| 315 |
public byte GetAssetType(UUID assetid) |
public byte GetAssetType(UUID assetid) |
| 316 |
{ |
{ |
| 317 |
AssetBase tempmodel = m_scenes[0].AssetCache.GetAsset(assetid, true); |
AssetBase tempmodel = m_scenes[0].AssetService.Get(assetid.ToString()); |
| 318 |
if (tempmodel == null) |
if (tempmodel == null) |
| 319 |
m_scenes[0].AssetCache.GetAsset(assetid, false); |
m_scenes[0].AssetService.Get(assetid.ToString()); |
| 320 |
|
|
| 321 |
if (tempmodel != null) |
if (tempmodel != null) |
| 322 |
return(byte)(tempmodel.Metadata.Type); |
return(byte)(tempmodel.Type); |
| 323 |
else |
else |
| 324 |
return 0; |
return 0; |
| 325 |
} |
} |
| 375 |
RexObjectProperties props = RexObjectPropertiesCache[id]; |
RexObjectProperties props = RexObjectPropertiesCache[id]; |
| 376 |
if (props == null) |
if (props == null) |
| 377 |
{ |
{ |
| 378 |
|
//Objects that are not in the scene can't be found from cache. |
| 379 |
|
//So before we create new properties, we try to find them from db |
| 380 |
|
props = m_db.LoadObject(id); |
| 381 |
|
if (props == null) |
| 382 |
|
{ |
| 383 |
props = new RexObjectProperties(id, this); |
props = new RexObjectProperties(id, this); |
| 384 |
|
} |
| 385 |
RexObjectPropertiesCache.Add(id, props); |
RexObjectPropertiesCache.Add(id, props); |
| 386 |
} |
} |
| 387 |
return props; |
return props; |
| 403 |
return false; |
return false; |
| 404 |
} |
} |
| 405 |
|
|
|
|
|
| 406 |
#endregion |
#endregion |
| 407 |
|
|
| 408 |
|
|
| 409 |
|
public void HandleLoadRexLegacyData(string module, string[] args) |
| 410 |
|
{ |
| 411 |
|
NHibernateRexLegacyData legacydata = new NHibernateRexLegacyData(); |
| 412 |
|
|
| 413 |
|
legacydata.Initialise(args[1]); |
| 414 |
|
if(!legacydata.Inizialized) |
| 415 |
|
{ |
| 416 |
|
m_log.Info("[MODREXOBJECTS]: Legacy database failed to initialize."); |
| 417 |
|
return; |
| 418 |
|
} |
| 419 |
|
|
| 420 |
|
List<RexLegacyPrimData> rexprimdata = legacydata.LoadAllRexPrimData(); |
| 421 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimdata objects loaded:" + rexprimdata.Count.ToString()); |
| 422 |
|
|
| 423 |
|
List<RexLegacyPrimMaterialData> rexprimmaterialdata = legacydata.LoadAllRexPrimMaterialData(); |
| 424 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimmaterialdata objects loaded:" + rexprimmaterialdata.Count.ToString()); |
| 425 |
|
|
| 426 |
|
foreach (RexLegacyPrimData prim in rexprimdata) |
| 427 |
|
{ |
| 428 |
|
RexObjectProperties p = GetObject(prim.UUID); |
| 429 |
|
p.SetRexPrimDataFromLegacyData(prim); |
| 430 |
|
} |
| 431 |
|
|
| 432 |
|
foreach (RexLegacyPrimMaterialData primmat in rexprimmaterialdata) |
| 433 |
|
{ |
| 434 |
|
RexObjectProperties p = GetObject(primmat.UUID); |
| 435 |
|
p.RexMaterials.AddMaterial((uint)primmat.MaterialIndex,primmat.MaterialUUID); |
| 436 |
|
} |
| 437 |
|
} |
| 438 |
|
|
| 439 |
} |
} |
| 440 |
} |
} |