Well it looks like setTextureCoordinate(2, 0, new TexCoord2f(x,y)) and setTextureCoordinate(3, 0, new TexCoord2f(x,y)) is similar to passing no coordinates at all.
Can anyone confirm this?
I enabled TexCoord3f in xith3D since they’re critical to my being-delayed-due-to-some-bug demo that uses fragment and vertex shader as I can load more useful info into the GPU than I can ever do with the Tuple2f components.
JCD, try setting the number of texture sets to whatever number you desire in the creation of your geometry object. I have sample code for you at my office if you need it. I can hook you up with it tomorrow. ;D
What worked for me was something along the lines of:
IndexedTriangleArray myGreatBigArray(
bigNumber,
GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2,
4,
new int[] {0,0,0,0},
someOtherBigNumber);
Once you have the geo array setup right, then setting up the textureCoordinates should work as expected.
Already got that part working mate (4, new int[]{0,1,2,3}) it’s just that the texCoord at unit 2 and 3 (0 being the first) would transfer 0’s to the GPU.
Have you gotten more than 2 textures to work with a shape3D at once?
Yes, currently in my project for work, I have 4 textures loaded onto the terrain. One, being tiled across 16 per side, and 3 others stretched all the way across. I’m at home today but when I get to the office tomorrow, I’ll send you sample code.
The only thing I’m having trouble with is getting large textures working. I know my card supports very large textures (Radeon 9800 pro) but the largest I can get to show up in Xith is 2048. I know I had 4096 (and beyond) working in gl4java. I think, to get the resolution I need, I’m going to have to cut up the textures and tile them.
IndexedTriangleArray torusGeometry = new IndexedTriangleArray(torusVertices.length,
GeometryArray.TEXTURE_COORDINATE_3 |
GeometryArray.COORDINATES |
GeometryArray.NORMALS,
4,
new int[]{0,1,2,3},
indices.length);
torusGeometry.setIndex ( indices );
torusGeometry.setNormals ( 0, torusNormals );
torusGeometry.setCoordinates ( 0, torusVertices );
torusGeometry.setValidIndexCount ( indices.length );
torusGeometry.setTextureCoordinates(0,0, convert2fto3f );
torusGeometry.setTextureCoordinates(1,0, convert2fto3f );
torusGeometry.setTextureCoordinates(2,0, convert2fto3f );
torusGeometry.setTextureCoordinates(3,0, convert2fto3f );
That’s how I set up my coordinates and yet, when I got into the vertex shader and do
MOV result.texcoord[0], vertex.texcoord[2];
MOV result.texcoord[1], vertex.texcoord[3];
All I see is that gray uniform look accross the shape
Now doing
MOV result.texcoord[0], vertex.texcoord[1];
MOV result.texcoord[1], vertex.texcoord[0];
Works like a charm keeping in mind that texcoord[0-3] are all set to the same values
Offhand, I would say your code looks much like what I have at the office, although I know I played around with transparency attributes, etc. I’ll post code first thing tomorrow morning (Eastern Standard Time).
off to bed, but will be checking this thread first thing tomorrow morning.
I truly need functional binding of the third and 4th texture coordinates.
Nighty night
Sorry, I know it’s not quite first thing, but here goes. Keep in mind, I’m not real sure what parts of my code are required and what parts are just me searching for something that works (in terms of transparency attributes and texture attributes). All I know is that this code allowed me to have 5 textures applied to the shape3d at one time and I’m happy. 
Geometry generation:
geo = new IndexedTriangleArray(
MAX_VERTICES,
GeometryArray.COORDINATES |
GeometryArray.NORMALS |
GeometryArray.COLOR_3 |
GeometryArray.TEXTURE_COORDINATE_2 |
GeometryArray.BY_REFERENCE,
5,
new int[5],
MAX_INDICES);
Texture attributes:
TextureAttributes[] textureAttrs = new TextureAttributes[5];
textureAttrs[0] = new TextureAttributes();
textureAttrs[0].setTextureMode(TextureAttributes.NICEST);
textureAttrs[1] = new TextureAttributes();
textureAttrs[1].setTextureMode(TextureAttributes.NICEST);
textureAttrs[2] = new TextureAttributes();
textureAttrs[2].setTextureMode(TextureAttributes.NICEST);
textureAttrs[3] = new TextureAttributes();
textureAttrs[3].setTextureMode(TextureAttributes.NICEST);
textureAttrs[4] = new TextureAttributes();
textureAttrs[4].setTextureMode(TextureAttributes.NICEST);
Texture unit state:
TextureUnitState[] texUnitState = new TextureUnitState[5];
texUnitState[0] = new TextureUnitState(detailTexture, textureAttrs[0], null);
texUnitState[1] = new TextureUnitState(oceanTexture, textureAttrs[1], null);
texUnitState[2] = new TextureUnitState(roadTexture, textureAttrs[2], null);
texUnitState[3] = new TextureUnitState(contourTexture, textureAttrs[3], null);
texUnitState[4] = new TextureUnitState(inlandWaterTexture, textureAttrs[4], null);
Transparency attributes:
TransparencyAttributes transAttr = new TransparencyAttributes();
transAttr.setMode(TransparencyAttributes.BLENDED);
transAttr.setTransparency(0.3f);
Appearance:
Appearance a = new Appearance();
pa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL,PolygonAttributes.CULL_BACK,0);
a.setPolygonAttributes(pa);
a.setTransparencyAttributes(transAttr);
a.setTextureUnitState(texUnitState);
Shape:
shape = new Shape3D(geo,a);
Coordinate generation:
public void initVert(int i, float x, float y, float z) {
if(totalVerts>=MAX_VERTICES) return;
// Gots ta' generate our texture coordinates
int DetailTexScale=32;
int VPFTexScale=1;
float texCoordx, texCoordz;
texCoordx = x / (terrain.getWidth()/DetailTexScale);
texCoordz = z / (terrain.getWidth()/DetailTexScale);
TexCoord2f DetailTexCoord = new TexCoord2f(texCoordz, texCoordx);
texCoordx = x / (terrain.getWidth()/VPFTexScale);
texCoordz = z / (terrain.getWidth()/VPFTexScale);
TexCoord2f VPFTexCoord = new TexCoord2f(texCoordz, texCoordx);
geo.newVertex();
geo.setCoordinate(x,y,z);
geo.setTextureCoordinate(0, totalVerts, DetailTexCoord);
geo.setTextureCoordinate(1, totalVerts, VPFTexCoord);
geo.setTextureCoordinate(2, totalVerts, VPFTexCoord);
geo.setTextureCoordinate(3, totalVerts, VPFTexCoord);
geo.setTextureCoordinate(4, totalVerts, VPFTexCoord);
float c = y/(MAX_HEIGHT);
geo.setColor(0.66f+c,0.66f+c,0.57f+c);
vertexMap[i] = totalVerts++;
}
Thanks man, turned to be there is no bug or whatsoever. :
However in order for the GPU to access the n th texture coordinates, the n th textureUnitState parent itself has to contain even a null pointer to texture.
To put it in other words, if you intend to use TexCoord 3 & 4, your textureUnitState has resemble somthing like this:
appearance.setTextureUnitState(new TextureUnitState[]{
new TextureUnitState(loadTexture(base), null, null),
new TextureUnitState(loadTexture(dot3), null, null),
new TextureUnitState(null, null, null)});
That seems very odd to me. I’m just happy to have multi-texturing working the way I want it now. 