Repeating / tiling a texture from imported ogre model

I’ve managed to work out how to import models with textures into jme3 using ogre, but I want to tile the UV texture and set the wrapping parameters etc.

I could set the repeats for the texture in blender ok, but wasn’t showing up in jme3 - however, I still want to dynamically change the repeats within jme3 code wise.

The imported model is a spatial - so how do I access its material/texture properties?


Only terrain.j3md material supports tiling as far as i know.

The only solution here is in shaders, you would need to “copy” the lighting mat def (and shaders) and add the tiling support to it.

thanks, will look into just making my own materials rather than importing.

There’s a method called scaleTextureCoordinates() on Mesh that you can use to tile your UV coords

Momoko_Fan said:
There's a method called scaleTextureCoordinates() on Mesh that you can use to tile your UV coords

:O didn't know that!!

ok still can’t get things working…

I created my own material and texture, then switched WrapMode to repeat, scaled down the size of the texture hoping it would repeat but just got weird results. This might have to do with how the UV coords were imported, not sure. Giving up on this method.

Nehon - not sure how to go about creating my own lighting mat def and adding tiling support - is it easy?

scaleTextureCoordinates() would be perfect - but I’m using an imported model on a spatial,

is there a way I can access the geom/mesh or extract somehow from a spatial?

looks like I’ll have to build my own custom mesh internally so that I can freely play with tex coords and tiling.

Yhea use Kirill’s method it’s a lot more simpler.

your imported spatial is a Node probably, try to get the first child it should be your geometry, and you can get the mesh from it.

yes managed to get it basically working,

I cast the spatial as a new node, got its first child (geometry), and then could do everything from there, including scaleTextureCoordinates().


ok next little question,

I want to tile the texture in one direction only, so for example, if I have a cube, the top is 1x1, but the sides are say 1x10 (repeating 10 times in Y).

Is it possible to use a single mesh to accomplish this? - I’ve been looking at multi texturing and wondering how to apply different materials to different parts of the mesh (so that I can independently scale the tex coords). Would this require creating multiple UV maps in blender - and can jme3 handle multiple uv maps/tex coords?

I could easily split the mesh of course, and take the top of the cube by itself, but as I’m creating a lot of copies of the geometry, there would be less vertices by having a single mesh.

sorry and thanks…

The scaleTextureCoordinates takes a Vector2f, just specify 1,10 instead of whatever else you specify and it will work