Applies planar UV mapping by projecting vertices onto specified axis plane. Takes mesh (surface-based mesh entity), axis (0=X/YZ plane, 1=Y/XZ plane, 2=Z/XY plane). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and locked (must call b3dLockMesh first). Calculates bounding box across all surfaces (bboxMin, bboxMax). Computes size (bboxMax - bboxMin).
Applies planar UV mapping by projecting vertices onto specified axis plane. Takes mesh (surface-based mesh entity), axis (0=X/YZ plane, 1=Y/XZ plane, 2=Z/XY plane). Returns nothing. Validates mesh exists, type is ENTITY_MESH, surface-based, and locked (must call b3dLockMesh first). Calculates bounding box across all surfaces (bboxMin, bboxMax). Computes size (bboxMax - bboxMin). For each surface, for each vertex, projects position onto chosen plane: axis 0 (X): U=(Z-minZ)/sizeZ, V=1-(Y-minY)/sizeY; axis 1 (Y): U=(X-minX)/sizeX, V=1-(Z-minZ)/sizeZ; axis 2 (Z): U=(X-minX)/sizeX, V=1-(Y-minY)/sizeY. V coordinate inverted (1.0 minus) to match standard texture orientation (top of texture = top of geometry). Normalizes UVs to 0-1 range based on bounding box. Silently returns on errors (invalid handle, not surface-based, not locked).
This function generates automatic UV coordinates for procedural meshes. Planar mapping projects 3D positions onto 2D plane - imagine shining flashlight from one direction, texture appears on lit surface. Axis parameter determines projection direction: 0 projects from X (good for walls perpendicular to X), 1 from Y (good for floors/ceilings), 2 from Z (good for walls perpendicular to Z). Bounding box normalization ensures texture fits entire mesh (small meshes and large meshes both map to 0-1 UV range). Use cases: (1) Architectural walls (planar surfaces naturally fit planar mapping), (2) Floors/ceilings (axis=1 for top-down projection), (3) Signs/decals (flat geometry), (4) Quick texturing for prototypes. Limitations: stretching on non-planar surfaces (sphere with planar mapping = severe distortion), no wrapping (UVs outside 0-1 clamp/repeat based on texture sampler). Must lock mesh before calling (prevents GPU buffer conflicts). After UV mapping, call b3dUnlockMesh to upload changes. Multiple UV sets: writes to texCoord (UV0) - for additional UVs, use b3dAddMeshVertex with explicit UV parameters. Common workflow: mesh=b3dCreateMesh(...), b3dLockMesh(mesh), b3dUVMapPlanar(mesh, 2), b3dUnlockMesh(mesh), b3dLoadTexture(tex, "wall.png"), b3dSetEntityTexture(mesh, tex). Alternative mappings: b3dUVMapBox (6-sided projection), b3dUVMapCylindrical (tubes/columns), b3dUVMapSpherical (spheres/domes).