Hi,
i try to set Color to every Triangle explicitily. (Code at the end)
Without setColor it works fine an i see two Triangles in the canvas3D.
But if i try to set the Colors i got following error ..
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
GeometryArray: has no colors
at javax.media.j3d.GeometryArray.setColor(GeometryArray.java:1279)
at ipbmesh.SimpleMeshViewer.insertMesh(SimpleMeshViewer.java:218)
at ipbmesh.SimpleMeshViewer.createSceneGraph(SimpleMeshViewer.java:155)
How i can solve this problem, that IndexedTriangleArray instanciate a
ColorTable ?
Thanks for Help
Richard
########################################
Transform3D translate = new Transform3D();
translate.setTranslation (new Vector3d (0, 0, -10));
TransformGroup objTranslate = new TransformGroup(translate);
IndexedTriangleArray ta = new
IndexedTriangleArray(6,GeometryArray.COORDINATES,6);
double[] ca1 = {0.0,0.0,0.0};
double[] ca2 = {1.0,1.0,1.0};
double[] ca3 = {1.0,2.0,2.0};
double[] ca4 = {2.0,4.0,1.0};
double[] ca5 = {2.0,4.0,9.0};
ta.setCoordinate(0,ca1);
ta.setCoordinate(1,ca2);
ta.setCoordinate(2,ca3);
ta.setCoordinate(3,ca4);
ta.setCoordinate(4,ca5);
int[] t1 = {0,1,2}; int[] t2 = {1,3,4};
ta.setCoordinateIndices(0,t1);
ta.setCoordinateIndices(1,t2);
ta.setColor(0, new Color3f(100 , 100, 10));
ta.setColor(1, new Color3f(100,100,10));
Shape3D shape = new Shape3D (ta);
objTranslate.addChild(shape);
########################################
Christian Wiech - 04 May 2004 06:48 GMT
> Hi,
>
[quoted text clipped - 22 lines]
> IndexedTriangleArray ta = new
> IndexedTriangleArray(6,GeometryArray.COORDINATES,6);
> double[] ca1 = {0.0,0.0,0.0};
> double[] ca2 = {1.0,1.0,1.0};
[quoted text clipped - 17 lines]
>
> ########################################
Hi
In the constructor you have to specify the vertexFormat. It is a bitmask.
See the javadoc for more info.
This should work:
IndexedTriangleArray ta = new
IndexedTriangleArray(6,GeometryArray.COORDINATES |
GeometryArray.COLOR_3,6);
Cheers
Christian