MeshWidth# ( mesh )
Parameters
| mesh - mesh handle |
Description
|
Returns the width of a mesh - the x 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. Typical uses: working out the scale factor to feed ScaleMesh or FitMesh, or spacing objects so they don't overlap. See also: MeshHeight, MeshDepth, FitMesh, ScaleMesh. |
Example
; MeshWidth Example ; ----------------- ; MeshWidth returns the width (x 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 width 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 x - the width readout follows If KeyDown(26) Then ScaleMesh drum,0.98,1,1 If KeyDown(27) Then ScaleMesh drum,1.02,1,1 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 width Arrow keys: move camera Esc: exit" Text 0,20,"MeshWidth(drum) = "+MeshWidth(drum) Text 0,40,"Height "+MeshHeight(drum)+" Depth "+MeshDepth(drum) Flip Wend End
Index