Blitz3D+ Command Reference

EntityTexture entity,texture[,frame][,index]

Parameters

entity - entity handle
texture - texture handle
frame (optional) - which frame of an animated texture to show; 0 (default)
index (optional) - texture layer to assign the texture to, 0 to 7; 0 (default)

Description

Applies a texture to an entity.

This is the quick, entity-level way to texture something: it works on whole entities and sits over whatever the entity's surfaces carry, so every surface shows the texture. For per-surface materials use brushes and PaintSurface instead.

The frame parameter selects a frame of a texture made with LoadAnimTexture or CreateTexture with multiple frames - call EntityTexture again with a new frame each update for flipbook animation. The index parameter picks one of eight texture layers (0-7) for multitexturing; each layer combines with the one below according to its TextureBlend mode, the standard trick being a lightmap or detail texture over the base layer.

On a terrain using the built-in layered terrain material, EntityTexture only changes the legacy brush underneath - use TerrainLayer (or ClearTerrainMaterial) for those.

See also: LoadTexture, LoadAnimTexture, BrushTexture, TextureBlend, PaintEntity.

Example

; EntityTexture Example
; ---------------------

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

camera=CreateCamera()

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

; A crate for our game scene
crate=CreateCube()
PositionEntity crate,0,0,5

tex_logo=LoadTexture("media/b3dlogo.jpg")
tex_moss=LoadTexture("media/MossyGround.BMP")

; Apply the logo. The optional arguments are frame (animation frame of the
; texture) and index (texture layer 0-7, used for multitexturing).
EntityTexture crate,tex_logo,0,0

tex_name$="tex_logo"

While Not KeyDown(1)

    ; Keys 1/2 choose which texture the crate wears
    If KeyHit(2)
        EntityTexture crate,tex_logo,0,0
        tex_name="tex_logo"
    EndIf
    If KeyHit(3)
        EntityTexture crate,tex_moss,0,0
        tex_name="tex_moss"
    EndIf

    TurnEntity crate,0,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,"1: logo texture   2: moss texture   Arrows: camera   Esc: exit"
    Text 0,20,"EntityTexture crate,"+tex_name+",0,0"

    Flip

Wend

End

Index