Vertex Texture Co-ords

Blitz3D Forums/Blitz3D Programming/Vertex Texture Co-ords

Nexic(Posted 2005) [#1]
At the moment I'm using a basic single surface system for my current project, only up until now I've had a seperate surface for each texture (as all quads on a surface must share the same map). However I now need some animating objects to be single surface. Now assuming I have a 400x400 texture, with 16 100x100 mini textures each representing a frame(4x4), I think I should be able use VertexTexCoords to change the UV map depending onthe frame. However I can't seem to get my head around how this would work. Could somebody give me a helping hand?

Would the +1/+1 vertex be the top right hand corner of each tile? And is U/V in actual pixels, or from 0 to 1?

Any information would be useful :)


Nexic(Posted 2005) [#2]
Would this be right?

For example (pseudo code):

1600x100 texture (16x 100x100 pixel tiles)
for frame = 1 to 16
 ;format vertex = x,y 

 vertex +1/+1 = (frame)*(1.0/16), 0
 vertex -1/+1 = (frame-1)*(1.0/16), 0
 vertex +1/-1 = (frame)*(1.0/16),1.0 
 vertex -1/-1 = (frame-1)*(1.0/16), 1.0
next



jfk EO-11110(Posted 2005) [#3]
First: don't use texture sizes that are not "power of two" values. They will be rescaled internally to the next bigger power of two size.
EG:
100*200 will be scaled to 128*256
100*100 to 128*128
400*400 to 512*512
80*900 to 128*1024
Power of two values are boolen Bit values, eg: 1,2,4,8,16,32,64,128,256,512...
width and hight don't have to be the same.

When you use animated textures (LoadAnimTex) you don't have to care about the calcultion of the frames on the multi texture. Just assume frame 1 is the whole texture and set the UVs this way (from 0.0 to 1.0, as usual).

When you want to use some selfmade animation system,or multitexture on singlesurface system, you will have to calculate the true UVs, as you did.


Nexic(Posted 2005) [#4]
Right, so my calculations are correct then?

Thanks for the info on the bit values.


jfk EO-11110(Posted 2005) [#5]
i think it would be ok, just use a float variable for "frame" to prevent the multiplication will return an int value.


Nexic(Posted 2005) [#6]
Thanks :)