What would be the best way to calculate the normal of the terrain triangle retrieved when using the x.z coordinates?
for example, getHeight(x,z) returns the height of the triangle represented by the coordinates. I am wanting to grab the normal of that same triangle such as vector3df normal = terrain->getNormal(x,z);
terrain normal
Re: terrain normal
I haven't really worked with terrain yet. But usually you can get triangles from triangle-selectors (so x,z you check a ray straight down at that position with the getTriangles function that takes a line). And triangles have a getNormal function.
But be careful - terrain only works without transformation. There was some open bug that stuff like rotations doesn't work for it (usually not a problem I guess).
But be careful - terrain only works without transformation. There was some open bug that stuff like rotations doesn't work for it (usually not a problem I guess).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: terrain normal
sigh....i should have thought of that. thanks for the assist! working on vegetation and want to use the slope of the terrain to either prevent placement or maybe angle the veggies.
-
- Posts: 4
- Joined: Sun Sep 24, 2023 5:48 am
Re: terrain normal
I recently implemented this in CopperCube engine with I would expect similar code as Irrlicht terrain though dont know for sure.
I added new member to struct STerrainData called "Angle" and in the 'updateMeshesFromTerrainData() function added new formula to get normal angle and update this 'Angle' before outputting this to the external javascript via new API so I can get for each cell the terrain texture and hence appropriate sound and also update all textures based on surface angle rather than by height which worked really well.
If you need more info let me know...
I added new member to struct STerrainData called "Angle" and in the 'updateMeshesFromTerrainData() function added new formula to get normal angle and update this 'Angle' before outputting this to the external javascript via new API so I can get for each cell the terrain texture and hence appropriate sound and also update all textures based on surface angle rather than by height which worked really well.
If you need more info let me know...