mesh - mesh handle x# - x position of mesh y# - y position of mesh z# - z position of mesh width# - width of mesh height# - height of mesh depth# - depth of mesh uniform (optional) - if true, the mesh will be scaled by the same amounts in x, y and z, so will not be distorted. Defaults to false. |
Scales and translates all vertices of a mesh so that the mesh occupies the specified box. Do not use a width#, height# or depth# value of 0, otherwise all mesh data will be destroyed and your mesh will not be displayed. Use a value of 0.001 instead for a flat mesh along one axis. See also: dxScaleMesh, dxScaleEntity. |
; dxFitMesh Example ; --------------- ; In this example we will demonstrate the use of the dxFitMesh command. ; First we will use dxFitMesh on a semi-transparent blue box. This will represent the dimensions we will ; be using with dxFitMesh. ; Then we will use these dimensions on a red cone, so that it appears to fit inside the box when the ; space bar is pressed. ; The first time the space bar is pressed a uniform dxFitMesh will be performed, which means the cone ; will be scaled equally along all axis so that at least one axis fits the dimensions specified. ; The second time the space bar is pressed a non-unifrom dxFitMesh will be performed, meaning the cone ; will be scaled non-equally along all axes so that all axes fit the dimensions specified. dxGraphics3D 640,480 dxSetBuffer dxBackBuffer() camera=dxCreateCamera() light=dxCreateLight() ; Create cube cube=dxCreateCube() ; Set cube colour to blue dxEntityColor cube,0,0,255 ; Make cube semi-transparent so we will be able to see cone inside it later dxEntityAlpha cube,0.5 ; Use dxFitMesh on cube to make it a cuboid dxFitMesh cube,-1,-.5,-1,2,1,2 ; Position cube in front of camera so we can see it dxPositionEntity cube,0,-1,5 ; Create cone cone=dxCreateCone() ; Set cone dxColor to red dxEntityColor cone,255,0,0 ; Position cone in front of camera so we can see it dxPositionEntity cone,0,-1,5 ; Set uniform value to 1 so when space is first pressed, dxFitMesh will be uniform uniform=1 While Not dxKeyDown(1) ; If space bar pressed.... If dxKeyHit(57)=True ; Set syntax string to show syntax useage syntax$="dxFitMesh cone,-1,-.5,-1,2,1,2,"+uniform ; Use dxFitMesh with cone, using same values as used with cube earlier. Cone should now fit in cube. dxFitMesh cone,-1,-.5,-1,2,1,2,uniform ; Change uniform value from 1 to 0 so when space bar is pressed again dxFitMesh will be non-uniform uniform=0 EndIf dxRenderWorld dxText 0,0,"Press space to use uniform dxFitMesh with cone" dxText 0,20,"Press space again to use non-uniform dxFitMesh with cone" dxText 0,40,syntax$ dxFlip Wend End |