SyntaxBomb - Indie Coders
Languages & Coding => BlitzMax / BlitzMax NG => MiniB3D => Topic started by: Kippykip on November 08, 2019, 11:46:35
Hey guys, I noticed OpenB3D / MiniB3D have a bit of difficulty calculating normals on meshes that have multiple groups.
Such as here (might have to zoom as the images have the scanline filter):
(https://i.imgur.com/gxiwXvR.png)
So here's what this alternative function does to the normalmaps instead:
(https://i.imgur.com/lOk99ky.png)
'Custom UpdateNormals equivilant that works on mesh groups better
Function NormaliseNormals(mesh:TMesh)
For Local s:Int = 1 To CountSurfaces(mesh)
Local surf:TSurface = GetSurface(mesh, s)
For Local vert:Int = 0 To CountVertices(surf) - 1
TFormPoint(VertexX(surf, vert), VertexY(surf, vert), VertexZ(surf, vert), mesh, mesh)
VertexNormal(surf, vert, TFormedX(), TFormedY(), TFormedZ())
Next
Next
End Function
It could be optimised better, I added this to my internal mesh loader function (where duplicates use either CopyEntity or CopyMesh, to avoid recalculating and reloading off the hard disk.)
in case you are not aware, take a look at smoothing groups (when modeling a mesh)