Blitz3D+ Command Reference

CreateCone ( [segments][,solid][,parent] )

Parameters

segments (optional) - cone detail; 8 (default)

solid (optional) - true for a cone with a base, false for a cone without a base; true (default)

parent (optional) - parent entity of cone

Description

Creates a cone mesh/entity and returns its handle.

The cone is centred at 0,0,0, extends 1 unit up and down on the y axis, and the base has a radius of 1. Cones make quick placeholders for rockets, trees, markers and arrows 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 cone 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):
4: 6 polygons - a pyramid
8: 14 polygons - bare minimum amount of polygons for a cone
16: 30 polygons - smooth cone at medium-high distances
32: 62 polygons - smooth cone at close distances

The optional parent parameter allows you to specify a parent entity for the cone, so that when the parent moves the cone 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 cone being created at position 0,0,0 rather than at the parent entity's position.

See also: CreateCube, CreateSphere, CreateCylinder, CreatePivot.

Example

; CreateCone 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 cone
cone=CreateCone(segments)
PositionEntity cone,0,1,0
EntityColor cone,255,100,0

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 cone when the segment count changes
    If segments<>old
        FreeEntity cone
        cone=CreateCone(segments)
        PositionEntity cone,0,1,0
        EntityColor cone,255,100,0
    EndIf

    spin=spin+1
    RotateEntity cone,0,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,"CreateCone("+segments+")"

    Flip

Wend

End

Index