| 7 |
using ModularRex.RexNetwork; |
using ModularRex.RexNetwork; |
| 8 |
using Nini.Config; |
using Nini.Config; |
| 9 |
using OpenMetaverse; |
using OpenMetaverse; |
| 10 |
using OpenSim.Region.Environment.Interfaces; |
using OpenSim.Region.Framework.Interfaces; |
| 11 |
using OpenSim.Region.Environment.Scenes; |
using OpenSim.Region.Framework.Scenes; |
| 12 |
using OpenSim.Data.NHibernate; |
using OpenSim.Data.NHibernate; |
| 13 |
using OpenSim.Framework; |
using OpenSim.Framework; |
| 14 |
|
|
| 33 |
m_scenes.Add(scene); |
m_scenes.Add(scene); |
| 34 |
|
|
| 35 |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
| 36 |
scene.m_sceneGraph.OnObjectDuplicate += SceneGraph_OnObjectDuplicate; |
scene.SceneContents.OnObjectDuplicate += SceneGraph_OnObjectDuplicate; |
| 37 |
|
scene.SceneContents.OnObjectRemove += SceneGraph_OnObjectRemove; |
| 38 |
|
|
| 39 |
|
scene.AddCommand(this, "modreximport", "load 0.4 rex database <connstring>", "conn string example: SQLiteDialect;SQLite20Driver;Data Source=beneath_the_waves.db;Version=3", HandleLoadRexLegacyData); |
| 40 |
|
|
| 41 |
if (m_db == null) |
if (m_db == null) |
| 42 |
{ |
{ |
| 83 |
cloneprops.SetRexPrimDataFromObject(origprops); |
cloneprops.SetRexPrimDataFromObject(origprops); |
| 84 |
} |
} |
| 85 |
|
|
| 86 |
|
void SceneGraph_OnObjectRemove(EntityBase obj) |
| 87 |
|
{ |
| 88 |
|
DeleteObject(obj.UUID); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
//void rcv_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage e) |
//void rcv_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage e) |
| 93 |
//{ |
//{ |
| 94 |
// if (e.Message.StartsWith("/rexobj ")) |
// if (e.Message.StartsWith("/rexobj ")) |
| 120 |
} |
} |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
|
private void SendPreloadAssetsToUser(RexClientView user) |
| 124 |
|
{ |
| 125 |
|
try |
| 126 |
|
{ |
| 127 |
|
Scene ourScene = null; |
| 128 |
|
foreach (Scene s in m_scenes) |
| 129 |
|
{ |
| 130 |
|
if (user.Scene.RegionInfo.RegionHandle == s.RegionInfo.RegionHandle) |
| 131 |
|
ourScene = s; |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
if (ourScene != null) |
| 135 |
|
{ |
| 136 |
|
if (ourScene.Modules.ContainsKey("RexAssetPreload")) |
| 137 |
|
{ |
| 138 |
|
RexAssetPreload module = (RexAssetPreload)ourScene.Modules["RexAssetPreload"]; |
| 139 |
|
if (module.PreloadAssetDictionary.Count > 0) |
| 140 |
|
{ |
| 141 |
|
user.SendRexPreloadAssets(module.PreloadAssetDictionary); |
| 142 |
|
} |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
} |
| 146 |
|
catch (Exception e) |
| 147 |
|
{ |
| 148 |
|
m_log.Error("[MODREXOBJECTS]: Sending preload assets failed.", e); |
| 149 |
|
} |
| 150 |
|
} |
| 151 |
|
|
| 152 |
void SendAllPropertiesToUser(RexClientView user) |
void SendAllPropertiesToUser(RexClientView user) |
| 153 |
{ |
{ |
| 154 |
|
SendPreloadAssetsToUser(user); |
| 155 |
|
|
| 156 |
foreach (RexObjectProperties p in GetObjects()) |
foreach (RexObjectProperties p in GetObjects()) |
| 157 |
{ |
{ |
| 158 |
user.SendRexObjectProperties(p.ParentObjectID, p); |
user.SendRexObjectProperties(p.ParentObjectID, p); |
| 221 |
return; |
return; |
| 222 |
} |
} |
| 223 |
|
|
| 224 |
if (sop.ParentGroup != null && sop.PhysActor != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
| 225 |
{ |
{ |
| 226 |
if (p.RexCollisionMeshUUID != UUID.Zero) |
if (p.RexCollisionMeshUUID != UUID.Zero) |
| 227 |
RexUpdateCollisionMesh(id); |
RexUpdateCollisionMesh(id); |
| 228 |
else |
else |
| 229 |
sop.PhysActor.SetCollisionMesh(null, "", false); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(null, "", false); |
| 230 |
} |
} |
| 231 |
} |
} |
| 232 |
|
|
| 244 |
return; |
return; |
| 245 |
} |
} |
| 246 |
|
|
| 247 |
if (sop.ParentGroup != null && sop.PhysActor != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
| 248 |
{ |
{ |
| 249 |
sop.PhysActor.SetBoundsScaling(p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetBoundsScaling(p.RexScaleToPrim); |
| 250 |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
| 251 |
} |
} |
| 252 |
} |
} |
| 283 |
return; |
return; |
| 284 |
} |
} |
| 285 |
|
|
| 286 |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor != null) |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor is IRexPhysicsActor) |
| 287 |
{ |
{ |
| 288 |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetCache.GetAsset(p.RexCollisionMeshUUID, false); |
AssetBase tempmodel = sop.ParentGroup.Scene.CommsManager.AssetCache.GetAsset(p.RexCollisionMeshUUID, false); |
| 289 |
if (tempmodel != null) |
if (tempmodel != null) |
| 290 |
sop.PhysActor.SetCollisionMesh(tempmodel.Data, tempmodel.Metadata.Name, p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(tempmodel.Data, tempmodel.Name, p.RexScaleToPrim); |
| 291 |
} |
} |
| 292 |
} |
} |
| 293 |
|
|
| 294 |
|
public byte GetAssetType(UUID assetid) |
| 295 |
|
{ |
| 296 |
|
AssetBase tempmodel = m_scenes[0].CommsManager.AssetCache.GetAsset(assetid, true); |
| 297 |
|
if (tempmodel == null) |
| 298 |
|
m_scenes[0].CommsManager.AssetCache.GetAsset(assetid, false); |
| 299 |
|
|
| 300 |
|
if (tempmodel != null) |
| 301 |
|
return(byte)(tempmodel.Type); |
| 302 |
|
else |
| 303 |
|
return 0; |
| 304 |
|
} |
| 305 |
#endregion |
#endregion |
| 306 |
|
|
| 307 |
|
|
| 370 |
if (RexObjectPropertiesCache.ContainsKey(id)) |
if (RexObjectPropertiesCache.ContainsKey(id)) |
| 371 |
{ |
{ |
| 372 |
RexObjectPropertiesCache.Remove(id); |
RexObjectPropertiesCache.Remove(id); |
| 373 |
|
m_db.RemoveObject(id); |
| 374 |
return true; |
return true; |
| 375 |
} |
} |
| 376 |
return false; |
return false; |
| 379 |
|
|
| 380 |
#endregion |
#endregion |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
public void HandleLoadRexLegacyData(string module, string[] args) |
| 384 |
|
{ |
| 385 |
|
NHibernateRexLegacyData legacydata = new NHibernateRexLegacyData(); |
| 386 |
|
|
| 387 |
|
legacydata.Initialise(args[1]); |
| 388 |
|
if(!legacydata.Inizialized) |
| 389 |
|
{ |
| 390 |
|
m_log.Info("[MODREXOBJECTS]: Legacy database failed to initialize."); |
| 391 |
|
return; |
| 392 |
|
} |
| 393 |
|
|
| 394 |
|
List<RexLegacyPrimData> rexprimdata = legacydata.LoadAllRexPrimData(); |
| 395 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimdata objects loaded:" + rexprimdata.Count.ToString()); |
| 396 |
|
|
| 397 |
|
List<RexLegacyPrimMaterialData> rexprimmaterialdata = legacydata.LoadAllRexPrimMaterialData(); |
| 398 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimmaterialdata objects loaded:" + rexprimmaterialdata.Count.ToString()); |
| 399 |
|
|
| 400 |
|
foreach (RexLegacyPrimData prim in rexprimdata) |
| 401 |
|
{ |
| 402 |
|
RexObjectProperties p = GetObject(prim.UUID); |
| 403 |
|
p.SetRexPrimDataFromLegacyData(prim); |
| 404 |
|
} |
| 405 |
|
|
| 406 |
|
foreach (RexLegacyPrimMaterialData primmat in rexprimmaterialdata) |
| 407 |
|
{ |
| 408 |
|
RexObjectProperties p = GetObject(primmat.UUID); |
| 409 |
|
p.RexMaterials.AddMaterial((uint)primmat.MaterialIndex,primmat.MaterialUUID); |
| 410 |
|
} |
| 411 |
|
} |
| 412 |
|
|
| 413 |
} |
} |
| 414 |
} |
} |