/** * The geometry definition is now finished so take the given field values and generate the * triangle output. * * @param ch The content handler instance to write to * @param sh The script handler instance to write to * @param ph The proto handler instance to write to * @param rh The route handler instance to write to */ void generateOutput(ContentHandler ch, ScriptHandler sh, ProtoHandler ph, RouteHandler rh) { // Set up the coordinate array and indices. ConeGenerator generator = new ConeGenerator(height, radius); GeometryData data = new GeometryData(); data.geometryType = GeometryData.INDEXED_TRIANGLES; data.geometryComponents = GeometryData.NORMAL_DATA | GeometryData.TEXTURE_2D_DATA; generator.generate(data); ch.startNode("IndexedTriangleSet", null); ch.startField("coord"); ch.startNode("Coordinate", null); ch.startField("point"); if (ch instanceof BinaryContentHandler) { ((BinaryContentHandler) ch).fieldValue(data.coordinates, data.coordinates.length); } else if (ch instanceof StringContentHandler) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.coordinates.length; i++) { buf.append(data.coordinates[i]); buf.append(' '); } ((StringContentHandler) ch).fieldValue(buf.toString()); } ch.endField(); // point ch.endNode(); // Coordinate ch.endField(); // coord ch.startField("index"); if (ch instanceof BinaryContentHandler) { ((BinaryContentHandler) ch).fieldValue(data.indexes, data.indexes.length); } else if (ch instanceof StringContentHandler) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.indexes.length; i++) { buf.append(data.indexes[i]); buf.append(' '); } ((StringContentHandler) ch).fieldValue(buf.toString()); } ch.endField(); // index if (!solid) { ch.startField("solid"); if (ch instanceof BinaryContentHandler) { ((BinaryContentHandler) ch).fieldValue(solid); } else if (ch instanceof StringContentHandler) { ((StringContentHandler) ch).fieldValue("FALSE"); } ch.endField(); // solid } ch.endNode(); // IndexedTriangleSet }