0

I have 6 textures I would like to load on 6 different faces of a cube. I'm trying to make a new texture by using GLGE.TextureCube();. And then I load all six images to the faces the supposedly should be on the cube like so

    mapTex = new GLGE.TextureCube();
    mapTex.setSrcNegX("models/map/negx.jpg"); // they are all 1024x1024
    mapTex.setSrcNegY("models/map/negy.jpg");
    mapTex.setSrcNegZ("models/map/negz.jpg");
    mapTex.setSrcPosX("models/map/posx.jpg");
    mapTex.setSrcPosY("models/map/posy.jpg");
    mapTex.setSrcPosZ("models/map/posz.jpg");

And then I add the texture to the Wavefront object. However, it seems only one of the 6 texture images is getting mapped and its mapped incorrectly.

My guess is that when it creates the new texture map out of the other 6, it tiles them beside each other so the new texture map's co-ordinates no longer correspond to that my obj file.

How can I properly combine 6 textures to one map to be used with GLGE? Or is there a way to manually load a texture on a face of a Mesh?

cdiggins
  • 17,602
  • 7
  • 105
  • 102
Zeeno
  • 2,671
  • 9
  • 37
  • 60

2 Answers2

2

Cube maps are somewhat special, as the usual UV (ST) texture coordinates don't work for them. A cube map, the name suggests it, consists of 6 quadratic textures, arranged as the faces of a cube. The texture coordinates are not absolute positions on the cube's faces, but directions from the center of the cube away, and the position where a ray from the center in the given direction hits the cube, is the position of the texture on that particular face.

If you apply texture coordinates with the third coordinate being zero, like those in Wavefront, you will address only a slice of the cube's face, namely the part that intersects with the XY plane. If you want to see a working cubemap in action, use the object's smooth normals as texture coordinates.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Would it then be possible to create 6 different textures and then map them to specific faces on the Mesh? – Zeeno Sep 12 '11 at 11:59
  • @ZOMG-A-KITTEH: Of course this is possible. However, you still can use a cubemap then. By setting one coordinate +/-1, the other two act like regular 2D texture coordinates. So ultimately you need to store the to be uses cubemap face in addition to 2D texture coordinates. – datenwolf Sep 12 '11 at 13:55
  • 1
    @ZOMG-A-KITTEH: I just saw your other question, about streetview like application. Cubemaps are ideal for this kind of thing. – datenwolf Sep 12 '11 at 13:56
  • Thanks for the info. What I ended up doing actually was splitting the cube into 6 separate meshes (its sideS) and then mapped the textures to those faces. Looks exactly like a google map app :-) – Zeeno Sep 13 '11 at 13:32
0

You'll need to use a different texture coordinate, eg: materialLayer.setMapinput(GLGE.MAP_OBJ) depending on what you want try GLGE.MAP_OBJ,GLGE.MAP_NORM or GLGE.MAP_ENV

  • If I set the mapping type to any of the types you suggested, how would I be able to specify the face that a texture should be mapped to? – Zeeno Sep 13 '11 at 13:30