I'm having some pretty severe texture mapping
problems and I can't see what's wrong. At http://www.users.qwest.net/~kduling/Milkshape/
at the bottom of the page is a screenshot illustrating the problem. It
seems that the first triangle is fine, but after that, it's
unpredictable.
The block of code I'm having trouble with is
this:
for (int
j = 0; j < mesh.getTriangleCount();
j++)
{ final int triangleIndex = mesh.getTriangleIndicies()[j]; final MS3DTriangle triangle = triList[triangleIndex]; final float s[] = triangle.getS(); final float t[] = triangle.getT(); final TexCoord2f texCoords[] = new TexCoord2f[3]; for (int k = 0; k < 3; k++) { final int index = triangle.getVertexIndicies()[k]; final Vector3f normals[] = triangle.getVertexNormals(); final MS3DVertex vertex = vertList[index]; triangles.setCoordinate(vertexCount, vertex.getLocation()); triangles.setNormal(vertexCount++, normals[k]); if (bTextureInfo) { texCoords[k] = new TexCoord2f(s[k], t[k]); System.out.println("coords: " + texCoords[k].toString()); } } System.out.println("--------------"); if (bTextureInfo) triangles.setTextureCoordinates(0, j, texCoords); The texture coordinates are being loaded in from a
file. Printing them out for the cube shows this:
coords: (0.0, 1.0)
coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 1.0) coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 1.0) coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 1.0) coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 1.0) coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 1.0) coords: (0.0, 0.0) coords: (1.0, 1.0) -------------- coords: (0.0, 0.0) coords: (1.0, 0.0) coords: (1.0, 1.0) -------------- |
- [JAVA3D] Retriving Viewing parameters Kevin J. Duling
- [JAVA3D] Retriving Viewing parameters Juan Miguel