Better and quicker just to calculate the triangle Y normal component, rather than the steepest edge, like so ...
Where >0 = Flat up , <0 = flat down, 0 = steepest / vertical
Stevie
Where >0 = Flat up , <0 = flat down, 0 = steepest / vertical
Function TriangleNY#( s , t ) v0 = TriangleVertex( s, t, 0 ) v1 = TriangleVertex( s, t, 1 ) v2 = TriangleVertex( s, t, 2 ) ax# = VertexX( s, v1 ) - VertexX( s, v0 ) ay# = VertexY( s, v1 ) - VertexY( s, v0 ) az# = VertexZ( s, v1 ) - VertexZ( s, v0 ) bx# = VertexX( s, v2 ) - VertexX( s, v1 ) by# = VertexY( s, v2 ) - VertexY( s, v1 ) bz# = VertexZ( s, v2 ) - VertexZ( s, v1 ) Nx# = ( ay * bz ) - ( az * by ) Ny# = ( az * bx ) - ( ax * bz ) Nz# = ( ax * by ) - ( ay * bx ) Ns# = Sqr( Nx * Nx + Ny * Ny + Nz * Nz ) if Ns > 0 Return Ny / Ns else return 0 endif End Function
Stevie