My terrain texture doesn't tile!


I'm using the code from the flag rush tutorials (more specifically  (the buildTerrain() method)).

But, when I run it my texture gets applied to the whole map ONCE… that is, if my map is 64x64, then my texture goes from 0,0 to 64,64… instead of 0,0 and 1,1 … and so on. It doesn't repeat/tile or whatever, I hope you understand.

Any ideas?

As you can see, that single texture somehow gets stretched over all the tiles in the terrain, which I clearly don’t want. No way to change this?

set the wrap mode to Texture.WM_WRAP_S_WRAP_T

Setting the wrap mode is not enough. You'll also have to scale the texture or change the texture coordinates.

oh, sorry, forgot that  :expressionless:

if you want your texture to repeat 10 times, you'll have t set the texture scale to something like new Vector3f(10, 10, 10). of course you're not bound to using uniform scaling but it just looks better :slight_smile:


Maybe this should be added to the tutorial, since it's only 1 line of code that is missing! Took me hours to figure this out.  Texture.setScale() not very descriptive… :confused:

yes… I was trying to do the same thing now and couldn't do it with only wrap like in tutorial, and then found this… setScale solved the problem

…and sorry for necroing, but had to mention that problem is still there

it's not a problem, it's just the way to do it.

I'm talking about missing line in the tutorial… it's not working as it supposed to (or maybe not?)

hmmm. the tutorial doesn't mention texture tiling, so in that sense it's nothing wrong with it. but you could add a note about tiling if you want to.