WrapMode on Boxes

Hey,



i’ve got a problem; i want to build a ground for my game. This ground has a Texture, and i want to repeat the Texture:



[java]

Box box2 = new Box(Vector3f.ZERO, 500f,0f,500f);



Material mat_stone = new Material(

assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);



Texture stone = assetManager.loadTexture(“Textures/texture001.png”);

stone.setWrap(WrapMode.Repeat);



mat_stone.setTexture(“ColorMap”, stone);



mat_stone.getTextureParam(“ColorMap”).getTextureValue().setWrap(WrapMode.Repeat);



Spatial ground = new Geometry(“Box2” , box2 );



ground.setMaterial(mat_stone);

ground.setLocalTranslation(0f,-5f,0f);

rootNode.attachChild(ground);

[/java]



I’ve tried all wrap-modes, nothing. My texture is a tile, and i want to repeat it. Any ideas?



Tom

you have to scale the texture coordinates

[java]

box2.scaleTextureCoordinates(new Vector2f(howManyTimesRepeatedOnX,howManyTimesRepeatedOnY));

[/java]

you also have to set the wrapMode to repeat like you did.

1 Like

It works, thanks alot :smiley: