Stevenson Posted January 23, 2010 Share Posted January 23, 2010 Hello, i was playing arround a little bit with C++, and i had problems with selecting the terrain. This is my code: TEntity cScene = LoadScene("abstract::test2.sbx"); ScaleEntity(FindChild(cScene,"Terrain"), Vec3(1,1,1)); Does some one know, what is my problem? greats Quote Your Travel Route Link to comment Share on other sites More sharing options...
Canardia Posted January 23, 2010 Share Posted January 23, 2010 I think FindChild is looking for the "name" key, and not the "class" key. GameLib gets the terrain entity correctly by looking for "class"=="Terrain". If you don't want to use GameLib, you could just copy the function GetFirstEntityByKey(key,value) from it, and use it as: terrain = GetFirstEntityByKey("class","Terrain");. 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...
Stevenson Posted January 23, 2010 Author Share Posted January 23, 2010 Hello, were i can find GetFirstEntityByKey ? I am unable to find it in the c++ files. greats Quote Your Travel Route Link to comment Share on other sites More sharing options...
Stevenson Posted January 23, 2010 Author Share Posted January 23, 2010 Ok, i found a solution: TEntity cScene = LoadScene("abstract::test2.sbx"); int cTerrainChildCount = CountChildren(cScene); TTerrain cTarrain = (TTerrain)GetChild(cScene,cTerrainChildCount); Thanks! greats Quote Your Travel Route Link to comment Share on other sites More sharing options...
Masterxilo Posted January 23, 2010 Share Posted January 23, 2010 How can you be sure that the terrain is always the last child? Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
Stevenson Posted January 23, 2010 Author Share Posted January 23, 2010 I Also thought about that, but every time when i test it, it was the last chil. But, i have one more question, why does this two ways to get the terrain height doesn´t work: First Way: VObject::kiObject->Y = TerrainHeight(cTerrain, kiObject->X*2,kiObject->Y*2); // 2 is the Meter per tile Second way: if(LinePick(&cPick, Vec3(kiObject->X,kiObject->Y,kiObject->Z), Vec3(kiObject->X,kiObject->Y-10,kiObject->Z), 5)) { kiObject->Y = cPick.Y; std::cout << cPick.Y << std::endl; } Can some one help me? greats Quote Your Travel Route Link to comment Share on other sites More sharing options...
Masterxilo Posted January 23, 2010 Share Posted January 23, 2010 The first way doesn't work because you use y as the z position, I think it should be: VObject::kiObject->Y = TerrainHeight(cTerrain, kiObject->X*2,kiObject->Z*2); // 2 is the Meter per tile and for the second way: make sure you use 0 as the pick radius, anything else doesn't work. (set your 5 to 0) Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
Stevenson Posted January 23, 2010 Author Share Posted January 23, 2010 Oh, i am so stupid PS.: It is also wrong in the Wiki: C++: flt Terrain::GetHeight( int x, int y ) const EDIT: Now every thing work fine: VObject::kiObject->Y = TerrainElevation(cTerrain, kiObject->X,kiObject->Z) greats Quote Your Travel Route Link to comment Share on other sites More sharing options...
Masterxilo Posted January 23, 2010 Share Posted January 23, 2010 It's not wrong in the wiki, if there are only two axis (like, for example on a plane) they're always called x, y. It's just confusing because the terrain actually lies in the xz plane. Quote Hurricane-Eye Entertainment - Site, blog. 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.