ScaleTexture texture,u_scale#,v_scale#

Parameters

texture - texture handle
u_scale# - horizontal scale
v_scale# - vertical scale

Description

Scales a texture up or down over whatever it is painted on.

Scales are absolute, and bigger means bigger: ScaleTexture tex,2,2 draws the texture at twice the size, so it tiles half as often, while ScaleTexture tex,0.5,0.5 packs four tiles into the space of one. This is the easy way to make a floor texture repeat nicely across a big room without touching the mesh UVs.

The two axes are independent, so uneven scales stretch the texture - useful for getting a brick texture to line up on a wall that is not square.

Do not pass 0 for either scale. The value is inverted internally, so zero produces an unusable texture matrix rather than an invisible texture.

Like the other texture transforms this applies to the texture handle, so every surface using that texture changes at once. Load the texture a second time if one object needs a scale of its own.

See also: PositionTexture, RotateTexture, TextureCoords, LoadBrush.

Example

; ScaleTexture Example
; --------------------

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

camera=CreateCamera()

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

; A mossy floor slab to show the texture tiling on
ground=CreateCube()
ScaleEntity ground,4,4,0.2
PositionEntity ground,0,0,6

tex=LoadTexture("media/MossyGround.BMP")
EntityTexture ground,tex

scale#=1.0

While Not KeyDown(1)

    ; Press + / - to shrink/grow the texture scale smoothly
    If KeyDown(13) Then scale=scale*1.01
    If KeyDown(12) Then scale=scale/1.01

    ; Apply the scale to both the u and v axes of the texture
    ScaleTexture tex,scale,scale

    TurnEntity ground,0,0,0.2

    ; 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,"+ / - : change texture scale   Arrows: camera   Esc: exit"
    Text 0,20,"ScaleTexture tex,"+scale+","+scale

    Flip

Wend

End

Index