Пример #1
0
  private void convertDataStructures(ModelMD3 model, MeshInfoMD3 meshHeader) {
    int i = 0;

    Object3d currentMesh = new Object3d();

    // Assign the vertex, texture coord and face count to our new structure
    currentMesh.setNumVertices(meshHeader.numVertices * meshHeader.numMeshFrames);
    currentMesh.setNumVert(meshHeader.numVertices);

    currentMesh.setNumTexcoords(meshHeader.numVertices);
    currentMesh.setNumFaces(meshHeader.numTriangles);
    currentMesh.setName(meshHeader.strName);

    // Go through all of the vertices and assign them over to our structure
    for (i = 0; i < currentMesh.getNumVertices() * meshHeader.numMeshFrames; i++) {
      Vector3f temp =
          new Vector3f(
              vertices[i].vertex[0] / 64.0f,
              vertices[i].vertex[1] / 64.0f,
              vertices[i].vertex[2] / 64.0f);

      currentMesh.setVertices(temp, i);
    }

    for (i = 0; i < currentMesh.getNumTexcoords(); i++) {
      Vector3f temp = new Vector3f(texCoords[i].u, -texCoords[i].v, 0);
      currentMesh.setTexcoords(temp, i);
    }

    // Go through all of the face data and assign it over to OUR structure
    for (i = 0; i < currentMesh.getNumFaces(); i++) {
      // Assign the vertex indices to our face data
      currentMesh.getFace(i).setVertices(0, triangles[i].vertexIndices[0]);
      currentMesh.getFace(i).setVertices(1, triangles[i].vertexIndices[1]);
      currentMesh.getFace(i).setVertices(2, triangles[i].vertexIndices[2]);

      // Assign the texture coord indices to our face data
      currentMesh.getFace(i).setTexCoords(0, triangles[i].vertexIndices[0]);
      currentMesh.getFace(i).setTexCoords(1, triangles[i].vertexIndices[1]);
      currentMesh.getFace(i).setTexCoords(2, triangles[i].vertexIndices[2]);
    }
    currentMesh.setDimension();
    // Here we add the current object (or frame) to our list object list
    model.addObject(currentMesh);
  }