UVs

Blitz3D Forums/Blitz3D Programming/UVs

RifRaf(Posted 2004) [#1]
Hi.. I am trying to convert the code below to work on a single brush.. any help appreciated.. here it is as multibrus/surface.

;Create a map mesh
tilex=t_gridx
tilez=t_gridz
mesh=CreateMesh()
u#=0
v#=0
stp#=1.0/Float(tilex)
For zt#=0 To tilez-1
u=0
For xt#=1 To tilex
h1#=map(1,xt,zt)\y ;top right height
h2#=map(1,xt-1,zt)\y ;top left height
h3#=map(1,xt-1,zt+1)\y ;bot left height
h4#=map(1,xt,zt+1)\y ;bot right height
br=map(1,xt,zt)\brush ; this brush contains both tiles + mask + lightmap
surf=FindSurface( mesh,br) ; Find a surface in the mesh that contains the same brush
If surf=0 Then surf=CreateSurface(mesh,br) ; If it can't find one create a new surface
cnt=CountVertices( surf ) ; Get count of vertices
;Add vertices including tile coords
AddVertex surf,xt-1.0,h2,zt,1,0
AddVertex surf,xt,h1,zt,0,0
AddVertex surf,xt,h4,zt+1.0,0,1
AddVertex surf,xt-1.0,h3,zt+1.0,1,1
VertexTexCoords surf,cnt,u+stp,v,0,1
VertexTexCoords surf,cnt+1,u,v,0,1
VertexTexCoords surf,cnt+2,u,v+stp,0,1
VertexTexCoords surf,cnt+3,u+stp,v+stp,0,1

AddTriangle surf,cnt,cnt+2,cnt+1
AddTriangle surf,cnt,cnt+3,cnt+2
u=u+stp
Next
v=v+stp
Next

UpdateNormals mesh



ok i replace teh brush reference to a large 1024x1024 image with all the smaller images in it.. I can either load in animaesh or strandard.. if i do that and reference only that brush.. How the heck can i get those UVs to lign up with the proper tile if I know what tile index it is.
each tile is 64x64. and I know the max width and height of the image is 1024x1024 (unless loaded aniimage) then its 1024*16 x 64

the information available to the program at the point of UV assignment. is the index number for the tile IE tile#24 the width/height of the entire brush(texture) and the tile index number.

thanks.. code examples that would work in the above code would be very very very much appreciated


RifRaf(Posted 2004) [#2]
bump


Biofellis(Posted 2004) [#3]
I think you might need to explain a little better what this code is doing- and a little more exactly what you want it to do instead- it's a little confusing.

Specifically, why are you vertexcoords'ing stuff you (apparently) just addvertex'ed? I may be missing something obvious, and I have little idea what all your vars represent as well.

Anyway, the math on your tile index uvs is 64/1024 or .0625


RifRaf(Posted 2004) [#4]
i got it going, thanks


Biofellis(Posted 2004) [#5]
k.