Terrain tiled UVW

Blitz3D Forums/Blitz3D Programming/Terrain tiled UVW

licin(Posted 2007) [#1]
Well,
I load a terrain from a B3D file and want to make from a single texture on it a tiled terrain.But there is one problem,my vertexes are welded and if I move one UV from
this position,it will stretch all over the texture.


D4NM4N(Posted 2007) [#2]
Is the terrain's vertex order logical, or has it been 'optimised'?

assuming it is,

At the moment if it has a single texture stretched over the whole terrain (like a 'supertexture' or lightmap) it looks like this:

(the UV result in each box is in relation to the top left vertex in each quad (2 triangles) :)

---U----V------------------------------------------------------
| 0.0 , 0.0 | 0.2 , 0.0 | 0.4 , 0.0 | 0.6 , 0.0 | 0.8 , 0.0| 1.0,0.0
|------------|------------|------------|------------|-----------|
| 0.0 , 0.2 | 0.2 , 0.2 | 0.4 , 0.2 | 0.6 , 0.2 | 0.8 , 0.2| 1.0,0.2
|------------|------------|------------|------------|-----------|
| 0.0 , 0.4 | 0.2 , 0.4 | 0.4 , 0.4 | 0.6 , 0.4 | 0.8 , 0.4| 1.0,0.4
|------------|------------|------------|------------|-----------|
| 0.0 , 0.6 | 0.2 , 0.6 | 0.4 , 0.6 | 0.6 , 0.6 | 0.8 , 0.6| 1.0,0.6
|------------|------------|------------|------------|-----------|
| 0.0 , 0.8 | 0.2 , 0.8 | 0.4 , 0.8 | 0.6 , 0.8 | 0.8 , 0.8| 1.0,0.8
-----------------------------------------------------------------
\0.0,1.0 etc... up to 1.0,1.0 which is your texture repeat

To tile it with welded verts, what you need to do is set it like this (or something with the correct ratio, which in this example is using 1:1 or 1 repeat per quad for simplicity) like so:

---U----V--------------------------------------------------------
| 0.0 , 0.0 | 1.0 , 0.0 | 2.0 , 0.0 | 3.0 , 0.0 | 4.0 , 0.0| etc..
|------------|------------|------------|------------|-----------|
| 0.0 , 1.0 | 1.0 , 1.0 | 2.0 , 1.0 | 3.0 , 1.0 | 4.0 , 1.0| etc..
|------------|------------|------------|------------|-----------|
| 0.0 , 2.0 | 1.0 , 2.0 | 2.0 , 2.0 | 3.0 , 2.0 | 4.0 , 2.0| etc..
|------------|------------|------------|------------|-----------|
| 0.0 , 3.0 | 1.0 , 3.0 | 2.0 , 3.0 | 3.0 , 3.0 | 4.0 , 3.0| etc..
|------------|------------|------------|------------|-----------|
| 0.0 , 4.0 | 1.0 , 4.0 | 2.0 , 4.0 | 3.0 , 4.0 | 4.0 , 4.0| etc..
-----------------------------------------------------------------
\0.0,5.0 etc..

The vertex index on the above mesh surface is arranged like so: (as it is a 6x6 vertex layout):

0 . 1 . 2 . 3 . 4 . 5 .
6 . 7 . 8 . 9 .10.11.

etc.etc.