Applies box UV mapping by projecting each vertex from its dominant normal direction.
Takes mesh (surface-based mesh entity).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
meshInt
Returns
Void
Quick Summary
Applies box UV mapping by projecting each vertex from its dominant normal direction.
Takes mesh (surface-based mesh entity).
Returns nothing.
Technical Exegesis...
Applies box UV mapping by projecting each vertex from its dominant normal direction. Takes mesh (surface-based mesh entity). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and locked. Calculates bounding box across all surfaces. Computes size. For each surface, for each vertex, determines dominant normal axis (absX, absY, absZ - largest component). Projects based on dominant: X-dominant uses YZ plane, Y-dominant uses XZ plane, Z-dominant uses XY plane.
Applies box UV mapping by projecting each vertex from its dominant normal direction. Takes mesh (surface-based mesh entity). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and locked. Calculates bounding box across all surfaces. Computes size. For each surface, for each vertex, determines dominant normal axis (absX, absY, absZ - largest component). Projects based on dominant: X-dominant uses YZ plane, Y-dominant uses XZ plane, Z-dominant uses XY plane. Same projection formulas as b3dUVMapPlanar but chosen per-vertex based on normal. Normalizes UVs to 0-1 based on bounding box. Prevents texture stretching on box-like geometry (each face gets appropriate projection). Silently returns on errors.
This function provides intelligent multi-directional planar mapping. Box mapping = 6 planar projections (+/-X, +/-Y, +/-Z faces), algorithm chooses projection per-vertex using normal direction. Eliminates stretching on axis-aligned box geometry. Use cases: (1) Cubes/rooms (each wall gets correct projection), (2) Buildings (walls project from side, roof from top), (3) Crates/containers (box-shaped objects), (4) Terrain with cliffs (cliff faces project correctly). Normal-based selection: vertex normal determines which projection plane - face pointing +X uses YZ projection, face pointing +Y uses XZ, etc. Bounding box ensures consistent scaling across all projections. Limitations: seams at edges where projection changes (visible with non-tiling textures), not smooth for curved surfaces. Better than single planar for complex geometry. Worse than cylindrical/spherical for round objects. Must lock mesh before calling. After mapping, unlock to upload. Works on procedural meshes (b3dCreateMesh) with properly calculated normals. For meshes without normals, call normal calculation function first or normals will be zero/undefined (unpredictable results). Common workflow: mesh=b3dCreateCube(...), b3dLockMesh(mesh), b3dUVMapBox(mesh), b3dUnlockMesh(mesh). Coordinates inverted in V to match texture orientation. Alternative: manually assign UVs per surface for precise control, use b3dUVMapPlanar for flat geometry, b3dUVMapCylindrical for round columns.