Rotates mesh vertices/normals/tangents permanently (modifies geometry, not transform).
Takes entity (mesh entity handle), pitch (rotation around X-axis in degrees), yaw (rotation around Y-axis in degrees), roll (rotation around Z-axis in degrees).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
entityInt
pitchDouble
yawDouble
rollDouble
Returns
Void
Quick Summary
Rotates mesh vertices/normals/tangents permanently (modifies geometry, not transform).
Takes entity (mesh entity handle), pitch (rotation around X-axis in degrees), yaw (rotation around Y-axis in degrees), roll (rotation around Z-axis in degrees).
Returns nothing.
Technical Exegesis...
Rotates mesh vertices/normals/tangents permanently (modifies geometry, not transform). Takes entity (mesh entity handle), pitch (rotation around X-axis in degrees), yaw (rotation around Y-axis in degrees), roll (rotation around Z-axis in degrees). Returns nothing.
Rotates mesh vertices/normals/tangents permanently (modifies geometry, not transform). Takes entity (mesh entity handle), pitch (rotation around X-axis in degrees), yaw (rotation around Y-axis in degrees), roll (rotation around Z-axis in degrees). Returns nothing. Validates entity and mesh exist, calls EnsureUniqueMesh for copy-on-write, builds rotation matrix from Euler angles (pitch/yaw/roll), rotates all vertices/normals/tangents in all surfaces by multiplying with matrix, recalculates bounding radius, handles locked meshes (sets needsGPUUpload, defers buffer rebuild), unlocked meshes immediately call RebuildGPUBuffersFromSurfaces. Permanent geometry modification.
This function permanently rotates mesh geometry. Mesh vs entity transform: RotateMesh changes vertex/normal/tangent data directly (permanent geometry modification), affects mesh orientation (not world orientation), entity transform unchanged. Contrast with b3dRotateEntity which rotates entity without changing geometry. Use case: RotateMesh for one-time adjustments (reorient imported models), RotateEntity for runtime rotation (spinning, aiming). Copy-on-write: calls EnsureUniqueMesh() before modification, checks if mesh shared by multiple entities (refCount>1), creates independent mesh copy if shared (prevents corruption), single-use meshes modified in-place. Rotation matrix: converts degrees to radians (deg * PI/180), builds rotation matrix from Euler angles: Rx (pitch), Ry (yaw), Rz (roll), combined as Rz * Ry * Rx (intrinsic rotations), matrix used to transform vectors. Implementation: iterates all surfaces in mesh, for each vertex in each surface: position = matrixMultiply(rotationMatrix, position) (rotates position), normal = matrixMultiply(rotationMatrix, normal) (rotates normal), tangent.xyz = matrixMultiply(rotationMatrix, tangent.xyz) (rotates tangent, preserves .w for handedness). Rotation about origin: mesh rotates around coordinate origin (0,0,0), not around mesh center or entity position, to rotate around custom point: translate to origin, rotate, translate back. Normals/tangents: must rotate normals/tangents alongside positions (lighting requires correct surface orientation), normal rotation uses same matrix as position (not inverse-transpose, assumes uniform scale), tangent rotation preserves handedness (.w component unchanged). Bounding radius recalculation: after rotating vertices, calculates max distance from origin: boundingRadius = max(sqrt(vx*vx + vy*vy + vz*vz)), affects frustum culling and LOD (incorrect radius causes culling errors). Lock/unlock pattern: if mesh.locked==true, sets mesh.needsGPUUpload=true, defers GPU buffer update, b3dUnlockMesh later rebuilds once. If mesh.locked==false, immediately calls RebuildGPUBuffersFromSurfaces, uploads to GPU. Use cases: (1) Reorient imported models (fix up-axis, facing direction), (2) Procedural mesh generation (build rotated sections), (3) Mesh repair (fix incorrect orientation), (4) Baked vertex animation (pre-compute rotated poses), (5) Mirror/symmetry operations (180 degree rotation). Common pattern: mesh=b3dLoadMesh("model.glb"), b3dRotateMesh(mesh, 90, 0, 0) to fix up-axis from Z-up to Y-up. Typical workflow: b3dLockMesh, perform multiple RotateMesh/ScaleMesh/PositionMesh calls, b3dUnlockMesh (single GPU upload). Performance: O(N) where N=total vertex count, locked mesh mode defers expensive GPU upload, EnsureUniqueMesh may allocate/copy (expensive if many vertices), matrix multiplication per vertex/normal/tangent (3x multiplications per vertex). GPU upload: RebuildGPUBuffersFromSurfaces creates new vertex/index buffers, uploads to GPU, releases old buffers (synchronization required). Coordinate space: operates in mesh local space (before entity transform applied), rotated vertices permanently reoriented, subsequent entity transforms apply to already-rotated mesh. Hierarchy: mesh modification doesn't affect children (only entity transform propagates), parent mesh modification independent of child entities. Validation: invalid entity/mesh handles silently ignored. UV coordinates: not affected by rotation (texture mapping unchanged), only positions/normals/tangents rotated. Related: b3dRotateEntity rotates entity without geometry change, b3dPositionMesh translates vertices, b3dScaleMesh scales vertices, EnsureUniqueMesh handles copy-on-write, b3dLockMesh/UnlockMesh for batching, RebuildGPUBuffersFromSurfaces uploads to GPU.