import java.io.InputStreamReader;\r
import java.util.ArrayList;\r
import java.util.List;\r
-import java.util.StringTokenizer;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
\r
import com.badlogic.gdx.math.Vector3;\r
import com.badlogic.gdx.math.collision.BoundingBox;\r
int currMesh = 0;\r
\r
while ((line = reader.readLine()) != null) {\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) continue;\r
\r
//\r
if (tokens.get(0).equals("joints")) {\r
for (int i = 0; i < model.baseSkeleton.numJoints; i++) {\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) {\r
i--;\r
continue;\r
\r
while (!line.contains("}")) {\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) continue;\r
\r
if (tokens.get(0).equals("shader")) {\r
float[] animFrameData = null;\r
\r
while ((line = reader.readLine()) != null) {\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) continue;\r
-\r
if (tokens.get(0).equals("MD5Version")) {\r
if (!tokens.get(1).equals("10"))\r
throw new IllegalArgumentException("Not a valid MD5 animation file, version is " + tokens.get(1)\r
+ ", expected 10");\r
- }\r
-\r
+ } \r
if (tokens.get(0).equals("numFrames")) {\r
int numFrames = parseInt(tokens.get(1));\r
animation.frames = new MD5Joints[numFrames];\r
if (tokens.get(0).equals("hierarchy")) {\r
for (int i = 0; i < jointInfos.length; i++) {\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0 || tokens.get(0).equals("//")) {\r
i--;\r
continue;\r
if (tokens.get(0).equals("bounds")) {\r
for (int i = 0; i < animation.bounds.length; i++) {\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) {\r
i--;\r
continue;\r
if (tokens.get(0).equals("baseframe")) {\r
for (int i = 0; i < baseFrame.length; i++) {\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
if (tokens.size() == 0) {\r
i--;\r
continue;\r
\r
int i = 0;\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
while (tokens.get(0).equals("}") == false) {\r
for (int j = 0; j < tokens.size(); j++)\r
animFrameData[i++] = parseFloat(tokens.get(j));\r
\r
line = reader.readLine();\r
- tokenize(line, tokens);\r
+ MD5Tokenizer.tokenize(line, tokens);\r
}\r
\r
buildFrameSkeleton(jointInfos, baseFrame, animFrameData, animation, frameIndex);\r
}\r
}\r
-\r
return animation;\r
} catch (Exception ex) {\r
ex.printStackTrace();\r
}\r
}\r
}\r
-\r
- private static void tokenize (String line, List<String> tokens) {\r
- tokens.clear();\r
- StringTokenizer tokenizer = new StringTokenizer(line);\r
- while (tokenizer.hasMoreTokens())\r
- tokens.add(tokenizer.nextToken());\r
- }\r
-\r
+ \r
static class JointInfo {\r
public String name;\r
public int parent;\r