Blitz3D+ Command Reference

CaptureWorld

Parameters

None.

Description

Captures the properties (position, rotation, scale, alpha and colour) of every entity in the 3D world.

CaptureWorld exists for render tweening: capture, run one step of game logic, then render one or more frames with the RenderWorld tween parameter set to how far through the step you are. Each entity is drawn interpolated between its captured state and its current state, so motion looks smooth even though the game logic runs at a fixed, lower rate.

The usual loop is: CaptureWorld, UpdateWorld and your movement code, then RenderWorld tween for one or more values between 0 and 1. See the RenderWorld docs for the full explanation of render tweening.

CaptureWorld is also useful after repositioning lots of entities at once (a level restart, say) - capturing immediately afterwards stops the first tweened frame interpolating from the old positions.

See also: RenderWorld, UpdateWorld.

Example

; CaptureWorld Example
; --------------------

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

camera=CreateCamera()
PositionEntity camera,0,0,-12

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

; Two identical cones, both placed on the left
cone1=CreateCone(16)
PositionEntity cone1,-4,0,0
ScaleEntity cone1,1,2,1
EntityColor cone1,255,60,60

cone2=CopyEntity(cone1)

; CaptureWorld stores the CURRENT state (position, rotation, scale, alpha)
; of every entity - here, with both cones together on the left
CaptureWorld

; Now change the world: move the second cone to the right and tilt it
MoveEntity cone2,8,0,0
TurnEntity cone2,0,0,90

tween#=1.0

While Not KeyDown(1)

    ; Left/Right choose the tween value passed to RenderWorld
    If KeyDown(203) And tween>0 Then tween=tween-0.01
    If KeyDown(205) And tween<1 Then tween=tween+0.01

    ; RenderWorld tween draws each entity interpolated between its captured
    ; state (tween=0) and its current state (tween=1). Games use this to
    ; render smooth in-between frames when the game logic updates less
    ; often than the screen refreshes.
    RenderWorld tween

    Text 0,0,"Left/Right: change tween   Esc: exit"
    Text 0,20,"CaptureWorld was taken with both cones on the left"
    Text 0,40,"RenderWorld "+tween

    Flip

Wend

End

Index