Hi,
I want a texture on my sphere, but i don’t want to spread it all over it, but place it on a special position. Is there any tutorial or hint about that?
p.s. it’s a big sphere, so i cant’t create one big texture which fullfills this job.
First you have to uv wrap you sphere to create the uv texture coordinates like that:
You can do it in a 3d modeling software like blender.
If you are going to do it in a 3d modeling software then after the uv texture coordinates are created, export it as an image and edit it in a image editor like photshop or gimp. There are a lot of tutorials in the internet how to map textures to a model, for blender i know a nice site : blendercookie.com. If you wanna do it manually in jmp then start by learning uv texture coordinates, but i don’t advise you to do it, it’s used internally by the engine.
Thanks for reply, i just found out an other exciting solution, based on the scaleTextureCoordinates function:
[java]
public class SphereWithMovableTexture extends Sphere {
public SphereWithMovableTexture(int i, int j, float f) {
super(i, j, f);
}
public void moveTextureCoordinates(Vector2f scaleFactor) {
VertexBuffer tc = getBuffer(Type.TexCoord);
if (tc == null)
throw new IllegalStateException("The mesh has no texture coordinates");
if (tc.getFormat() != VertexBuffer.Format.Float)
throw new UnsupportedOperationException("Only float texture coord format is supported");
if (tc.getNumComponents() != 2)
throw new UnsupportedOperationException("Only 2D texture coords are supported");
FloatBuffer fb = (FloatBuffer) tc.getData();
fb.clear();
for (int i = 0; i < fb.capacity() / 2; i++) {
float x = fb.get();
float y = fb.get();
fb.position(fb.position() - 2);
x += scaleFactor.getX();
y += scaleFactor.getY();
fb.put(x).put(y);
}
fb.clear();
tc.updateData(fb);
}
}
[/java]
Maybe it can be added to standard-functionality