protected void addChildren(ArrayList<OBJFace> faces, ArrayList<OBJMaterial> materials, ArrayList<PVector> coords, ArrayList<PVector> normals, ArrayList<PVector> texcoords) { int mtlIdxCur = -1; OBJMaterial mtl = null; for (int i = 0; i < faces.size(); i++) { OBJFace face = faces.get(i); // Getting current material. if (mtlIdxCur != face.matIdx || face.matIdx == -1) { // To make sure that at least we get the default material mtlIdxCur = PApplet.max(0, face.matIdx); mtl = materials.get(mtlIdxCur); } // Creating child shape for current face. PShape child = new PShapeOBJ(face, mtl, coords, normals, texcoords); addChild(child); } }
public PShapeOBJ(PApplet parent, BufferedReader reader) { ArrayList<OBJFace> faces = new ArrayList<OBJFace>(); ArrayList<OBJMaterial> materials = new ArrayList<OBJMaterial>(); ArrayList<PVector> coords = new ArrayList<PVector>(); ArrayList<PVector> normals = new ArrayList<PVector>(); ArrayList<PVector> texcoords = new ArrayList<PVector>(); parseOBJ(parent, reader, faces, materials, coords, normals, texcoords); // The OBJ geometry is stored with each face in a separate child shape. parent = null; family = GROUP; addChildren(faces, materials, coords, normals, texcoords); }
/** * Initializes a new OBJ Object with the given filename. */ public PShapeOBJ(PApplet parent, String filename) { this(parent, parent.createReader(filename), getBasePath(parent, filename)); }
static protected PShape loadShapeImpl(PGraphics pg, String filename, String extension) { PShapeOBJ obj = null; if (extension.equals("obj")) { obj = new PShapeOBJ(pg.parent, filename); int prevTextureMode = pg.textureMode; pg.textureMode = NORMAL; PShapeOpenGL p3d = PShapeOpenGL.createShape((PGraphicsOpenGL)pg, obj); pg.textureMode = prevTextureMode; return p3d; } return null; }
parseMTL(parent, fn, path, mreader, materials, mtlTable); mreader.close();
currentMtl = addMaterial(mtlname, materials, materialsHash); } else { if (currentMtl == null) { currentMtl = addMaterial("material" + materials.size(), materials, materialsHash);
static protected PShape loadShapeImpl(PGraphics pg, String filename, String extension) { PShapeOBJ obj = null; if (extension.equals("obj")) { obj = new PShapeOBJ(pg.parent, filename); int prevTextureMode = pg.textureMode; pg.textureMode = NORMAL; PShapeOpenGL p3d = PShapeOpenGL.createShape((PGraphicsOpenGL)pg, obj); pg.textureMode = prevTextureMode; return p3d; } return null; }
BufferedReader mreader = parent.createReader(parts[1]); if (mreader != null) { parseMTL(parent, mreader, materials, mtlTable);
public PShapeOBJ(PApplet parent, BufferedReader reader, String basePath) { ArrayList<OBJFace> faces = new ArrayList<OBJFace>(); ArrayList<OBJMaterial> materials = new ArrayList<OBJMaterial>(); ArrayList<PVector> coords = new ArrayList<PVector>(); ArrayList<PVector> normals = new ArrayList<PVector>(); ArrayList<PVector> texcoords = new ArrayList<PVector>(); parseOBJ(parent, basePath, reader, faces, materials, coords, normals, texcoords); // The OBJ geometry is stored with each face in a separate child shape. parent = null; family = GROUP; addChildren(faces, materials, coords, normals, texcoords); }
protected void addChildren(ArrayList<OBJFace> faces, ArrayList<OBJMaterial> materials, ArrayList<PVector> coords, ArrayList<PVector> normals, ArrayList<PVector> texcoords) { int mtlIdxCur = -1; OBJMaterial mtl = null; for (int i = 0; i < faces.size(); i++) { OBJFace face = faces.get(i); // Getting current material. if (mtlIdxCur != face.matIdx || face.matIdx == -1) { // To make sure that at least we get the default material mtlIdxCur = PApplet.max(0, face.matIdx); mtl = materials.get(mtlIdxCur); } // Creating child shape for current face. PShape child = new PShapeOBJ(face, mtl, coords, normals, texcoords); addChild(child); } }