How can i wrap a texture (for ex a 4x4 pixels) on a box (1x1x1) in such a way that the texture is repeated and not enlarged to cover all the surface.

 Geometry box = new Geometry("Box", new Box(1f,1f,1f));

Try this:

Geometry box = new Geometry("Box", new Box(1f, 1f, 1f));
Material woodMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); //create a simple material
Texture tex = assetManager.loadTexture(new TextureKey("Models/guide.png", false));
tex.setWrap(Texture.WrapMode.Repeat); //This should set the texture to repeat.
woodMat.setTexture("ColorMap", assetManager.loadTexture(tex)); // with Unshaded.j3md
woodGeom.setMaterial(woodMat);                   // set the cube's material

Let me know if it works :)

(Note, I'm new to jMonkeyEngine myself, so this might not work. Good luck!)

NOTE: You might have to tinker with using:

box.scaleTextureCoordinates(new Vector2f(0.5f, 0.5f));

This will scale the texture to your liking.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.