Setting texture to always be the same size?

I have a box, and I made a Geometry, but the problem is, it stretches the texture. I tried

[java]box.scaleTextureCoordinates(…);

geometry.setWrapMode(WrapMode.Repeat);[/java]

But it only works for 2 sides of the box (the front and back, because I just divided the box width/height and the image width/height) How can I make it do the texture is always the original size, no matter what size the box is?

Not sure I’m understanding you correctly. Are you asking how you scale the box and have the texture remain the same size?



Seeeeeew… if you make a box that is 0.2f x 0.2f…

and change the box to 0.4f x 0.4f… (twice the size)

You would scale the texture coords by 0.5f x 0.5f (half of what it was)



If you were to change the box size from 0.2f x 0.2f to 0.8f x 0.8f

You would scale the texture coords to 0.25f x 0.25f (a fourth of what it was)



Or if you need it to be dynamic…

You start scaling the box upward from 0.2f (I’m gonna use larger steps)

[java]//Pseudo code…

float scaleDifference, originalSize, newSize;



originalSize = box.getSize();



// change the size;

newSize = someNewVector2f

box.setSize(newSize);



scaleDifference = newSize-orginalSize;



box.scaleTextureCoordinates(1.0f-scaleDifference);

[/java]



This works from 0.0 to 1.0… so set a scale you plan on working with… (i.e. boxes start from 1f or 10f, so you know what to divide scaleDifference by, etc) I’ll leave it to you to make it work for sizes past that.



Why do get the feeling this isn’t what you were asking? >.<

Ya know… I have no clue how scaleTextureCoordinates works… did you read the JavaDocs? hahahaha