Blitz3D+ Command Reference

ScaleEntity entity,x_scale#,y_scale#,z_scale#[,global]

Parameters

entity - entity handle

x_scale# - x scale of entity
y_scale# - y scale of entity
z_scale# - z scale of entity

global (optional) - true to set the scale in world space, ignoring any scale inherited from parent entities; false (default)

Description

Scales an entity to an absolute size.

Scale values of 1,1,1 are the default size when creating or loading entities. 2,2,2 doubles the size; 0.5,0.5,0.5 halves it. The three axes are independent, so a stretched cube makes a wall (ScaleEntity wall,10,3,0.2) and a squashed sphere makes a puddle.

Scale values of 0,0,0 make an entity disappear, and negative values turn it inside out while making it bigger in the negative direction - rarely what you want.

Children inherit their parent's scale: scale a parent to 2 and every child appears twice as big too (pass true for global to set a child's world-space size directly). Note that scaling an entity does not change its collision radius or box - set EntityRadius/EntityBox to match the new size.

ScaleEntity is non-destructive and can be changed every frame (a pulsing pickup, for instance). To bake a size change into the actual vertex data instead, use ScaleMesh or FitMesh.

See also: ScaleMesh, FitMesh, EntityRadius, EntityBox.

Example

; ScaleEntity Example
; -------------------

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

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

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

; A balloon to inflate and squash
balloon=CreateSphere(16)
EntityColor balloon,255,60,60

x_scale#=1
y_scale#=1
z_scale#=1

While Not KeyDown(1)

    ; Cursor keys and A/Z stretch or squash each axis
    If KeyDown(203) And x_scale>0.1 Then x_scale=x_scale-0.02
    If KeyDown(205) Then x_scale=x_scale+0.02
    If KeyDown(208) And y_scale>0.1 Then y_scale=y_scale-0.02
    If KeyDown(200) Then y_scale=y_scale+0.02
    If KeyDown(44) And z_scale>0.1 Then z_scale=z_scale-0.02
    If KeyDown(30) Then z_scale=z_scale+0.02

    ; ScaleEntity sets the ABSOLUTE size: 1 is the default size, 2 is double
    ScaleEntity balloon,x_scale,y_scale,z_scale

    TurnEntity balloon,0,1,0

    RenderWorld

    Text 0,0,"Cursors/A/Z: scale each axis   Esc: exit"
    Text 0,20,"ScaleEntity balloon,"+x_scale+","+y_scale+","+z_scale

    Flip

Wend

End

Index