| 43 |
private static Queue<TextureComplete> assignTextureQueue = new Queue<TextureComplete>(); |
private static Queue<TextureComplete> assignTextureQueue = new Queue<TextureComplete>(); |
| 44 |
|
|
| 45 |
private static Dictionary<string, VObject> interpolationTargets = new Dictionary<string, VObject>(); |
private static Dictionary<string, VObject> interpolationTargets = new Dictionary<string, VObject>(); |
| 46 |
|
private static SkinnedMesh avmeshtest = null; |
| 47 |
|
private static AnimatedMeshSceneNode avmeshsntest = null; |
| 48 |
|
|
| 49 |
private static Simulator currentSim; |
private static Simulator currentSim; |
| 50 |
|
|
| 261 |
// new Rect(new Position2D(10, 10), new Dimension2D(200, 22)), true, false, guienv.RootElement, -1, false); |
// new Rect(new Position2D(10, 10), new Dimension2D(200, 22)), true, false, guienv.RootElement, -1, false); |
| 262 |
//Image img = |
//Image img = |
| 263 |
// |
// |
| 264 |
|
smgr.VideoDriver.AmbientLight = new Color(255, 128, 128, 128); |
| 265 |
|
|
| 266 |
|
//driver. |
| 267 |
|
smgr.VideoDriver.SetFog(new Color(0, 255, 255, 255), false, 9999, 9999, 0, false, false); |
| 268 |
|
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, false); |
| 269 |
|
|
| 270 |
|
smgr.AddSkyBoxSceneNode(null, new Texture[] { |
| 271 |
|
driver.GetTexture("irrlicht2_up.jpg"), |
| 272 |
|
driver.GetTexture("irrlicht2_dn.jpg"), |
| 273 |
|
driver.GetTexture("irrlicht2_rt.jpg"), |
| 274 |
|
driver.GetTexture("irrlicht2_lf.jpg"), |
| 275 |
|
driver.GetTexture("irrlicht2_ft.jpg"), |
| 276 |
|
driver.GetTexture("irrlicht2_bk.jpg")}, 0); |
| 277 |
|
|
| 278 |
|
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); |
| 279 |
|
|
| 280 |
cam = new Camera(smgr); |
cam = new Camera(smgr); |
| 281 |
|
|
| 282 |
smgr.VideoDriver.AmbientLight = new Color(255, 128, 128, 128); |
|
| 283 |
|
|
| 284 |
|
|
| 285 |
//AnimatedMesh mesh = smgr.GetMesh("sydney.md2"); |
//AnimatedMesh mesh = smgr.GetMesh("sydney.md2"); |
| 294 |
// node.Position = new Vector3D(128, 32, 128); |
// node.Position = new Vector3D(128, 32, 128); |
| 295 |
//} |
//} |
| 296 |
//we add the skybox which we already used in lots of Irrlicht examples. |
//we add the skybox which we already used in lots of Irrlicht examples. |
|
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, false); |
|
|
|
|
|
smgr.AddSkyBoxSceneNode(null, new Texture[] { |
|
|
driver.GetTexture("irrlicht2_up.jpg"), |
|
|
driver.GetTexture("irrlicht2_dn.jpg"), |
|
|
driver.GetTexture("irrlicht2_rt.jpg"), |
|
|
driver.GetTexture("irrlicht2_lf.jpg"), |
|
|
driver.GetTexture("irrlicht2_ft.jpg"), |
|
|
driver.GetTexture("irrlicht2_bk.jpg")}, 0); |
|
| 297 |
|
|
|
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); |
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 340 |
//GUIToolBar gtb = guienv.AddToolBar(guienv.RootElement, 91); |
//GUIToolBar gtb = guienv.AddToolBar(guienv.RootElement, 91); |
| 341 |
//gtb.Text = "Hi"; |
//gtb.Text = "Hi"; |
| 342 |
//gtb.AddButton(92, "Button", "Click", null, null, true, false); |
//gtb.AddButton(92, "Button", "Click", null, null, true, false); |
| 343 |
|
/* |
| 344 |
|
AnimatedMesh av = smgr.GetMesh("Female.x"); |
| 345 |
|
|
| 346 |
|
//int mbcount = av.GetMesh(0).MeshBufferCount; |
| 347 |
|
for (int j = 0; j < mbcount; j++) |
| 348 |
|
{ |
| 349 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.Texture1 = driver.GetTexture("Green_Grass_Detailed.tga"); |
| 350 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.SpecularColor = new Color(255, 150, 150, 150); |
| 351 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.AmbientColor = new Color(255, 110, 110, 110); |
| 352 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.EmissiveColor = new Color(255, 125, 125, 125); |
| 353 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.Shininess = 0.80f; |
| 354 |
|
} |
| 355 |
|
//SkinnedMesh sm = new SkinnedMesh(av.Raw); |
| 356 |
|
//sm. |
| 357 |
|
//sm.SkinMesh(); |
| 358 |
|
//sm.AnimateMesh(0, 0); |
| 359 |
|
|
| 360 |
|
|
| 361 |
|
avmeshsntest = smgr.AddAnimatedMeshSceneNode(av); |
| 362 |
|
//avmeshsntest.JointMode = JointUpdateOnRenderMode.Read; |
| 363 |
|
avmeshsntest.SetMaterialFlag(MaterialFlag.NormalizeNormals,true); |
| 364 |
|
|
| 365 |
|
|
| 366 |
|
|
| 367 |
|
//BoneSceneNode avb = avm.GetXJointNode(1); |
| 368 |
|
avmeshsntest.Position = new Vector3D(125, 37, 125); |
| 369 |
|
avmeshsntest.Scale = new Vector3D(15, 15, 15); |
| 370 |
|
avmeshsntest.Rotation = new Vector3D(0, 90, 0); |
| 371 |
|
//avmeshsntest.UpdateAbsolutePosition(); |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
//SkinnedMesh smm = new SkinnedMesh(avm.AnimatedMesh.Raw); |
| 375 |
|
//smm.SkinMesh(); |
| 376 |
|
*/ |
| 377 |
int minFrameTime = (int)(1.0f / maxFPS); |
int minFrameTime = (int)(1.0f / maxFPS); |
| 378 |
bool running = true; |
bool running = true; |
| 379 |
while (running) |
while (running) |
| 393 |
UpdateTerrain(); |
UpdateTerrain(); |
| 394 |
//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); |
| 395 |
//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); |
| 396 |
|
//avm.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
| 397 |
|
//avm.SetMaterialTexture(0,driver.GetTexture("Green_Grass_Detailed.tga")); |
| 398 |
|
//avb |
| 399 |
|
//avm.AnimatedMesh.GetMesh(0).GetMeshBuffer(0).GetVertex(0).TCoords |
| 400 |
|
/* |
| 401 |
|
* |
| 402 |
|
avmeshsntest.AnimationSpeed = 8; |
| 403 |
|
avmeshsntest.SetFrameLoop(0, 1); |
| 404 |
|
avmeshsntest.AnimateJoints(true); |
| 405 |
|
avmeshsntest.AutomaticCulling = CullingType.Off; |
| 406 |
|
avmeshsntest.CurrentFrame = 1; |
| 407 |
|
//avmeshsntest.DebugDataVisible = DebugSceneType.Full; |
| 408 |
|
avmeshsntest.LoopMode = true; |
| 409 |
|
|
| 410 |
|
BoneSceneNode bcn = avmeshsntest.GetJointNode("chest:2"); |
| 411 |
|
bcn.AutomaticCulling = CullingType.Off; |
| 412 |
|
bcn.DebugDataVisible = DebugSceneType.Full; |
| 413 |
|
|
| 414 |
|
bcn.AnimationMode = AnimationMode.Unanimated; |
| 415 |
|
Vector3D rot = bcn.Rotation; |
| 416 |
|
rot.X = 9; |
| 417 |
|
bcn.Rotation = rot; |
| 418 |
|
//bcn.RotationHint = 5; |
| 419 |
|
|
| 420 |
|
bcn.UpdateAbsolutePositionOfAllChildren(); |
| 421 |
|
|
| 422 |
|
avmeshsntest.AnimateJoints(false); |
| 423 |
|
*/ |
| 424 |
driver.BeginScene(true, true, new Color(255, 100, 101, 140)); |
driver.BeginScene(true, true, new Color(255, 100, 101, 140)); |
| 425 |
smgr.DrawAll(); |
smgr.DrawAll(); |
| 426 |
guienv.DrawAll(); |
guienv.DrawAll(); |
| 562 |
break; |
break; |
| 563 |
|
|
| 564 |
tx = assignTextureQueue.Dequeue(); |
tx = assignTextureQueue.Dequeue(); |
| 565 |
tex = (TextureExtended)driver.GetTexture(tx.texture); |
tex = new TextureExtended(driver.GetTexture(tx.texture).Raw); |
| 566 |
} |
} |
| 567 |
|
|
| 568 |
if (tx.node != null && tex != null) |
if (tx.node != null && tex != null) |
| 702 |
node = vObj.node; |
node = vObj.node; |
| 703 |
} |
} |
| 704 |
|
|
| 705 |
//node.Scale = new Vector3D(0.035f, 0.035f, 0.035f); |
node.Scale = new Vector3D(0.035f, 0.035f, 0.035f); |
| 706 |
node.Scale = new Vector3D(15f, 15f, 15f); |
//node.Scale = new Vector3D(15f, 15f, 15f); |
| 707 |
if (!isTextured) |
if (!isTextured) |
| 708 |
node.SetMaterialTexture(0, driver.GetTexture(avatarMaterial)); |
node.SetMaterialTexture(0, driver.GetTexture(avatarMaterial)); |
| 709 |
node.SetMaterialFlag(MaterialFlag.Lighting, true); |
node.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 932 |
{ |
{ |
| 933 |
if (vObj.prim is Avatar) |
if (vObj.prim is Avatar) |
| 934 |
{ |
{ |
| 935 |
|
|
| 936 |
AnimatedMesh avmesh = smgr.GetMesh("sydney.md2"); |
AnimatedMesh avmesh = smgr.GetMesh("sydney.md2"); |
| 937 |
|
|
| 938 |
AnimatedMeshSceneNode node2 = smgr.AddAnimatedMeshSceneNode(avmesh); |
AnimatedMeshSceneNode node2 = smgr.AddAnimatedMeshSceneNode(avmesh); |
| 939 |
node = node2; |
node = node2; |
| 940 |
|
node.Scale = new Vector3D(0.035f, 0.035f, 0.035f); |
| 941 |
vObj.node = node2; |
vObj.node = node2; |
| 942 |
|
|
| 943 |
lock (interpolationTargets) |
lock (interpolationTargets) |
| 1475 |
} |
} |
| 1476 |
terrain = smgr.AddTerrainSceneNode( |
terrain = smgr.AddTerrainSceneNode( |
| 1477 |
filename, smgr.RootSceneNode, -1, |
filename, smgr.RootSceneNode, -1, |
| 1478 |
new Vector3D(relTerrainPos.X - 4f, relTerrainPos.Z, relTerrainPos.Y + 16f), new Vector3D(0, 270, 0), new Vector3D(1, 1, 1), new Color(255, 255, 255, 255), 3, TerrainPatchSize.TPS17); |
new Vector3D(relTerrainPos.X - 4f, relTerrainPos.Z, relTerrainPos.Y + 16f), new Vector3D(0, 270, 0), new Vector3D(1, 1, 1), new Color(255, 255, 255, 255), 2, TerrainPatchSize.TPS17); |
| 1479 |
//device.FileSystem.WorkingDirectory = "./media/"; |
//device.FileSystem.WorkingDirectory = "./media/"; |
| 1480 |
terrain.SetMaterialFlag(MaterialFlag.Lighting, true); |
terrain.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 1481 |
terrain.SetMaterialType(MaterialType.DetailMap); |
terrain.SetMaterialType(MaterialType.DetailMap); |