Hi-
I am using the NCSA Portfolio classes to load a .dxf file.
Once I get the file, it is pretty easy to get the BranchGroup
using the Scene.getSceneGroup() and the Shape3D's using
BranchGroup test = s.getSceneGroup();
Shape3D testShape = (Shape3D) test.getChild(1);
Now I want to add some texture coordinates and put the textures on the
different Shape3D's. I use the following:
GeometryArray geo = (GeometryArray) testShape.getGeometry();
geo.setCapability(GeometryArray.ALLOW_TEXCOORD_WRITE);
geo.setCapability(GeometryArray.ALLOW_TEXCOORD_READ);
testShape.setAppearance(app);
System.out.println("vertex: " + geo.getValidVertexCount());
int npoints = geo.getValidVertexCount();
float[] texCoords = new float[npoints];
float[] coords = new float[npoints];
geo.getCoordinate(0, coords);
texCoords[0] = 0.f;
texCoords[npoints-1]=1.f;
for (int ii=1; ii<npoints-1; ii++)
texCoords[ii] = (float) (ii/npoints);
}
Finally, I try to set the texture coordinates. This is where the error
occurs:
geo.setCapability(GeometryArray.TEXTURE_COORDINATE_2);
geo.setTextureCoordinate(0,0,texCoords);
The error is:
vertex: 25760
java.lang.ArrayIndexOutOfBoundsException: GeometryArray: has no texture
coordinates
at
javax.media.j3d.GeometryArrayRetained.setTextureCoordinates(GeometryArrayRet
ained.java:3834)
at
javax.media.j3d.GeometryArray.setTextureCoordinate(GeometryArray.java:1871)
at DXFLoadEx.createSceneGraph(DXFLoadEx.java:102)
at DXFLoadEx.<init>(DXFLoadEx.java:179)
at DXFLoadEx.main(DXFLoadEx.java:194)
---
My question is (finally):
How can I add the texture coordinates if they don't exist already on the
GeometryArray?
Thanks--
Alex
===========================================================================
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".