Setting textures on TerrainQuad

Hi.

I’ve pretty much got runtime terrain generation working by extending @jayfella’s code, but have come up against an issue setting textures on to terrain patches.

I am creating a TerrainChunk (which extends TerrainQuad) at tile size 17, block size 65, which gives 16 patches.
On each patch I want to set a map texture which has a raw image size of 256 pixels, but can see that only the first 64 pixels from the image is being displayed in one patch.

Is there away of resetting/ changing the texture coordinates on the quad or patch to accept the large® image. I don’t want to create patches of 256+1 as this will make an enormous mesh.

Many thanks.

Okay, relatively simple after looking at the TerrainPatch code;
[java]
private void increaseTextureSize(TerrainPatch patch, float multBy) {

	FloatBuffer tfb = patch.getMesh().getFloatBuffer(Type.TexCoord);
	float[] texCoord = BufferUtils.getFloatArray(tfb);
	for (int i=0; i < texCoord.length; i++) texCoord[i] *= multBy;
	tfb = BufferUtils.createFloatBuffer(texCoord);
	patch.getMesh().setBuffer(Type.TexCoord, 2, tfb);
	
}

[/java]

Not quite so straight forward…

Apply this to each patch results in only one patch receiving a correctly sized texture; the others appear to be have a single line of pixels stretched across the patch.

The Material is set independently on each patch by getMaterial().clone(), so not sure why this would be happening.

Any thoughts would be appreciated…

Stretched pixels is either that the texture coordinates are getting messed up or that wrap mode is not set to repeat.

I don’t really know enough about the surrounding code but if multBy is more than 1 then it implies that you are shrinking the texture…and therefore it will need to repeat.

Awesome - It was the Wrap.Repeat mode not set.

Many thanks @pspeed

Incidentally, my ‘function’ is easily replaced with
[java]patch.getMesh().scaleTextureCoordinates( new Vector2f(textureScale, textureScale) );[/java]