Esempio n. 1
0
  @Override
  public void incoporateResults(WavefrontObject wavefrontObject) {

    // wavefrontObject.getFaces().add(face);
    Group group = wavefrontObject.getCurrentGroup();

    if (group == null) {
      group = new Group("Default created by loader");
      wavefrontObject.getGroups().add(group);
      wavefrontObject.getGroupsDirectAccess().put(group.getName(), group);
      wavefrontObject.setCurrentGroup(group);
    }

    if (this.vertices.length == 3) {
      // Add list of vertex/normal/texcoord to current group
      // Each object keeps a list of its own data, apart from the global list
      group.vertices.add(this.vertices[0]);
      group.vertices.add(this.vertices[1]);
      group.vertices.add(this.vertices[2]);
      group.normals.add(this.normals[0]);
      group.normals.add(this.normals[1]);
      group.normals.add(this.normals[2]);
      group.texcoords.add(this.textures[0]);
      group.texcoords.add(this.textures[1]);
      group.texcoords.add(this.textures[2]);
      group.indices.add(group.indexCount++);
      group.indices.add(group.indexCount++);
      group.indices.add(group.indexCount++); // create index list for current object

      face.vertIndices = vindices;
      face.normIndices = nindices;
      face.texIndices = tindices;
      face.setNormals(this.normals);
      face.setNormals(this.normals);
      face.setVertices(this.vertices);
      face.setTextures(this.textures);
      face.setMaterial(wavefrontObject.getCurrentFaceMaterial());

      wavefrontObject.getCurrentGroup().addFace(face);
    } else {
      // Add list of vertex/normal/texcoord to current group
      // Each object keeps a list of its own data, apart from the global list
      group.vertices.add(this.vertices[0]);
      group.vertices.add(this.vertices[1]);
      group.vertices.add(this.vertices[2]);
      group.vertices.add(this.vertices[3]);
      group.normals.add(this.normals[0]);
      group.normals.add(this.normals[1]);
      group.normals.add(this.normals[2]);
      group.normals.add(this.normals[3]);
      group.texcoords.add(this.textures[0]);
      group.texcoords.add(this.textures[1]);
      group.texcoords.add(this.textures[2]);
      group.texcoords.add(this.textures[3]);
      group.indices.add(group.indexCount++);
      group.indices.add(group.indexCount++);
      group.indices.add(group.indexCount++);
      group.indices.add(group.indexCount++); // create index list for current object

      face.vertIndices = vindices;
      face.normIndices = nindices;
      face.texIndices = tindices;
      face.setNormals(this.normals);
      face.setNormals(this.normals);
      face.setVertices(this.vertices);
      face.setTextures(this.textures);
      face.setMaterial(wavefrontObject.getCurrentFaceMaterial());

      wavefrontObject.getCurrentGroup().addFace(face);
    }
  }
Esempio n. 2
0
 private void parseTriangles() {
   face.setType(Face.GL_TRIANGLES);
   parseLine(3);
 }
Esempio n. 3
0
 private void parseQuad() {
   face.setType(Face.GL_QUADS);
   parseLine(4);
 }