Hello everyone,
I've got problem with texturing GeometryInfo. I have cod like this:
Point3f p1 = new Point3f(0.5f, 0.5f, 0.0f); Point3f p2 = new Point3f(0.5f, 0.0f, 0.0f); Point3f p3 = new Point3f(0.3f, -0.3f, 0.0f);
Point3f p4= new Point3f(-0.3f, -0.3f, 0.0f); Point3f p5 = new Point3f(-0.5f, 0.0f, 0.0f); Point3f p6 = new Point3f(-0.3f, 0.3f, 0.0f);
Point3f[] table = new Point3f[6]; int[] stripCounts = {6}; table[0] = p1; table[1] = p2; table[2] = p3; table[3] = p4; table[4] = p5; table[5] = p6;
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); gi.setCoordinates(table); gi.setStripCounts(stripCounts);
Triangulator tr = new Triangulator(); NormalGenerator ng = new NormalGenerator(); Stripifier s = new Stripifier(); tr.triangulate(gi); ng.generateNormals(gi); s.stripify(gi);
There should never be any reason to use the Triangulator explicitly. It will get used as-needed automatically. See here:
http://www.j3d.org/tutorials/quick_fix/geom_info.html
/*tekstury*/ TexCoord2f t1 = new TexCoord2f(0.0f,1.0f); TexCoord2f t2 = new TexCoord2f(1.0f,1.0f); TexCoord2f t3 = new TexCoord2f(0.0f,0.0f); TexCoord2f t4 = new TexCoord2f(1.0f,0.0f); TexCoord2f t5 = new TexCoord2f(0.5f,0.0f); TexCoord2f t6 = new TexCoord2f(1.0f,0.5f); TexCoord2f[] texcoords = new TexCoord2f[5]; texcoords[0] = t1; texcoords[1] = t2; texcoords[2] = t3; texcoords[3] = t4; texcoords[4] = t5; //texcoords[5] = t6;
gi.setTextureCoordinateParams(1, 2);
gi.setTextureCoordinates(0, texcoords);
You need to set the texture coordinates *before* you generate normals and stripify. You always want to put all your geometry into the GeometryInfo at the start because the NormalGenerator and Stripifier are going to change them around. By the time you put in your texture coordinates, GeometryInfo had already converted your polygon into indexed triangle strips.
return gi.getGeometryArray();
Now , by the line return gi.getGeometryArray(); I get exception:
java.lang.IllegalArgumentException: Missing Index List.
HOW CAN I PROPERLY PUT TEXTURE COORDINATES ON GEOMETRYINFO OBJECT ???
It told you this because the GeometryInfo (at this point) is indexed triangle strips, and you set the texture coordinates without setting the texture coordinate indices. But don't worry about that - set the texture coordinates before you generate normals and stripify and you should be OK.
-Paul
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
