| 278 |
driver.GetTexture("irrlicht2_bk.jpg")}, 0); |
driver.GetTexture("irrlicht2_bk.jpg")}, 0); |
| 279 |
|
|
| 280 |
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); |
driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); |
| 281 |
|
SceneNode tree = smgr.AddTreeSceneNode("Oak.xml", null, -1, new Vector3D(128, 40, 128), new Vector3D(0, 0, 0), new Vector3D(0.25f, 0.25f, 0.25f), driver.GetTexture("OakBark.png"), driver.GetTexture("OakLeaf.png"), driver.GetTexture("OakBillboard.png")); |
| 282 |
|
tree.Position = new Vector3D(128, 20, 128); |
| 283 |
|
//tree.Scale = new Vector3D(0.25f, 0.25f, 0.25f); |
| 284 |
cam = new Camera(smgr); |
cam = new Camera(smgr); |
| 285 |
|
|
| 286 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
SceneNode light = smgr.AddLightSceneNode(smgr.RootSceneNode, new Vector3D(0, 0, 0), new Colorf(1, 1, 1, 1), 90, -1); |
SceneNode light = smgr.AddLightSceneNode(smgr.RootSceneNode, new Vector3D(0, 0, 0), new Colorf(1, 0.5f, 0.5f, 0.5f), 90, -1); |
| 306 |
Animator anim = smgr.CreateFlyCircleAnimator(new Vector3D(128, 250, 128), 250.0f, 0.0010f); |
Animator anim = smgr.CreateFlyCircleAnimator(new Vector3D(128, 250, 128), 250.0f, 0.0010f); |
| 307 |
light.AddAnimator(anim); |
light.AddAnimator(anim); |
| 308 |
anim.Dispose(); |
anim.Dispose(); |
| 320 |
// samplePrimNode.SetMaterialFlag(MaterialFlag.Lighting, true); |
// samplePrimNode.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 321 |
//} |
//} |
| 322 |
|
|
| 323 |
|
// dahlia's sample sculpty |
| 324 |
|
|
| 325 |
|
string sculptFileName = "c:\\sampleSculpty.bmp"; |
| 326 |
|
try |
| 327 |
|
{ |
| 328 |
|
Mesh samplePrim = null; |
| 329 |
|
System.Drawing.Image image = System.Drawing.Bitmap.FromFile(sculptFileName); |
| 330 |
|
|
| 331 |
|
samplePrim = PrimMesherG.SculptIrrMesh((System.Drawing.Bitmap)image); |
| 332 |
|
if (samplePrim != null) |
| 333 |
|
{ |
| 334 |
|
SceneNode samplePrimNode = smgr.AddMeshSceneNode(samplePrim, smgr.RootSceneNode, -1); |
| 335 |
|
samplePrimNode.Position = new Vector3D(128, 32, 128); |
| 336 |
|
samplePrimNode.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 337 |
|
} |
| 338 |
|
} |
| 339 |
|
catch (Exception e) |
| 340 |
|
{ |
| 341 |
|
m_log.Error("Unable to open sample sculpty file: " + sculptFileName, e); |
| 342 |
|
} |
| 343 |
|
|
| 344 |
//generateRandomPrim(4000); |
//generateRandomPrim(4000); |
| 345 |
AnimatedMesh mesh = smgr.AddHillPlaneMesh("myHill", |
AnimatedMesh mesh = smgr.AddHillPlaneMesh("myHill", |
| 346 |
new Dimension2Df(120, 120), |
new Dimension2Df(120, 120), |
| 371 |
int mbcount = av.GetMesh(0).MeshBufferCount; |
int mbcount = av.GetMesh(0).MeshBufferCount; |
| 372 |
for (int j = 0; j < mbcount; j++) |
for (int j = 0; j < mbcount; j++) |
| 373 |
{ |
{ |
| 374 |
av.GetMesh(0).GetMeshBuffer(j).Material.Texture1 = driver.GetTexture("Green_Grass_Detailed.tga"); |
Texture texDriver = driver.GetTexture(j.ToString() + "-" + avatarMaterial); |
| 375 |
|
if (texDriver != null) |
| 376 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.Texture1 = texDriver; |
| 377 |
|
else |
| 378 |
|
av.GetMesh(0).GetMeshBuffer(j).Material.Texture1 = driver.GetTexture(avatarMaterial); |
| 379 |
|
|
| 380 |
av.GetMesh(0).GetMeshBuffer(j).Material.SpecularColor = new Color(255, 150, 150, 150); |
av.GetMesh(0).GetMeshBuffer(j).Material.SpecularColor = new Color(255, 150, 150, 150); |
| 381 |
av.GetMesh(0).GetMeshBuffer(j).Material.AmbientColor = new Color(255, 110, 110, 110); |
av.GetMesh(0).GetMeshBuffer(j).Material.AmbientColor = new Color(255, 110, 110, 110); |
| 382 |
av.GetMesh(0).GetMeshBuffer(j).Material.EmissiveColor = new Color(255, 125, 125, 125); |
av.GetMesh(0).GetMeshBuffer(j).Material.EmissiveColor = new Color(255, 125, 125, 125); |
| 384 |
} |
} |
| 385 |
smgr.MeshManipulator.FlipSurfaces(av.GetMesh(0)); |
smgr.MeshManipulator.FlipSurfaces(av.GetMesh(0)); |
| 386 |
|
|
|
|
|
|
|
|
| 387 |
avmeshsntest = smgr.AddAnimatedMeshSceneNode(av); |
avmeshsntest = smgr.AddAnimatedMeshSceneNode(av); |
| 388 |
avmeshsntest.JointMode = JointUpdateOnRenderMode.Control; |
avmeshsntest.JointMode = JointUpdateOnRenderMode.Control; |
| 389 |
//avmeshsntest.SetMaterialFlag(MaterialFlag.NormalizeNormals,true); |
//avmeshsntest.SetMaterialFlag(MaterialFlag.NormalizeNormals,true); |
| 623 |
tex = new TextureExtended(driver.GetTexture(tx.texture).Raw); |
tex = new TextureExtended(driver.GetTexture(tx.texture).Raw); |
| 624 |
} |
} |
| 625 |
|
|
| 626 |
if (tx.node != null && tex != null) |
if (tx.vObj != null && tex != null) |
| 627 |
{ |
{ |
| 628 |
textureMan.applyTexture(tex, tx.node); |
textureMan.applyTexture(tex, tx.vObj, tx.textureID); |
| 629 |
} |
} |
| 630 |
} |
} |
| 631 |
|
|
| 799 |
{ |
{ |
| 800 |
if (vObj.mesh == null) |
if (vObj.mesh == null) |
| 801 |
continue; |
continue; |
| 802 |
|
if (vObj.updateFullYN) |
| 803 |
|
{ |
| 804 |
node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
node = smgr.AddMeshSceneNode(vObj.mesh, parentNode, (int)vObj.prim.LocalID); |
| 805 |
if (node == null) |
|
|
continue; |
|
| 806 |
creatednode = true; |
creatednode = true; |
| 807 |
vObj.node = node; |
vObj.node = node; |
| 808 |
} |
} |
| 809 |
|
else |
| 810 |
|
{ |
| 811 |
|
node = vObj.node; |
| 812 |
|
} |
| 813 |
|
if (node == null) |
| 814 |
|
continue; |
| 815 |
|
} |
| 816 |
|
|
| 817 |
if (node == null && vObj.prim is Avatar) |
if (node == null && vObj.prim is Avatar) |
| 818 |
{ |
{ |
| 911 |
continue; |
continue; |
| 912 |
node.Rotation = finalpos.Matrix.RotationDegrees; |
node.Rotation = finalpos.Matrix.RotationDegrees; |
| 913 |
if (creatednode) |
if (creatednode) |
| 914 |
{ node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
{ |
| 915 |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, backFaceCulling); |
//node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
| 916 |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
//node.SetMaterialFlag(MaterialFlag.BackFaceCulling, backFaceCulling); |
| 917 |
node.SetMaterialFlag(MaterialFlag.Lighting, true); |
//node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
| 918 |
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
//node.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 919 |
|
//node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
| 920 |
|
|
| 921 |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
| 922 |
node.TriangleSelector = trisel; |
node.TriangleSelector = trisel; |
| 932 |
{ |
{ |
| 933 |
UUID textureID = vObj.prim.Textures.DefaultTexture.TextureID; |
UUID textureID = vObj.prim.Textures.DefaultTexture.TextureID; |
| 934 |
if (textureMan != null) |
if (textureMan != null) |
| 935 |
textureMan.RequestImage(textureID, node); |
textureMan.RequestImage(textureID, vObj); |
| 936 |
|
|
| 937 |
} |
} |
| 938 |
} |
} |
| 951 |
if (textureID != UUID.Zero) |
if (textureID != UUID.Zero) |
| 952 |
{ |
{ |
| 953 |
if (textureMan != null) |
if (textureMan != null) |
| 954 |
textureMan.RequestImage(textureID, node); |
textureMan.RequestImage(textureID, vObj); |
| 955 |
} |
} |
| 956 |
} |
} |
| 957 |
} |
} |
| 1070 |
|
|
| 1071 |
if (creatednode) |
if (creatednode) |
| 1072 |
{ |
{ |
| 1073 |
node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
//node.SetMaterialFlag(MaterialFlag.NormalizeNormals, true); |
| 1074 |
node.SetMaterialFlag(MaterialFlag.BackFaceCulling, backFaceCulling); |
//node.SetMaterialFlag(MaterialFlag.BackFaceCulling, backFaceCulling); |
| 1075 |
node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
//node.SetMaterialFlag(MaterialFlag.GouraudShading, true); |
| 1076 |
node.SetMaterialFlag(MaterialFlag.Lighting, true); |
//node.SetMaterialFlag(MaterialFlag.Lighting, true); |
| 1077 |
node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
//node.SetMaterialTexture(0, driver.GetTexture("red_stained_wood.tga")); |
| 1078 |
|
|
| 1079 |
|
|
| 1080 |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
TriangleSelector trisel = smgr.CreateTriangleSelector(vObj.mesh, node); |
| 1091 |
{ |
{ |
| 1092 |
UUID textureID = vObj.prim.Textures.DefaultTexture.TextureID; |
UUID textureID = vObj.prim.Textures.DefaultTexture.TextureID; |
| 1093 |
if (textureMan != null) |
if (textureMan != null) |
| 1094 |
textureMan.RequestImage(textureID, node); |
textureMan.RequestImage(textureID, vObj); |
| 1095 |
|
|
| 1096 |
} |
} |
| 1097 |
} |
} |
| 1107 |
if (textureID != UUID.Zero) |
if (textureID != UUID.Zero) |
| 1108 |
{ |
{ |
| 1109 |
if (textureMan != null) |
if (textureMan != null) |
| 1110 |
textureMan.RequestImage(textureID, node); |
textureMan.RequestImage(textureID, vObj); |
| 1111 |
} |
} |
| 1112 |
} |
} |
| 1113 |
} |
} |
| 2290 |
|
|
| 2291 |
#endregion |
#endregion |
| 2292 |
|
|
| 2293 |
public void textureCompleteCallback(string tex, SceneNode node) |
public void textureCompleteCallback(string tex, VObject vObj, UUID AssetID) |
| 2294 |
{ |
{ |
| 2295 |
TextureComplete tx = new TextureComplete(); |
TextureComplete tx = new TextureComplete(); |
| 2296 |
tx.texture = tex; |
tx.texture = tex; |
| 2297 |
tx.node = node; |
tx.vObj = vObj; |
| 2298 |
|
tx.textureID = AssetID; |
| 2299 |
assignTextureQueue.Enqueue(tx); |
assignTextureQueue.Enqueue(tx); |
| 2300 |
} |
} |
| 2301 |
} |
} |
| 2302 |
|
|
| 2303 |
public struct TextureComplete |
public struct TextureComplete |
| 2304 |
{ |
{ |
| 2305 |
public SceneNode node; |
public VObject vObj; |
| 2306 |
public string texture; |
public string texture; |
| 2307 |
|
public UUID textureID; |
| 2308 |
|
|
| 2309 |
} |
} |
| 2310 |
} |
} |