Blitz3D+ Command Reference

MeshDepth# ( mesh )

Parameters

mesh - mesh handle

Description

Returns the depth of a mesh - the z extent of its bounding box.

The size comes from the actual vertex positions, so ScaleEntity has no effect on the result, while mesh commands such as ScaleMesh and FitMesh do. Loaded models report the size they were modelled at.

Together with MeshWidth and MeshHeight this gives you the full bounding box of a model - useful for auto-scaling with FitMesh or for rough sizing of collision volumes.

See also: MeshWidth, MeshHeight, FitMesh, ScaleMesh.

Example

; MeshDepth Example
; -----------------

; MeshDepth returns the depth (z size) of a mesh's geometry.
; It measures the MESH data, so ScaleMesh changes it while
; ScaleEntity would not. Hold [ or ] to squash and stretch the drum
; and watch the depth readout follow.

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-4

light=CreateLight()
RotateEntity light,30,40,0

; Load a model and fit it into a 2x2x2 box to start from known sizes
drum=LoadMesh("media/oil-drum/oildrum.3ds")
FitMesh drum,-1,-1,-1,2,2,2

While Not KeyDown(1)

    ; [ / ] rescale the mesh along z - the depth readout follows
    If KeyDown(26) Then ScaleMesh drum,1,1,0.98
    If KeyDown(27) Then ScaleMesh drum,1,1,1.02

    TurnEntity drum,0,1,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"[ / ] : squash / stretch depth   Arrow keys: move camera   Esc: exit"
    Text 0,20,"MeshDepth(drum) = "+MeshDepth(drum)
    Text 0,40,"Width "+MeshWidth(drum)+"   Height "+MeshHeight(drum)

    Flip

Wend

End

Index