Hello there,
I have a Box with a jpg texture on it. I set the wrapmode to repeat with “wall.setWrap(Texture.WrapMode.Repeat);” but the texture is not repeating and just spreads all along the box so the texture is distorted… I don’t get it.
Sorry if I missed a post with a similar problem…
Thanks for your time !
A screen shot would help visualize the problem.
1 Like
sure thing ! here :
what I want the texture to look like :
what it looks like when I stretch the textured box :
http://i.imgur.com/2h503.png
And this despite the
wall.setWrap(Texture.WrapMode.Repeat);
line I put when I created the box and applied the texture to it.
Thanks for helping !
@lewisgreen said:
And this despite the
wall.setWrap(Texture.WrapMode.Repeat);
line I put when I created the box and applied the texture to it.
Thanks for helping !
Code... We need code.
Alternatively, have you tried not setting anything? I don't use cube, so I have can't say I have experimented with texturing them.
1 Like
I did not put code since it is exactly like in the tutorial for texturing a Box.
Anyway, here it is :
public class Wall {
public Box box;
public Geometry geom;
public Material mat;
public RigidBodyControl body;
public Wall(AssetManager assetManager, Vector3f position, int sizeX, int sizeY, int sizeZ){
//set the wall shape
box = new Box(Vector3f.ZERO, sizeX, sizeY, sizeZ);
geom = new Geometry("Box", box);
geom.setLocalTranslation(position);
mat = new Material(assetManager, "Unshaded.j3md");
geom.setMaterial(mat);
//set the texture
Texture wall = assetManager.loadTexture("walls.jpeg");
wall.setWrap(Texture.WrapMode.Repeat);
mat.setTexture("ColorMap", wall);
//make the wall physical
body = new RigidBodyControl(0.0f);
geom.addControl(body);
}
}
it is a class I use to build textured walls in my scene. So in my main scene class I have a collection of walls, Later on I will implement all sorts of detections using swing.
Not setting anything does not change a thing. It seems like the wrapmode is ignored even if the set line is here...
you have to scale the texture coordinates too
[java]
box.scaleTextureCoordinate(new Vector2f(howManyTimesIwantMyTextureToRepeatOnX,howManyTimseIwantMyTextureToRepeatOnY));
[/java]
2 Likes