| 37 |
private static MetaTriangleSelector mts; |
private static MetaTriangleSelector mts; |
| 38 |
|
|
| 39 |
private static Queue<VObject> objectModQueue = new Queue<VObject>(); |
private static Queue<VObject> objectModQueue = new Queue<VObject>(); |
| 40 |
|
private static Queue<VObject> objectMeshQueue = new Queue<VObject>(); |
| 41 |
|
|
| 42 |
private static Queue<VObject> UnAssignedChildObjectModQueue = new Queue<VObject>(); |
private static Queue<VObject> UnAssignedChildObjectModQueue = new Queue<VObject>(); |
| 43 |
private static Queue<TextureComplete> assignTextureQueue = new Queue<TextureComplete>(); |
private static Queue<TextureComplete> assignTextureQueue = new Queue<TextureComplete>(); |
| 44 |
|
|
| 353 |
UpdateTerrain(); |
UpdateTerrain(); |
| 354 |
//cam.Position = new Vector3D(cam.Position.X , cam.Position.Y, cam.Position.Z- 0.5f); |
//cam.Position = new Vector3D(cam.Position.X , cam.Position.Y, cam.Position.Z- 0.5f); |
| 355 |
//cam.Target = new Vector3D(0, 0, 0);//cam.Target.X - 0.5f, cam.Target.Y, cam.Target.Z); |
//cam.Target = new Vector3D(0, 0, 0);//cam.Target.X - 0.5f, cam.Target.Y, cam.Target.Z); |
| 356 |
|
|
| 357 |
driver.BeginScene(true, true, new Color(255, 100, 101, 140)); |
driver.BeginScene(true, true, new Color(255, 100, 101, 140)); |
| 358 |
smgr.DrawAll(); |
smgr.DrawAll(); |
| 359 |
guienv.DrawAll(); |
guienv.DrawAll(); |
| 364 |
Color.Red); |
Color.Red); |
| 365 |
//m_log.Debug(driver.FPS); |
//m_log.Debug(driver.FPS); |
| 366 |
driver.EndScene(); |
driver.EndScene(); |
| 367 |
|
|
| 368 |
mscounter += System.Environment.TickCount - tickcount; |
mscounter += System.Environment.TickCount - tickcount; |
| 369 |
msreset = 55; |
msreset = 55; |
| 370 |
// |
// |
| 383 |
} |
} |
| 384 |
if ((framecounter % objectmods) == 0) |
if ((framecounter % objectmods) == 0) |
| 385 |
{ |
{ |
| 386 |
|
doProcessMesh(5); |
| 387 |
doObjectMods(5); |
doObjectMods(5); |
| 388 |
CheckAndApplyParent(5); |
CheckAndApplyParent(5); |
| 389 |
doTextureMods(); |
doTextureMods(); |
| 492 |
} |
} |
| 493 |
private void doSetCameraPosition() |
private void doSetCameraPosition() |
| 494 |
{ |
{ |
| 495 |
|
Vector3[] camdata = cam.GetCameraLookAt(); |
| 496 |
|
|
| 497 |
avatarConnection.SetCameraPosition(cam.Position); |
avatarConnection.SetCameraPosition(camdata[0],camdata[1]); |
| 498 |
} |
} |
| 499 |
|
|
| 500 |
|
|
| 629 |
} |
} |
| 630 |
else |
else |
| 631 |
{ |
{ |
| 632 |
|
if (vObj.mesh == null) |
| 633 |
|
continue; |
| 634 |
node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
| 635 |
|
if (node == null) |
| 636 |
|
continue; |
| 637 |
creatednode = true; |
creatednode = true; |
| 638 |
vObj.node = node; |
vObj.node = node; |
| 639 |
} |
} |
| 683 |
if (node.Raw == IntPtr.Zero) |
if (node.Raw == IntPtr.Zero) |
| 684 |
continue; |
continue; |
| 685 |
// ROTATION |
// ROTATION |
| 686 |
|
if (vObj == null || parentObj == null) |
| 687 |
|
continue; |
| 688 |
|
if (vObj.prim == null || parentObj.prim == null) |
| 689 |
|
continue; |
| 690 |
vObj.prim.Position = vObj.prim.Position * parentObj.prim.Rotation; |
vObj.prim.Position = vObj.prim.Position * parentObj.prim.Rotation; |
| 691 |
vObj.prim.Rotation = parentObj.prim.Rotation * vObj.prim.Rotation; |
vObj.prim.Rotation = parentObj.prim.Rotation * vObj.prim.Rotation; |
| 692 |
|
|
| 949 |
} |
} |
| 950 |
} |
} |
| 951 |
} |
} |
| 952 |
|
|
| 953 |
|
public void doProcessMesh(int pObjects) |
| 954 |
|
{ |
| 955 |
|
for (int i = 0; i < pObjects; i++) |
| 956 |
|
{ |
| 957 |
|
VObject vobj = null; |
| 958 |
|
lock (objectMeshQueue) |
| 959 |
|
{ |
| 960 |
|
if (objectMeshQueue.Count == 0) |
| 961 |
|
break; |
| 962 |
|
vobj = objectMeshQueue.Dequeue(); |
| 963 |
|
} |
| 964 |
|
|
| 965 |
|
|
| 966 |
|
vobj.mesh = PrimMesherG.PrimitiveToIrrMesh(vobj.prim); |
| 967 |
|
if (vobj.prim.Textures != null) |
| 968 |
|
{ |
| 969 |
|
if (vobj.prim.Textures.DefaultTexture != null) |
| 970 |
|
{ |
| 971 |
|
|
| 972 |
|
Color4 coldata = vobj.prim.Textures.DefaultTexture.RGBA; |
| 973 |
|
if (coldata != Color4.White) |
| 974 |
|
{ |
| 975 |
|
Mesh coolmesh = smgr.MeshManipulator.CreateMeshWithTangents(vobj.mesh); |
| 976 |
|
vobj.mesh = coolmesh; |
| 977 |
|
if (coldata.R != 1f || coldata.B != 1f || coldata.G != 1f) |
| 978 |
|
{ |
| 979 |
|
smgr.MeshManipulator.SetVertexColors(vobj.mesh, new Color((int)(coldata.A * 255), (int)(coldata.R * 255), (int)(coldata.G * 255), (int)(coldata.B * 255))); |
| 980 |
|
} |
| 981 |
|
if (coldata.A != 1f) |
| 982 |
|
{ |
| 983 |
|
smgr.MeshManipulator.SetVertexColorAlpha(vobj.mesh,(int)(coldata.A * 256f)); |
| 984 |
|
} |
| 985 |
|
} |
| 986 |
|
|
| 987 |
|
} |
| 988 |
|
} |
| 989 |
|
ulong regionHandle = vobj.prim.RegionHandle; |
| 990 |
|
|
| 991 |
|
if (vobj.prim.ParentID != 0) |
| 992 |
|
{ |
| 993 |
|
bool foundEntity = false; |
| 994 |
|
|
| 995 |
|
lock (Entities) |
| 996 |
|
{ |
| 997 |
|
if (!Entities.ContainsKey(regionHandle.ToString() + vobj.prim.ParentID.ToString())) |
| 998 |
|
{ |
| 999 |
|
UnAssignedChildObjectModQueue.Enqueue(vobj); |
| 1000 |
|
} |
| 1001 |
|
else |
| 1002 |
|
{ |
| 1003 |
|
foundEntity = true; |
| 1004 |
|
} |
| 1005 |
|
} |
| 1006 |
|
|
| 1007 |
|
if (foundEntity) |
| 1008 |
|
{ |
| 1009 |
|
vobj.updateFullYN = true; |
| 1010 |
|
enqueueVObject(vobj); |
| 1011 |
|
} |
| 1012 |
|
} |
| 1013 |
|
else |
| 1014 |
|
{ |
| 1015 |
|
vobj.updateFullYN = true; |
| 1016 |
|
enqueueVObject(vobj); |
| 1017 |
|
} |
| 1018 |
|
} |
| 1019 |
|
|
| 1020 |
|
} |
| 1021 |
#endregion |
#endregion |
| 1022 |
|
|
| 1023 |
|
|
| 1408 |
|
|
| 1409 |
#region LibOMV Callbacks |
#region LibOMV Callbacks |
| 1410 |
|
|
| 1411 |
|
|
| 1412 |
|
|
| 1413 |
|
|
| 1414 |
public void newPrimCallback(Simulator sim, Primitive prim, ulong regionHandle, |
public void newPrimCallback(Simulator sim, Primitive prim, ulong regionHandle, |
| 1415 |
ushort timeDilation) |
ushort timeDilation) |
| 1416 |
{ |
{ |
| 1438 |
|
|
| 1439 |
} |
} |
| 1440 |
|
|
| 1441 |
lock (mesh_synclock) |
|
|
{ |
|
| 1442 |
newObject = VUtil.NewVObject(prim,newObject); |
newObject = VUtil.NewVObject(prim,newObject); |
|
} |
|
| 1443 |
|
|
|
if (prim.ParentID != 0) |
|
|
{ |
|
|
bool foundEntity = false; |
|
| 1444 |
|
|
|
lock (Entities) |
|
|
{ |
|
|
if (!Entities.ContainsKey(regionHandle.ToString() + prim.ParentID.ToString())) |
|
|
{ |
|
|
UnAssignedChildObjectModQueue.Enqueue(newObject); |
|
|
} |
|
|
else |
|
|
{ |
|
|
foundEntity = true; |
|
|
} |
|
|
} |
|
| 1445 |
|
|
| 1446 |
if (foundEntity) |
|
| 1447 |
{ |
lock (objectMeshQueue) |
|
newObject.updateFullYN = true; |
|
|
enqueueVObject(newObject); |
|
|
} |
|
|
} |
|
|
else |
|
| 1448 |
{ |
{ |
| 1449 |
newObject.updateFullYN = true; |
objectMeshQueue.Enqueue(newObject); |
|
enqueueVObject(newObject); |
|
| 1450 |
} |
} |
| 1451 |
|
|
| 1452 |
} |
} |