Clackdor Posted February 26, 2012 Share Posted February 26, 2012 I want to use the TerrainElevation() function. flt TerrainElevation( TEntity terrain, flt x, flt y ) If I have loaded a map using TEntity scene = LoadScene("abstract::pacman.sbx"); How do I access the TEntity terrain reference required as an argument for TerrainElevation? Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 26, 2012 Share Posted February 26, 2012 TTerrain terrain=GetChild(scene,0); Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Clackdor Posted February 26, 2012 Author Share Posted February 26, 2012 I appreciate the answer. Haven't put it in my code yet, but, how did you know that it was the 0 child? I figured it would be a GetChild or FindChild function. I spent about an hour though assuming that I couldn't know the child order, looking for the name of the terrain to use FindChild. Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 26, 2012 Share Posted February 26, 2012 It's always child 0, unless it has been changed. I think also FindChild(scene,"terrain") works, and should be used to ensure future compatibility. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Pixel Perfect Posted February 26, 2012 Share Posted February 26, 2012 I think also FindChild(scene,"terrain") works, and should be used to ensure future compatibility. I does, that's what I've always used. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Clackdor Posted February 26, 2012 Author Share Posted February 26, 2012 Ok, so neither of those is working. In the case of GetChild, I get a reference, but the TerrainElevation function causes a crash, which tells me that it is not returning a TTerrain type, but a different entity. If the case of FindChild, the reference is null, so I'm thinking that "terrain" isn't the correct name to be searching for. Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted February 26, 2012 Share Posted February 26, 2012 I don't have your answer but I'm pretty sure you can't search for a child of a scene. I think that once a scene is created it doesn't have a context any more. But I'm not sure I just recall hearing that somewhere. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Clackdor Posted February 26, 2012 Author Share Posted February 26, 2012 Ok, took another look at this. I used: TTerrain terrain=GetChild(scene,CountChildren(scene)); I took a look at the sbx file and Terrain is the very last item listed. Had a hunch and it worked out. Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted February 26, 2012 Share Posted February 26, 2012 Well this works for me: for (i = 1; i <= childCount; i++) { newChild = GetChild(child,i); newChildCount = CountChildren(newChild); if(newChildCount>0) processChildren(newChild); // Get the terrain entity childClass = GetEntityKey(newChild, "class",""); if(childClass == "Terrain") { terrain = newChild; } Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Clackdor Posted February 26, 2012 Author Share Posted February 26, 2012 Yes, Pixel, thanks. That seems to be a more correct way to do it. Quote 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.