use of maspack.geometry.io.WavefrontReader in project artisynth_core by artisynth.
the class WavefrontToMaya method doFiberExport.
public static void doFiberExport(String inputFile, String outputFile, NumberFormat fmt) {
PrintStream out;
WavefrontReader wfr;
String outputFileName = "unknown";
// output stream
if (outputFile == null) {
out = System.out;
} else {
try {
out = new PrintStream(outputFile);
} catch (IOException e) {
e.printStackTrace();
return;
}
outputFileName = outputFile.substring(outputFile.lastIndexOf(File.separator) + 1);
}
try {
wfr = new WavefrontReader(inputFile);
wfr.parse();
} catch (IOException e) {
e.printStackTrace();
return;
}
Date date = new Date();
DateFormat dateFormat = new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ss z");
// maya header
out.println("//Maya ASCII 2012 scene");
out.println("//Name: " + outputFileName);
out.println("//Last modified: " + dateFormat.format(date));
out.println("//Codeset: 1252");
out.println("requires maya \"" + requiresMayaVersion + "\";");
int lineNum = 0;
for (String groupName : wfr.getPolylineGroupNames()) {
wfr.setGroup(groupName);
ArrayList<Point3d> vtxList = new ArrayList<Point3d>();
int[][] indices;
try {
indices = wfr.getLocalLineIndicesAndVertices(vtxList);
} catch (IOException e) {
e.printStackTrace();
continue;
}
for (int i = 0; i < indices.length; i++) {
lineNum++;
String lineStr = stringifyPolyline(indices[i], vtxList, "curve" + lineNum, fmt);
out.print(lineStr);
}
}
// maya footer
out.println("// End of " + outputFileName);
if (out != System.out) {
out.flush();
out.close();
}
}
Aggregations