Vizard 7 » Reference » Appearance & Texturing » Texture matrix
7.6

Texture Matrix

OpenGL contains a feature which allows the user to set a transformation matrix for texture coordinates. When a texture matrix is applied, all texture coordinates will be transformed through it. In the example code below, the texture is animated by updating the texture matrix every frame:

import viz
import vizact
viz.go()

viz.clearcolor(viz.SLATE)

#Create a quad to display texture
quad = viz.addTexQuad(pos=[0,1.8,3])

#Create texture with repeating wrap mode
tex = viz.addTexture('images/tile_grass.jpg', wrap=viz.REPEAT)
tex.pos = 0

#Apply texture to quad
quad.texture(tex)

ANIMATE_SPEED = 0.1

def animateTexture():
    #Increment texture position
    tex.pos += ANIMATE_SPEED * viz.elapsed()

    #Create transform for texture
    mat = viz.Transform()
    mat.setTrans(tex.pos,0,0)

    #Apply transform to texture
    quad.texmat(mat)

vizact.ontimer(0,animateTexture)

See also

In this section:

Appearance & texturing basics

Texture wrapping

Multi-texturing

Environment mapping

Texture appearance and filtering

Texture types

Visibility

Draw order & Z offsetting

Projecting textures

Appearance & texturing command table

Other sections:

Matrix transform basics

Example scripts:

Matrix transformations