| 127 | |
| 128 | |
| 129 | protected void addChildren(ArrayList<OBJFace> faces, |
| 130 | ArrayList<OBJMaterial> materials, |
| 131 | ArrayList<PVector> coords, |
| 132 | ArrayList<PVector> normals, |
| 133 | ArrayList<PVector> texcoords) { |
| 134 | int mtlIdxCur = -1; |
| 135 | OBJMaterial mtl = null; |
| 136 | for (int i = 0; i < faces.size(); i++) { |
| 137 | OBJFace face = faces.get(i); |
| 138 | |
| 139 | // Getting current material. |
| 140 | if (mtlIdxCur != face.matIdx || face.matIdx == -1) { |
| 141 | // To make sure that at least we get the default material |
| 142 | mtlIdxCur = PApplet.max(0, face.matIdx); |
| 143 | mtl = materials.get(mtlIdxCur); |
| 144 | } |
| 145 | |
| 146 | // Creating child shape for current face. |
| 147 | PShape child = new PShapeOBJ(face, mtl, coords, normals, texcoords); |
| 148 | addChild(child); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | |
| 153 | static protected void parseOBJ(PApplet parent, String path, |