Home
Products
Community
Manuals
Contact
Login or Signup

Blitz3D Docs -> 3D - Category -> Entity Movement -> ScaleEntity

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

Parameters:

entity - name of the entity to be scaled
x_scale# - x size of entity
y_scale# - y size of entity
z_scale# - z size of entity
global (optional) -

Description:

Scales an entity so that it is of an absolute size.

Scale values of 1,1,1 are the default size when creating/loading entities.

Scale values of 2,2,2 will double the size of an entity.

Scale values of 0,0,0 will make an entity disappear.

Scale values of less than 0,0,0 will invert an entity and make it bigger.

See also: ScaleMesh, FitMesh.

Example:

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

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
light=CreateLight()

cone=CreateCone( 32 )
PositionEntity cone,0,0,5

; Set scale values so that cone is default size to begin with
x_scale#=1
y_scale#=1
z_scale#=1

While Not KeyDown( 1 )

; Change scale values depending on the key pressed
If KeyDown( 203 )=True Then x_scale#=x_scale#-0.1
If KeyDown( 205 )=True Then x_scale#=x_scale#+0.1
If KeyDown( 208 )=True Then y_scale#=y_scale#-0.1
If KeyDown( 200 )=True Then y_scale#=y_scale#+0.1
If KeyDown( 44 )=True Then z_scale#=z_scale#-0.1
If KeyDown( 30 )=True Then z_scale#=z_scale#+0.1

; Scale cone using scale values
ScaleEntity cone,x_scale#,y_scale#,z_scale#

RenderWorld

Text 0,0,"Use cursor/A/Z keys to scale cone"
Text 0,20,"X Scale: "+x_scale#
Text 0,40,"Y Scale: "+y_scale#
Text 0,60,"Z Scale: "+z_scale#

Flip

Wend

End

Comments

DJWoodgate(Posted 1+ years ago)
Here are some functions to get the entityscale. Bear in mind that although they are accurate enough for a number of uses they will be prone to slight inaccuracy due to floating point precision, so you should be cautious about feeding them back into ScaleEntity.

Function EntityScaleX#(entity, globl=False) 
	If globl Then TFormVector 1,0,0,entity,0 Else TFormVector 1,0,0,entity,GetParent(entity) 
	Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) 
End Function 

Function EntityScaleY#(entity, globl=False)
	If globl Then TFormVector 0,1,0,entity,0 Else TFormVector 0,1,0,entity,GetParent(entity)  
	Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) 
End Function 

Function EntityScaleZ#(entity, globl=False)
	If globl Then TFormVector 0,0,1,entity,0 Else TFormVector 0,0,1,entity,GetParent(entity)  
	Return Sqr(TFormedX()*TFormedX()+TFormedY()*TFormedY()+TFormedZ()*TFormedZ()) 
End Function 


BTW. It would be handy if blitz stored and retrieved an entities absolute scale factors.


Sonic(Posted 1+ years ago)
Im curious as to the function of the Global parameter in ts function... Does anyone have an explanation?


Yasha(Posted 1+ years ago)
It controls whether the entity is scaled against global or local space.

In other words, if you call ScaleEntity e, 2, 2, 2, g when e's parent has already experienced ScaleEntity p, 2, 2, 2:

-- if g is true, the scale vector will represent e's final scale relative to the world, and e will have a scale after the operation of 2, 2, 2

--- if g is false, the scale vector will represent e's final scale multiplied by its parent's scale, so e will have a scale after the operation of 4, 4, 4

In other words, unless you force it to work otherwise, parent entities also control the base scale for their children, in the same way that they do position and rotation unless forced to use global units.


Blitz3D Manual Forum

BlitzPlus Equivalent Command