I have been looking through the documentation and the wiki and haven’t been able to find anything that discusses what I am trying to achieve. Maybe I missed it.
Say, for example, I have an Image, say 500 by 500 and I wish the Geometry to be mapped to a region “sub image” of say 100 by 100. During rendering this sub image changes in size and location giving an altering texture effect. Ideally, only one image should be loaded into the card and sub images of that are used as textures as there will be countless sub images with differing parameters.
The function below is pretty much the equivalent as it only requires one set of data…
BufferedImage.getSubimage(int x, int y, int w, int h);
As a workaround I could alter the texture mappings on the fly but that doesn’t seem like an ideal approach.
I will very much appreciate if someone could offer a suggestion on how to achieve my goal.
pspeed, TextureAtlas could be the answer. I was unable to determin how I should use TextureAtlas to achieve my goal. Is there an example somewhere of TextureAtlas usage I could use to get a better understanding?
A texture atlas is an abstract concept, its basically a texture with separate images in multiple areas. If you have for example a texture with four quarters each representing one image you’d set the texture coordinates of your mesh to 0-0.5 to use the upper left quarter. 0.5-1 for the lower left etc.
That sounds like sprite animations, and should be done on the gpu without modifying vertex data.
Or you could pass a Vector2f showing the real texture coordinates as material parameters to your shaders…
I delved into the source code and the utility that allowed me to render parts of a texture did in fact use a mesh and created the effect by altering the texture mappings.
I was quite happy with its performance so maybe I will extend Picture to include this ability.
jmaasing and zzuegg, is there an example codelet that demonstrates or similar to your suggested usage?
Thanks everyone for your help and advice. At this stage unless something better comes along it looks like I will be extending Picture to include the ability to alter the texture mapping of the quad to give the effect of displaying a sub image of the texture image.