CreateCube ( [parent] )

Parameters

parent (optional) - parent entity of cube

Description

Creates a cube mesh/entity and returns its handle.

The cube extends from -1,-1,-1 to +1,+1,+1, so it is 2 units along each side. Use ScaleEntity or ScaleMesh to turn it into crates, walls, floors and platforms of any size.

Cubes, cylinders and cones are a great way of getting scenes set up quickly: they can act as placeholders for more complex pre-modelled meshes later on in development, and they make handy invisible trigger volumes and collision blocks too.

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

See also: CreateSphere, CreateCylinder, CreateCone, CreatePivot, CreateBox, CreateWedge.

Example

; CreateCube Example
; ------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,1,-5

light=CreateLight()
RotateEntity light,45,45,0

; Create the cube - it extends from -1 to +1 on each axis
cube=CreateCube()
PositionEntity cube,0,1,0
EntityColor cube,0,150,255

While Not KeyDown(1)

    TurnEntity cube,0.5,1,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   Esc: exit"
    Text 0,20,"cube=CreateCube() - one cube entity, spun with TurnEntity"

    Flip

Wend

End

Index