CreateCylinder ( [segments][,solid][,parent] )
Parameters
|
segments (optional) - cylinder detail; 8 (default) solid (optional) - true for a capped cylinder, false for an open tube; true (default) parent (optional) - parent entity of cylinder |
Description
|
Creates a cylinder mesh/entity and returns its handle. The cylinder is centred at 0,0,0, extends 1 unit up and down on the y axis, and has a radius of 1. Cylinders make quick placeholders for pillars, barrels, tree trunks and characters while you block out a game. The segments value must be in the range 3-100 inclusive, although this is only checked in debug mode. A common mistake is to leave debug mode off and pass the parent parameter (usually an eight digit entity handle) in the place of the segments value - Blitz then tries to build a cylinder with millions of polygons and your program can hang or crash. Keep debug mode on while developing to catch this. Example segments values (solid=true): 3: 8 polygons - a prism 8: 28 polygons - bare minimum amount of polygons for a cylinder 16: 60 polygons - smooth cylinder at medium-high distances 32: 124 polygons - smooth cylinder at close distances The optional parent parameter allows you to specify a parent entity for the cylinder, so that when the parent moves the cylinder moves with it. The relationship is one way: applying movement commands to the child will not affect the parent. Specifying a parent will still result in the cylinder being created at position 0,0,0 rather than at the parent entity's position. See also: CreateCube, CreateSphere, CreateCone, CreatePivot. |
Example
; CreateCylinder Example ; ---------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 segments=8 ; Create the cylinder cylinder=CreateCylinder(segments) PositionEntity cylinder,0,1,0 EntityColor cylinder,100,255,100 spin=0 While Not KeyDown(1) old=segments ; [ / ] choose fewer or more segments If KeyHit(26) And segments>3 Then segments=segments-1 If KeyHit(27) And segments<32 Then segments=segments+1 ; Rebuild the cylinder when the segment count changes If segments<>old FreeEntity cylinder cylinder=CreateCylinder(segments) PositionEntity cylinder,0,1,0 EntityColor cylinder,100,255,100 EndIf spin=spin+1 RotateEntity cylinder,30,spin,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,"[ / ] : segments Arrow keys: move camera Esc: exit" Text 0,20,"CreateCylinder("+segments+")" Flip Wend End
Index