fn_Quiksilver 1633 Posted July 28, 2016 Hi guys, Any idea how to test terrain gradient of an area? Currently using a sloppy method of getting the Z-axis of 4 corners of the area and using basic math to get the avg slope of the difference, wondering if there is a better solution. isFlatEmpty checks gradient but not sure how. Share this post Link to post Share on other sites
pedeathtrian 99 Posted July 29, 2016 Check BIS_fnc_terrainGradAngle and surfaceNormal. Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted July 29, 2016 yes BIS_fnc_terrainGradAngle is good but only tests one vector. To get a true picture of an area we need to test multiple sites in an area. Basically have to put that function into a loop and iterate through different directions. If any of the directions exceed a certain limit, or add up the total and divide ... Surface normal isn't the right tool, tests only the surface at the exact position. I can't think of an elegant solution except to 'spiderweb' an area with bis_fnc_terraingradangle tests. Share this post Link to post Share on other sites
pedeathtrian 99 Posted July 29, 2016 Basically have to put that function into a loop and iterate through different directions. If any of the directions exceed a certain limit, or add up the total and divide ... Surface normal isn't the right tool, tests only the surface at the exact position. Get surface normal at some point, project it on XY plane (i.e. drop its z coordinate, and (optionally) normalize vector), convert projection into compass direction: you end up with direction of maximum slope gradient at that point. Beware of normal vectors very close to Z axis, they're the source of roundoff and other calculation errors. No direction loop required. Share this post Link to post Share on other sites
ceeeb 147 Posted July 29, 2016 Create a function to return terrain vertices, then you only need to collect the heights of each vertex in the area, then check the variation/deviation or min/max or however you want to decide it's too steep/flat. I have created functions to achieve similar results somewhere.... Share this post Link to post Share on other sites