b3dUpdateNormalsFlat

Recalculates vertex normals with flat shading (hard edges, per-face normals). Takes mesh (mesh entity handle). Returns nothing.

3D Graphics

Parameters & Returns

Parameters

mesh Int

Returns

void

Quick Summary

Recalculates vertex normals with flat shading (hard edges, per-face normals). Takes mesh (mesh entity handle). Returns nothing.

Technical Exegesis...

Recalculates vertex normals with flat shading (hard edges, per-face normals). Takes mesh (mesh entity handle). Returns nothing. Validates entity exists and type is ENTITY_MESH. Validates mesh is surface-based. For each triangle, calculates face normal using cross product of edge vectors. Assigns the same face normal to all three vertices of that triangle (no averaging across faces). Normalizes each face normal vector. Marks surfaces and mesh as needing GPU update. Silently returns on errors.

Example

Example.bam
; Create a cube and ensure flat shading after welding
Local cube:Int = b3dCreateCube(1, 0, 0)

b3dLockMesh(cube)
b3dWeldVertices(cube, 0.01)      ; Merge duplicates
b3dUnweldVertices(cube)          ; Split back for flat shading
b3dUpdateNormalsFlat(cube)       ; Calculate per-face normals
b3dUnlockMesh(cube)

; Result: Cube has proper flat shading with hard edges