hi
If you create your own object with triangles, you have to somehow tell the engine how to map a texture's picture information on to that object. This can be done by assigning UV coordiantes(UV really being x and y coordinates in % in a texture-> between 0 and 1) to the 3d geometry(vertices).
There several ways to assign UV coordiantes to your geometry:
You can do it like Kearnan, and let the engine calculate it for you(which might sometimes look a bit wierd), or by adding this information together with the vertices information of the triangle(often the case when using model loaders).
Following a simple example of a selfmade cube(probably the most awkward way of doing it heh). It only maps a texture on the two top triangles of the box. I'd go with automatic mapping though^^
/** Creates a box, which maps any given texture on to the top of the box */
public static Object3D createBoxTextTop(float size, int texId)
{
Object3D box = new Object3D(12);
SimpleVector[] sv = new SimpleVector[8];
/* The 8 vertices of the box */
sv[0] = new SimpleVector(0, 0, 0);
sv[1] = new SimpleVector(size, 0, 0);
sv[2] = new SimpleVector(size, size, 0);
sv[3] = new SimpleVector(0, size, 0);
sv[4] = new SimpleVector(0, 0, size);
sv[5] = new SimpleVector(size, 0, size);
sv[6] = new SimpleVector(size, size, size);
sv[7] = new SimpleVector(0, size, size);
/* Add the triangles counter-clockwise(so they face "outside") */
box.addTriangle(sv[0],sv[2],sv[1]);
box.addTriangle(sv[0],sv[3],sv[2]);
box.addTriangle(sv[1],sv[6],sv[5]);
box.addTriangle(sv[1],sv[2],sv[6]);
box.addTriangle(sv[5],sv[7],sv[4]);
box.addTriangle(sv[5],sv[6],sv[7]);
box.addTriangle(sv[4],sv[3],sv[0]);
box.addTriangle(sv[4],sv[7],sv[3]);
/* These are the 2 top triangles, which have a texture assigned(texId is the texture ID returned from a texmanager).
In this case its easy to map the texture, since the two triangles should show the whole texture
*/
box.addTriangle(sv[4], 0f, 0f, sv[1], 1f, 1f, sv[5], 1f, 0f, texId);
box.addTriangle(sv[4], 0f, 0f, sv[0], 0f, 1f, sv[1], 1f, 1f, texId);
box.addTriangle(sv[3],sv[6],sv[2]);
box.addTriangle(sv[3],sv[7],sv[6]);
return box;
}