b3dMeshMaxZ

Returns the maximum Z coordinate of a mesh's bounding box in local mesh space. Takes entity (mesh entity handle). Returns maximum Z value, or 0.0 on error.

3D Graphics

Parameters & Returns

Parameters

entity Int

Returns

Double

Quick Summary

Returns the maximum Z coordinate of a mesh's bounding box in local mesh space. Takes entity (mesh entity handle). Returns maximum Z value, or 0.0 on error.

Technical Exegesis...

Returns the maximum Z coordinate of a mesh's bounding box in local mesh space. Takes entity (mesh entity handle). Returns maximum Z value (Double), or 0.0 on error. Validates entity exists and type is ENTITY_MESH. Validates mesh has vertex data (not empty). Iterates all vertices in mesh to find maximum Z position. Returns unscaled mesh-space coordinate (does not account for entity scale/rotation). Silently returns 0.0 on errors.

Example

Example.bam
; Create visual bounding box for a mesh
Function CreateBoundingBox:Int(mesh:Int)
	Local minX:Double = b3dMeshMinX(mesh)
	Local maxX:Double = b3dMeshMaxX(mesh)
	Local minY:Double = b3dMeshMinY(mesh)
	Local maxY:Double = b3dMeshMaxY(mesh)
	Local minZ:Double = b3dMeshMinZ(mesh)
	Local maxZ:Double = b3dMeshMaxZ(mesh)

	Local width:Double = (maxX - minX) * b3dEntityScaleX(mesh)
	Local height:Double = (maxY - minY) * b3dEntityScaleY(mesh)
	Local depth:Double = (maxZ - minZ) * b3dEntityScaleZ(mesh)

	Local bbox:Int = b3dCreateCube(1, 0, 0)
	b3dScaleEntity(bbox, width / 2.0, height / 2.0, depth / 2.0)
	b3dPositionEntity(bbox, b3dEntityX(mesh), b3dEntityY(mesh), b3dEntityZ(mesh))

	Return bbox
EndFunction