Kronos Posted November 4, 2010 Share Posted November 4, 2010 Using the method of cycling through all child entities of the scene will only return terrain as an entity. How can I get it as a terrain. I need to be able to access the terrain to retrieve height information via terrainelevation(). This code doesn't work because you can't cast from entity to terrain. Local Myscene:TEntity = loadscene("media\myscene2.sbx"); Local ent:TEntity Local terrain:TTerrain DebugLog "countChildren = "+CountChildren(myscene) For i = 1 To CountChildren(myscene) ent = GetChild(myscene,i) If GetEntityKey(ent,"class") = "Terrain" Then terrain=ent <--no good!! Next Thanks in advance. Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit Link to comment Share on other sites More sharing options...
Flexman Posted November 4, 2010 Share Posted November 4, 2010 Try casting, like this? If GetEntityKey(ent,"class") = "Terrain" Then terrain=TTerrain(ent) Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
macklebee Posted November 4, 2010 Share Posted November 4, 2010 yes that should work... i was confirming that exact code myself when you replied Flexman, and it appears to work... or at least doesn't cause errors... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Flexman Posted November 4, 2010 Share Posted November 4, 2010 Casting is how I get to the loaded map layers for generating an overhead map, and this is how Josh does it in the editor too. So it's prety safe. Local cmap:TBuffer = TTerrain(game.scene.terrain).colormapbuffer; TTerrain(game.scene.terrain).normaltexture.Bind(1) ; SetShader(map_shader) ; ... ... DrawImage(cmap.colorbuffer[0], 0, TSD_MAPSIZE, TSD_MAPSIZE, -TSD_MAPSIZE) ; You can get the heightmap and mapsize goodies too. So it's very handy. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
macklebee Posted November 4, 2010 Share Posted November 4, 2010 nice... very handy... now please list how you coded the rest of combat helo in detail Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Kronos Posted November 4, 2010 Author Share Posted November 4, 2010 Confirmed that works fine for me. Thanks folks Quote intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.