CreateCylinder()

Syntax

Result = CreateCylinder(#Mesh, Radius.f, Height.f [, NbBaseSegments, NbHeightSegments, CloseTop])
Description
Create a new cylinder mesh.

Parameters

#Mesh The number to identify the new mesh. #PB_Any can be used to auto-generate this number.
Radius Radius, in world unit, of the cylinder.
Height Height, in world unit, of the cylinder.
NbBaseSegments (optional) Number of segments used for the base of the cylinder (default: 16).
NbHeightSegments (optional) Number of segments used for the height of the cylinder (default: 1).
CloseTop (optional) Specify if the cylinder should be closed on top and bottom, or if it should be left open (like a pipe). Set it to #True (default) to create a closed cylinder or to #False else.

Return value

Returns nonzero if the mesh was created successfully and zero if there was an error. If #PB_Any was used as the #Mesh parameter then the new generated number is returned on success.

Example

  InitEngine3D() 
  InitSprite() 
  
  OpenWindow(0, 0, 0, 640, 480, "Cylinder example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
  
  ; Light
  CreateLight(#PB_Any, RGB(25, 25, 180), -5, 10, 5, #PB_Light_Point)
  
  ; Camera
  CreateCamera(0, 0, 0, 100, 100)
  MoveCamera(0, 2, 1, 3, #PB_Absolute | #PB_Local)
  CameraLookAt(0, 0, 0, 0)
  
  ; Create the cylinder and attach it to the scene
  CreateCylinder(0, 0.5, 1)
  CreateEntity(0, MeshID(0), #PB_Material_None)
  
  Repeat
    RenderWorld()
    FlipBuffers()
  Until WaitWindowEvent(1) = #PB_Event_CloseWindow

See Also

FreeMesh(), CreateSphere(), CreateCone(), CreateMesh(), CreateCube(), CreatePlane(), CreateLine3D()

Supported OS

All

<- CreateCube() - Mesh Index - CreateIcoSphere() ->