protected void readUseMaterial(StringTokenizer tokenizer) { String material = null; if (tokenizer.hasMoreTokens()) { material = tokenizer.nextToken(); obj.addElement((ObjDrawable) obj.getMaterial(material)); } }
protected void readFace(StringTokenizer tokenizer) throws ObjFormatException { ObjFace face = new ObjFace(obj); while (tokenizer.hasMoreTokens()) { StringTokenizer t = new StringTokenizer(tokenizer.nextToken(), "/", true); int v = -1, vt = -1, vn = -1; if (t.hasMoreTokens()) { v = Integer.parseInt(t.nextToken()); } // The next token must be a slash. if (t.hasMoreTokens()) { String next = t.nextToken(); if (next.compareTo("/") != 0) { throw new ObjFormatException("Expected a slash at line " + reader.getLineNumber()); } } // If the next token is a number, then we have a // texture vertex to read. If it is a slash, then // we should skip ahead to the normal. if (t.hasMoreTokens()) { String next = t.nextToken(); if (next.compareTo("/") != 0) vt = Integer.parseInt(next); } if (t.hasMoreTokens()) { vn = Integer.parseInt(t.nextToken()); } face.add(v, vt, vn); } obj.addElement(face); }
protected void readNormal(StringTokenizer tokenizer) { double x = 0.0, y = 0.0, z = 0.0; if (tokenizer.hasMoreTokens()) x = Double.parseDouble(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) y = Double.parseDouble(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) z = Double.parseDouble(tokenizer.nextToken()); obj.addElement(new ObjNormal(x, y, z)); }
protected void readVertex(StringTokenizer tokenizer) { double x = 0.0, y = 0.0, z = 0.0, w = 0.0; if (tokenizer.hasMoreTokens()) x = Double.parseDouble(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) y = Double.parseDouble(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) z = Double.parseDouble(tokenizer.nextToken()); if (tokenizer.hasMoreTokens()) w = Double.parseDouble(tokenizer.nextToken()); obj.addElement(new ObjVertex(x, y, z, w)); }