; CreateExtrusion Example ; ----------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,9,-16 RotateEntity camera,25,0,0 light=CreateLight() RotateEntity light,45,30,0 ground=CreatePlane() EntityColor ground,70,110,70 ; An L-shaped plan in metres: 10 wide and 9 deep plan=CreateProfile() AddProfilePoint plan,-5,0 AddProfilePoint plan,5,0 AddProfilePoint plan,5,6 AddProfilePoint plan,-1,6 AddProfilePoint plan,-1,9 AddProfilePoint plan,-5,9 ; A turntable, so the building can be seen from every side turntable=CreatePivot() upward=True depth_steps=3 house=0 While Not KeyDown(1) ; U switches between a plan raised from the ground and a shape pushed back along Z If KeyHit(22) Then upward=Not upward If house Then FreeEntity house house=0 EndIf ; [ / ] change the depth in 1 m steps If KeyHit(26) And depth_steps>1 Then depth_steps=depth_steps-1 If house Then FreeEntity house house=0 EndIf If KeyHit(27) And depth_steps<8 Then depth_steps=depth_steps+1 If house Then FreeEntity house house=0 EndIf If house=0 Then house=CreateExtrusion(plan,depth_steps,upward,turntable) EntityColor house,230,210,170 EndIf TurnEntity turntable,0,0.2,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,"Arrow keys: move camera U: upward [ / ] : depth Esc: exit" Text 0,20,"CreateExtrusion(plan,"+depth_steps+","+upward+",turntable)" If upward Then Text 0,40,"Upward: the outline is a plan seen from above, rising from the ground" Else Text 0,40,"Not upward: the outline stands up, pushed back along Z and centred" EndIf Flip Wend End