Hi! I have approximately the following code creating an object I load from file. From the file I get a list of vertices with coordinates, normals and texture coordinates. I also get a list of triangles with references to 3 vertices in that list, a color for the triangle and a path to the texture used. With the following code I got everything to work with textures and all. The problem is performance. //////////////////////////////////////////////////////////////// Start of code //////////////////////////////////////////////// // Create an array of independant triangles TriangleArray[] myTriangles = new TriangleArray[numTriangles]; for (int i = 0; i < numTriangles; i++) { // Create this specific triangle myTriangles[i] = new TriangleArray(3, TriangleArray.COORDINATES | TriangleArray.COLOR_3 | TriangleArray.TEXTURE_COORDINATE_2 ); // Loop through the vertices for this triangle for (int vtx = 0; vtx < 3; vtx++) { // Set the coordinate myTriangles[i].setCoordinate(vtx, new Point3d(getXinSomeWay, getYinSomeWay, getZinSomeWay)); // Set the texture coordinate texCoords[0] = getUinSomeWay; texCoords[1] = getVinSomeWay; myTriangles[i].setTextureCoordinate(vtx, texCoords); } // Set the color for this triangle myTriangles[i].setColors(0, getTriangleColorInSomeWay); // Specify the texture TriangleAppear = new Appearance(); TriangleAppear.setTexture(textureArray[idxInTextureArray]); TriangleAppear.setTextureAttributes(textureAttrArray[idxInTextureAttrArray]); // Add the triangle to the scene graph objRoot.addChild(new Shape3D(myTriangles[i], TriangleAppear)); // Continue with next } //////////////////////////////////////////////////////////////// End of code //////////////////////////////////////////////// Now I'm trying to optimize my code. So I thought about using an IndexedTriangleArray to be able to reuse the vertices and that way getting better performance. With the following code I get it to work without color and textures. And it runs considerably faster. //////////////////////////////////////////////////////////////// Start of code //////////////////////////////////////////////// // Create the indexed triangle array with IndexedTriangleArray myTriangles = new IndexedTriangleArray(numVtx, GeometryArray.COORDINATES, numTriangles*3); // Set all the vertex coordinates for (int vi = 0; vi < numVtx; vi++) myTriangles.setCoordinate(vi, new Point3d(vertexList[vi].x, vertexList[vi].x, vertexList[vi].z) ); // Specify vertex indices for each triangle for (int f = 0; f < numTriangles; f++) for (int v = 0; v < 3; v++) myTriangles.setCoordinateIndex(f*3+v, triangleList[f].vtxList[v]); // Add the triangles to the scene graph objRoot.addChild(new Shape3D(myTriangles, null)); //////////////////////////////////////////////////////////////// End of code //////////////////////////////////////////////// But the problem is that I want to specify a color for each triangle and not per vertex. Also I want separate textures for each triangle but I only can have one Apperance for the whole Shape3D. What do I do? I'm pretty new to Java/Java3D so maybe I have misunderstood something; so please enlight me!! Thanks in advance! /Per Burstrom, Sweden
begin:vcard n:Burstrom;Per tel;fax:+46 278 186 23 tel;work:+46 278 639 209 x-mozilla-html:TRUE url:http://www.insite.se org:Insite adr:;;Lasarettsv. 126;SE-821 31 Bollnas;;;Sweden version:2.1 email;internet:[EMAIL PROTECTED] title:Senior programmer x-mozilla-cpt:;0 fn:Per Burstrom end:vcard