Shard Posted September 25, 2010 Share Posted September 25, 2010 How do I get a pointer/reference to the terrain in a scene? I need it so that I can check terrain normals when doing my AStar scan function. Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK Link to comment Share on other sites More sharing options...
Rick Posted September 25, 2010 Share Posted September 25, 2010 http://leadwerks.com/werkspace/index.php?/topic/1491-getting-terrain/page__p__13869__hl__%2Bfind+%2Bterrain__fromsearch__1#entry13869 Quote Link to comment Share on other sites More sharing options...
Shard Posted September 26, 2010 Author Share Posted September 26, 2010 http://leadwerks.com/werkspace/index.php?/topic/1491-getting-terrain/page__p__13869__hl__%2Bfind+%2Bterrain__fromsearch__1#entry13869 I did exactly that, and at the time of that thread, it worked. I did it again earlier today and it didn't work; I got a null pointer. I was thinking that something in the code had changed. My code is below. int childCount = scene.GetCountChildren(); Entity ent; string className; string objectName; string childClass; TVec3 objectPos; for(int i = 1; i < childCount; i++) { ent = scene.GetChild(i); className = ent.GetKey("classname"); objectName = ent.GetKey("name"); objectPos = ent.GetPosition(); childClass = ent.GetKey("class"); if(childClass == "Terrain") aStar.terrain = ent; if(objectName == "node_1") nodeOne = objectPos; else if(objectName == "node_2") nodeTwo = objectPos; else if(objectName == "waterplane_1") aStar.waterHeight = objectPos.Y; } Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK Link to comment Share on other sites More sharing options...
Canardia Posted September 26, 2010 Share Posted September 26, 2010 You can see how it's done in gamelib.cpp, and use it or copy it. 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...
Shard Posted September 28, 2010 Author Share Posted September 28, 2010 You can see how it's done in gamelib.cpp, copy use it or copy it. I did take a look at it and looked just like my code. Yet my code doesn't work. Any thoughts? if( (es=="nothing") && (cl=="Terrain") ) { // printf("******** FOUND TERRAIN ********\n"); terrain = e; SetEntityKey(e,"status","handled"); } Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK Link to comment Share on other sites More sharing options...
Shard Posted September 28, 2010 Author Share Posted September 28, 2010 I found the bug and fixed it. From: for(int i = 1; i < childCount; i++) To: for(int i = 1; i <= childCount; i++) Yep, since the terrain is the last object in a sbx, I always missed it because I wasn't checking the last element. Quote Programmer/Engineer/Student www.reikumar.com 2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM C++ - Visual Studio Express - Dark GDK - Leadwerks SDK 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.