| 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.m_sceneGraph.OnObjectRemove += SceneGraph_OnObjectRemove; |
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 |
{ |
{ |
| 68 |
if (client.TryGet(out rcv)) |
if (client.TryGet(out rcv)) |
| 69 |
{ |
{ |
| 70 |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
rcv.OnRexObjectProperties += rcv_OnRexObjectProperties; |
| 71 |
|
rcv.OnPrimFreeData += rcv_OnPrimFreeData; |
| 72 |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
//rcv.OnChatFromClient += rcv_OnChatFromClient; |
| 73 |
|
|
| 74 |
// Send them the current Scene. |
// Send them the current Scene. |
| 76 |
} |
} |
| 77 |
} |
} |
| 78 |
|
|
| 79 |
|
private void rcv_OnPrimFreeData(RexClientView sender, List<string> parameters) |
| 80 |
|
{ |
| 81 |
|
m_log.Info("[REXOBJS] Received Prim free data"); |
| 82 |
|
if (parameters.Count == 2) |
| 83 |
|
{ |
| 84 |
|
UUID primID = new UUID(parameters[0]); |
| 85 |
|
string data = parameters[1]; |
| 86 |
|
|
| 87 |
|
RexObjectProperties props = GetObject(primID); |
| 88 |
|
props.RexData = data; |
| 89 |
|
} |
| 90 |
|
else |
| 91 |
|
{ |
| 92 |
|
m_log.Warn("[REXOBJS] unexpected number of parameters"); |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
|
| 96 |
void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone) |
void SceneGraph_OnObjectDuplicate(EntityBase original, EntityBase clone) |
| 97 |
{ |
{ |
| 98 |
RexObjectProperties origprops = GetObject(original.UUID); |
RexObjectProperties origprops = GetObject(original.UUID); |
| 138 |
} |
} |
| 139 |
} |
} |
| 140 |
|
|
| 141 |
|
private void SendPreloadAssetsToUser(RexClientView user) |
| 142 |
|
{ |
| 143 |
|
try |
| 144 |
|
{ |
| 145 |
|
Scene ourScene = null; |
| 146 |
|
foreach (Scene s in m_scenes) |
| 147 |
|
{ |
| 148 |
|
if (user.Scene.RegionInfo.RegionHandle == s.RegionInfo.RegionHandle) |
| 149 |
|
ourScene = s; |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
if (ourScene != null) |
| 153 |
|
{ |
| 154 |
|
if (ourScene.Modules.ContainsKey("RexAssetPreload")) |
| 155 |
|
{ |
| 156 |
|
RexAssetPreload module = (RexAssetPreload)ourScene.Modules["RexAssetPreload"]; |
| 157 |
|
if (module.PreloadAssetDictionary.Count > 0) |
| 158 |
|
{ |
| 159 |
|
user.SendRexPreloadAssets(module.PreloadAssetDictionary); |
| 160 |
|
} |
| 161 |
|
} |
| 162 |
|
} |
| 163 |
|
} |
| 164 |
|
catch (Exception e) |
| 165 |
|
{ |
| 166 |
|
m_log.Error("[MODREXOBJECTS]: Sending preload assets failed.", e); |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
void SendAllPropertiesToUser(RexClientView user) |
void SendAllPropertiesToUser(RexClientView user) |
| 171 |
{ |
{ |
| 172 |
|
SendPreloadAssetsToUser(user); |
| 173 |
|
|
| 174 |
foreach (RexObjectProperties p in GetObjects()) |
foreach (RexObjectProperties p in GetObjects()) |
| 175 |
{ |
{ |
| 176 |
user.SendRexObjectProperties(p.ParentObjectID, p); |
user.SendRexObjectProperties(p.ParentObjectID, p); |
| 239 |
return; |
return; |
| 240 |
} |
} |
| 241 |
|
|
| 242 |
if (sop.ParentGroup != null && sop.PhysActor != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
| 243 |
{ |
{ |
| 244 |
if (p.RexCollisionMeshUUID != UUID.Zero) |
if (p.RexCollisionMeshUUID != UUID.Zero) |
| 245 |
RexUpdateCollisionMesh(id); |
RexUpdateCollisionMesh(id); |
| 246 |
else |
else |
| 247 |
sop.PhysActor.SetCollisionMesh(null, "", false); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(null, "", false); |
| 248 |
} |
} |
| 249 |
} |
} |
| 250 |
|
|
| 262 |
return; |
return; |
| 263 |
} |
} |
| 264 |
|
|
| 265 |
if (sop.ParentGroup != null && sop.PhysActor != null) |
if (sop.ParentGroup != null && sop.PhysActor is IRexPhysicsActor) |
| 266 |
{ |
{ |
| 267 |
sop.PhysActor.SetBoundsScaling(p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetBoundsScaling(p.RexScaleToPrim); |
| 268 |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
sop.ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(sop.PhysActor); |
| 269 |
} |
} |
| 270 |
} |
} |
| 301 |
return; |
return; |
| 302 |
} |
} |
| 303 |
|
|
| 304 |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor != null) |
if (p.RexCollisionMeshUUID != UUID.Zero && sop.PhysActor is IRexPhysicsActor) |
| 305 |
{ |
{ |
| 306 |
AssetBase tempmodel = sop.ParentGroup.Scene.AssetCache.GetAsset(p.RexCollisionMeshUUID, false); |
AssetBase tempmodel = sop.ParentGroup.Scene.CommsManager.AssetCache.GetAsset(p.RexCollisionMeshUUID, false); |
| 307 |
if (tempmodel != null) |
if (tempmodel != null) |
| 308 |
sop.PhysActor.SetCollisionMesh(tempmodel.Data, tempmodel.Metadata.Name, p.RexScaleToPrim); |
((IRexPhysicsActor)sop.PhysActor).SetCollisionMesh(tempmodel.Data, tempmodel.Name, p.RexScaleToPrim); |
| 309 |
} |
} |
| 310 |
} |
} |
| 311 |
|
|
| 312 |
|
public byte GetAssetType(UUID assetid) |
| 313 |
|
{ |
| 314 |
|
AssetBase tempmodel = m_scenes[0].CommsManager.AssetCache.GetAsset(assetid, true); |
| 315 |
|
if (tempmodel == null) |
| 316 |
|
m_scenes[0].CommsManager.AssetCache.GetAsset(assetid, false); |
| 317 |
|
|
| 318 |
|
if (tempmodel != null) |
| 319 |
|
return(byte)(tempmodel.Type); |
| 320 |
|
else |
| 321 |
|
return 0; |
| 322 |
|
} |
| 323 |
#endregion |
#endregion |
| 324 |
|
|
| 325 |
|
|
| 397 |
|
|
| 398 |
#endregion |
#endregion |
| 399 |
|
|
| 400 |
|
|
| 401 |
|
public void HandleLoadRexLegacyData(string module, string[] args) |
| 402 |
|
{ |
| 403 |
|
NHibernateRexLegacyData legacydata = new NHibernateRexLegacyData(); |
| 404 |
|
|
| 405 |
|
legacydata.Initialise(args[1]); |
| 406 |
|
if(!legacydata.Inizialized) |
| 407 |
|
{ |
| 408 |
|
m_log.Info("[MODREXOBJECTS]: Legacy database failed to initialize."); |
| 409 |
|
return; |
| 410 |
|
} |
| 411 |
|
|
| 412 |
|
List<RexLegacyPrimData> rexprimdata = legacydata.LoadAllRexPrimData(); |
| 413 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimdata objects loaded:" + rexprimdata.Count.ToString()); |
| 414 |
|
|
| 415 |
|
List<RexLegacyPrimMaterialData> rexprimmaterialdata = legacydata.LoadAllRexPrimMaterialData(); |
| 416 |
|
m_log.Info("[MODREXOBJECTS]: Legacy rexprimmaterialdata objects loaded:" + rexprimmaterialdata.Count.ToString()); |
| 417 |
|
|
| 418 |
|
foreach (RexLegacyPrimData prim in rexprimdata) |
| 419 |
|
{ |
| 420 |
|
RexObjectProperties p = GetObject(prim.UUID); |
| 421 |
|
p.SetRexPrimDataFromLegacyData(prim); |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
foreach (RexLegacyPrimMaterialData primmat in rexprimmaterialdata) |
| 425 |
|
{ |
| 426 |
|
RexObjectProperties p = GetObject(primmat.UUID); |
| 427 |
|
p.RexMaterials.AddMaterial((uint)primmat.MaterialIndex,primmat.MaterialUUID); |
| 428 |
|
} |
| 429 |
|
} |
| 430 |
|
|
| 431 |
} |
} |
| 432 |
} |
} |