I'm currently redeveloping an OBJ & MTL importer for my game engine. At the moment, I'm focusing on increasing how quickly I can parse large OBJ files.
For now, I can parse about 1.2M vertices, uvs and normals in around 4-6 seconds. Which is awesome, considering the file that I'm parsing, couldn't be parsed originally.
Anyways, on with my question; I want to be able to make the following method use a StringTokenizer instead of String array. The reason is because using String.split is slow and I want to parse the file relatively fast.
private OBJIndex parseIndex(String token)
{
String[] tokens = token.split("/");
OBJIndex result = new OBJIndex();
result.setVertexIndex(Integer.parseInt(tokens[0]) - 1);
if(tokens.length > 1)
{
if(!tokens[1].isEmpty())
{
hasUVs = true;
result.setUvIndex(Integer.parseInt(tokens[1]) - 1);
}
if(tokens.length > 2)
{
hasNormals = true;
result.setNormalIndex(Integer.parseInt(tokens[2]) - 1);
}
}
return result;
}
How would I go about doing this?