| 380 |
} |
} |
| 381 |
else |
else |
| 382 |
{ |
{ |
| 383 |
m_log.Warn("[NEWPRIM]: Duplicate prim, bleh, piping to the graphics layer anyway... "); |
// Full object update |
| 384 |
|
//m_log.Warn("[NEWPRIM] "); |
| 385 |
} |
} |
| 386 |
} |
} |
| 387 |
objectModQueue.Enqueue(newObject); |
objectModQueue.Enqueue(newObject); |
| 445 |
|
|
| 446 |
} |
} |
| 447 |
//} |
//} |
| 448 |
|
bool creatednode = false; |
| 449 |
|
SceneNode node = null; |
| 450 |
SceneNode node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
if (vObj.node == null) |
| 451 |
|
{ |
| 452 |
|
node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
| 453 |
|
creatednode = true; |
| 454 |
vObj.node = node; |
vObj.node = node; |
| 455 |
|
} |
| 456 |
|
else |
| 457 |
|
{ |
| 458 |
|
node = vObj.node; |
| 459 |
|
} |
| 460 |
|
|
| 461 |
node.Scale = new Vector3D(vObj.prim.Scale.X, vObj.prim.Scale.Z , vObj.prim.Scale.Y); |
node.Scale = new Vector3D(vObj.prim.Scale.X, vObj.prim.Scale.Z , vObj.prim.Scale.Y); |
| 462 |
// m_log.WarnFormat("[SCALE]: <{0},{1},{2}> = <{3},{4},{5}>", vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y, pscalex, pscaley, pscalez); |
// m_log.WarnFormat("[SCALE]: <{0},{1},{2}> = <{3},{4},{5}>", vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y, pscalex, pscaley, pscalez); |
| 463 |
if (vObj.prim.ParentID == 0) |
if (vObj.prim.ParentID == 0) |
| 469 |
node.Position = new Vector3D(WorldoffsetPos.X + parentObj.prim.Position.X + vObj.prim.Position.X, WorldoffsetPos.Z + parentObj.prim.Position.Z + vObj.prim.Position.Z, WorldoffsetPos.Y + parentObj.prim.Position.Y + vObj.prim.Position.Y); |
node.Position = new Vector3D(WorldoffsetPos.X + parentObj.prim.Position.X + vObj.prim.Position.X, WorldoffsetPos.Z + parentObj.prim.Position.Z + vObj.prim.Position.Z, WorldoffsetPos.Y + parentObj.prim.Position.Y + vObj.prim.Position.Y); |
| 470 |
} |
} |
| 471 |
|
|
|
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
|
| 472 |
|
|
| 473 |
//m_log.Warn(vObj.prim.Rotation.ToString()); |
//m_log.Warn(vObj.prim.Rotation.ToString()); |
| 474 |
IrrlichtNETCP.Quaternion iqu = new IrrlichtNETCP.Quaternion(vObj.prim.Rotation.X, vObj.prim.Rotation.Z, vObj.prim.Rotation.Y, vObj.prim.Rotation.W); |
IrrlichtNETCP.Quaternion iqu = new IrrlichtNETCP.Quaternion(vObj.prim.Rotation.X, vObj.prim.Rotation.Z, vObj.prim.Rotation.Y, vObj.prim.Rotation.W); |
| 489 |
|
|
| 490 |
|
|
| 491 |
node.Rotation = finalpos.Matrix.RotationDegrees; |
node.Rotation = finalpos.Matrix.RotationDegrees; |
| 492 |
|
if (creatednode) |
| 493 |
|
{ |
| 494 |
|
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
| 495 |
node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
| 496 |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false); |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false); |
| 497 |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
|
node.UpdateAbsolutePosition(); |
|
| 498 |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
| 499 |
node.TriangleSelector = trisel; |
node.TriangleSelector = trisel; |
| 500 |
lock (mts) |
lock (mts) |
| 501 |
{ |
{ |
| 502 |
mts.AddTriangleSelector(trisel); |
mts.AddTriangleSelector(trisel); |
| 503 |
} |
} |
| 504 |
|
} |
| 505 |
|
|
| 506 |
|
node.UpdateAbsolutePosition(); |
| 507 |
} |
} |
| 508 |
} |
} |
| 509 |
} |
} |
| 542 |
WorldoffsetPos = gposr - gposc; |
WorldoffsetPos = gposr - gposc; |
| 543 |
} |
} |
| 544 |
} |
} |
| 545 |
SceneNode node = smgr.AddMeshSceneNode(vObj.mesh, smgr.RootSceneNode, (int)vObj.prim.LocalID); |
bool creatednode = false; |
| 546 |
|
|
| 547 |
|
SceneNode node = null; |
| 548 |
|
if (vObj.node == null) |
| 549 |
|
{ |
| 550 |
|
node = smgr.AddMeshSceneNode(vObj.mesh, smgr.RootSceneNode, (int)vObj.prim.LocalID); |
| 551 |
|
creatednode = true; |
| 552 |
vObj.node = node; |
vObj.node = node; |
| 553 |
|
} |
| 554 |
|
else |
| 555 |
|
{ |
| 556 |
|
node = vObj.node; |
| 557 |
|
} |
| 558 |
|
|
| 559 |
//parentObj.node.AddChild(node); |
//parentObj.node.AddChild(node); |
| 560 |
node.Scale = new Vector3D(vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y); |
node.Scale = new Vector3D(vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y); |
| 561 |
|
|
| 562 |
//m_log.WarnFormat("[SCALE]: <{0},{1},{2}> = <{3},{4},{5}>", vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y, parentObj.node.Scale.X, parentObj.node.Scale.Y, parentObj.node.Scale.Z); |
//m_log.WarnFormat("[SCALE]: <{0},{1},{2}> = <{3},{4},{5}>", vObj.prim.Scale.X, vObj.prim.Scale.Z, vObj.prim.Scale.Y, parentObj.node.Scale.X, parentObj.node.Scale.Y, parentObj.node.Scale.Z); |
| 563 |
|
|
| 564 |
node.Position = new Vector3D(WorldoffsetPos.X + parentObj.prim.Position.X + vObj.prim.Position.X, WorldoffsetPos.Z + parentObj.prim.Position.Z + vObj.prim.Position.Z, WorldoffsetPos.Y + parentObj.prim.Position.Y + vObj.prim.Position.Y); |
node.Position = new Vector3D(WorldoffsetPos.X + parentObj.prim.Position.X + vObj.prim.Position.X, WorldoffsetPos.Z + parentObj.prim.Position.Z + vObj.prim.Position.Z, WorldoffsetPos.Y + parentObj.prim.Position.Y + vObj.prim.Position.Y); |
| 565 |
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
|
| 566 |
//m_log.Warn(vObj.prim.Rotation.ToString()); |
//m_log.Warn(vObj.prim.Rotation.ToString()); |
| 567 |
IrrlichtNETCP.Quaternion iqu = new IrrlichtNETCP.Quaternion(vObj.prim.Rotation.X, vObj.prim.Rotation.Z, vObj.prim.Rotation.Y, vObj.prim.Rotation.W); |
IrrlichtNETCP.Quaternion iqu = new IrrlichtNETCP.Quaternion(vObj.prim.Rotation.X, vObj.prim.Rotation.Z, vObj.prim.Rotation.Y, vObj.prim.Rotation.W); |
| 568 |
iqu.makeInverse(); |
iqu.makeInverse(); |
| 579 |
|
|
| 580 |
node.Rotation = finalpos.Matrix.RotationDegrees; |
node.Rotation = finalpos.Matrix.RotationDegrees; |
| 581 |
|
|
| 582 |
node.UpdateAbsolutePosition(); |
if (creatednode) |
| 583 |
|
{ |
| 584 |
|
|
| 585 |
|
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
| 586 |
node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
| 587 |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false); |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false); |
| 588 |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
| 592 |
{ |
{ |
| 593 |
mts.AddTriangleSelector(trisel); |
mts.AddTriangleSelector(trisel); |
| 594 |
} |
} |
| 595 |
|
} |
| 596 |
|
|
| 597 |
|
node.UpdateAbsolutePosition(); |
| 598 |
} |
} |
| 599 |
else |
else |
| 600 |
{ |
{ |
| 825 |
avatarConnection.OnGridConnected += connectedCallback; |
avatarConnection.OnGridConnected += connectedCallback; |
| 826 |
avatarConnection.OnNewPrim += newPrimCallback; |
avatarConnection.OnNewPrim += newPrimCallback; |
| 827 |
avatarConnection.OnSimConnected += SimConnectedCallback; |
avatarConnection.OnSimConnected += SimConnectedCallback; |
| 828 |
|
avatarConnection.OnObjectUpdated += objectUpdatedCallback; |
| 829 |
|
avatarConnection.OnObjectKilled += objectKilledCallback; |
| 830 |
|
|
| 831 |
|
|
| 832 |
IrrlichtNETCP.Matrix4 m4 = new IrrlichtNETCP.Matrix4(); |
IrrlichtNETCP.Matrix4 m4 = new IrrlichtNETCP.Matrix4(); |
| 980 |
|
|
| 981 |
} |
} |
| 982 |
} |
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 983 |
} |
} |
| 984 |
|
|
| 985 |
#region LibOMV Callbacks |
#region LibOMV Callbacks |
| 989 |
{ |
{ |
| 990 |
//System.Console.WriteLine(prim.ToString()); |
//System.Console.WriteLine(prim.ToString()); |
| 991 |
//return; |
//return; |
| 992 |
VObject newObject = new VObject(); |
VObject newObject = null; |
| 993 |
|
|
| 994 |
|
//bool foundEntity = false; |
| 995 |
|
|
| 996 |
|
lock (Entities) |
| 997 |
|
{ |
| 998 |
|
if (Entities.ContainsKey(regionHandle.ToString() + prim.LocalID.ToString())) |
| 999 |
|
{ |
| 1000 |
|
//foundEntity = true; |
| 1001 |
|
newObject = Entities[regionHandle.ToString() + prim.LocalID.ToString()]; |
| 1002 |
|
} |
| 1003 |
|
} |
| 1004 |
|
if (newObject != null) |
| 1005 |
|
{ |
| 1006 |
|
if (newObject.node != null) |
| 1007 |
|
{ |
| 1008 |
|
smgr.AddToDeletionQueue(newObject.node); |
| 1009 |
|
newObject.node = null; |
| 1010 |
|
} |
| 1011 |
|
|
| 1012 |
|
} |
| 1013 |
|
|
| 1014 |
lock (mesh_synclock) |
lock (mesh_synclock) |
| 1015 |
{ |
{ |
| 1016 |
newObject = VUtil.NewVObject(prim); |
newObject = VUtil.NewVObject(prim,newObject); |
| 1017 |
} |
} |
| 1018 |
|
|
| 1019 |
if (prim.ParentID != 0) |
if (prim.ParentID != 0) |
| 1220 |
} |
} |
| 1221 |
} |
} |
| 1222 |
|
|
| 1223 |
|
private void objectUpdatedCallback(Simulator simulator, ObjectUpdate update, ulong regionHandle, |
| 1224 |
|
ushort timeDilation) |
| 1225 |
|
{ |
| 1226 |
|
VObject obj = null; |
| 1227 |
|
if (!update.Avatar) |
| 1228 |
|
{ |
| 1229 |
|
lock (Entities) |
| 1230 |
|
{ |
| 1231 |
|
if (Entities.ContainsKey(regionHandle.ToString() + update.LocalID.ToString())) |
| 1232 |
|
{ |
| 1233 |
|
obj = Entities[regionHandle.ToString() + update.LocalID.ToString()]; |
| 1234 |
|
obj.prim.Acceleration = update.Acceleration; |
| 1235 |
|
obj.prim.AngularVelocity = update.AngularVelocity; |
| 1236 |
|
obj.prim.CollisionPlane = update.CollisionPlane; |
| 1237 |
|
obj.prim.Position = update.Position; |
| 1238 |
|
obj.prim.Rotation = update.Rotation; |
| 1239 |
|
obj.prim.PrimData.State = update.State; |
| 1240 |
|
obj.prim.Textures = update.Textures; |
| 1241 |
|
obj.prim.Velocity = update.Velocity; |
| 1242 |
|
Entities[regionHandle.ToString() + update.LocalID.ToString()] = obj; |
| 1243 |
|
} |
| 1244 |
|
} |
| 1245 |
|
if (obj != null) |
| 1246 |
|
enqueueVObject(obj); |
| 1247 |
|
} |
| 1248 |
|
} |
| 1249 |
|
private void objectKilledCallback(Simulator psim, uint pLocalID) |
| 1250 |
|
{ |
| 1251 |
|
ulong regionHandle = psim.Handle; |
| 1252 |
|
m_log.Debug("[DELETE]: obj " + regionHandle.ToString() + ":" + pLocalID.ToString()); |
| 1253 |
|
lock (Entities) |
| 1254 |
|
{ |
| 1255 |
|
if (Entities.ContainsKey(regionHandle.ToString() + pLocalID.ToString())) |
| 1256 |
|
{ |
| 1257 |
|
VObject obj = Entities[regionHandle.ToString() + pLocalID.ToString()]; |
| 1258 |
|
if (obj.node != null) |
| 1259 |
|
{ |
| 1260 |
|
smgr.AddToDeletionQueue(obj.node); |
| 1261 |
|
obj.node = null; |
| 1262 |
|
} |
| 1263 |
|
Entities.Remove(regionHandle.ToString() + pLocalID.ToString()); |
| 1264 |
|
} |
| 1265 |
|
} |
| 1266 |
|
} |
| 1267 |
#endregion |
#endregion |
| 1268 |
|
|
| 1269 |
#region KeyActions |
#region KeyActions |