Texturing with an Animtexture

Blitz3D Forums/Blitz3D Programming/Texturing with an Animtexture

John Pickford(Posted 2004) [#1]
I have a cuboid (build in code) where each side is a quad of two triangle, vertices are not shared among different quads. I'd like to texture each quad with a different 'frame' from an animtexture. Is this possible? Or do I have to manage the u/v coords myself.

The purpose of this is to keep all the sides as part of a single surface; and therefore different 'textures' are packed into a single animtexture.

BTW: The cuboid is just an example, I'm doing a lot more that that.


Shambler(Posted 2004) [#2]
I can't see any other option than managing the u/v coords.

They are all the same surface/entity so you can't EntityTexture each one with a different frame.


EOF(Posted 2004) [#3]
I'm working on something similar. What I'm doing is packing images into a texture (using an ImagePacker tool I wrote), saving the texture along with a definitions file which specifies where each image is located in the texture. Then I use functions such as:

pack1=LoadSpritePack("mysprites.png")
car=GetPackedSprite("porche",pack1)
PositionSprite car,100,200

I convert the x/y/width/height of the image dimensions into UV coordinates then use VertexTexCoords to get the image from the texture into the quad.
It's just a matter of dividing the pixel coordinates by the textures width/height to get the appropraite UV coordinates.


John Pickford(Posted 2004) [#4]
It's a shame we can't take advantage of the in-built animtexture features. An extra parameter on addtriangle or addvertex could specify which frame. The system already does most of the work as specied u/v's in the 0-1 range are corrected depending on the frame selected.