Homeworld Effects Manual: setTexture()

setTexture(filename texturefile, int x1, int y1, int x2, int y2)

texturefile is the filename of the texture, including the path from homeworld\etg\ and minus the extension. Thus, if you wanted to use homeworld\etg\textures\glow32.LiF, texturefile would be textures\glow32. Relative pathing is allowed, so you can reach directories above homeworld\etg\. .. means the parent of the current directory, and . means the current directory. So homeworld\r1\heavyinterceptor\rl0\lod0\page0.LiF can be reached with ..\r1\heavyinterceptor\rl0\lod0\page0. I could even retrieve a LiF from my Half-Life directory, although why I would do such a thing is beyond me.

The next four parameters allow you to use any rectangular portion of the texture you want. (x1, y1) are the co-ordinates of the lower-left corner of the texture. (x2, i>y2) are the co-ordinates of the upper-right corner of the texture. (see picture below) x1, x2, y1, and y2 can be int or float constants. Float constants will be rounded to the nearest integer. Any variables will be interpreted as zeros. There are no restrictions on the values of the co-ordinates; negative values and values that exceed the dimensions of the texture are quite legal. In this way, you can flip textures vertically or horizontally, stretch them, tile them, or use only a small portion of them.

setTexture() acts on differently on different types of objects:

Effects: Other effects usually call setDefaults() and/or setTexture() before creating anything, so setTexture() in the calling file will have no effect. It is possible to have a file that does not call setDefaults() at the beginning and thus depends on the calling file for some attributes, but such files are risky. If the calling file does not provide what the file is expecting, it may produce garbage.

Meshes: Meshes have texture co-ordinates built into them, so the texture co-ordinates in setTexture() are ignored. The texture co-ordinates in the mesh are not dependant on the size of the texture; any texture can be applied to a mesh without tiling or blank spots (unless the original textures on the mesh had tiling and blank spots.)

Sprites: Without setTexture(), sprites are basically worthless. Unlike meshes, sprites use the texture co-ordinates that setTexture() provides.

Circles, Lines, and Points: These objects do not use textures. setTexture() has no effect on them.