Java Code Examples for org.lwjgl.assimp.AIMesh#mMaterialIndex()

The following examples show how to use org.lwjgl.assimp.AIMesh#mMaterialIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
    List<Float> vertices = new ArrayList<>();
    List<Float> textures = new ArrayList<>();
    List<Float> normals = new ArrayList<>();
    List<Integer> indices = new ArrayList<>();

    processVertices(aiMesh, vertices);
    processNormals(aiMesh, normals);
    processTextCoords(aiMesh, textures);
    processIndices(aiMesh, indices);

    // Texture coordinates may not have been populated. We need at least the empty slots
    if ( textures.size() == 0) {
        int numElements = (vertices.size() / 3) * 2;
        for (int i=0; i<numElements; i++) {
            textures.add(0.0f);
        }
    }

    Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
            Utils.listToArray(normals), Utils.listIntToArray(indices));
    Material material;
    int materialIdx = aiMesh.mMaterialIndex();
    if (materialIdx >= 0 && materialIdx < materials.size()) {
        material = materials.get(materialIdx);
    } else {
        material = new Material();
    }
    mesh.setMaterial(material);

    return mesh;
}
 
Example 2
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) {
    List<Float> vertices = new ArrayList<>();
    List<Float> textures = new ArrayList<>();
    List<Float> normals = new ArrayList<>();
    List<Integer> indices = new ArrayList<>();
    List<Integer> boneIds = new ArrayList<>();
    List<Float> weights = new ArrayList<>();

    processVertices(aiMesh, vertices);
    processNormals(aiMesh, normals);
    processTextCoords(aiMesh, textures);
    processIndices(aiMesh, indices);
    processBones(aiMesh, boneList, boneIds, weights);

    // Texture coordinates may not have been populated. We need at least the empty slots
    if ( textures.size() == 0) {
        int numElements = (vertices.size() / 3) * 2;
        for (int i=0; i<numElements; i++) {
            textures.add(0.0f);
        }
    }

    Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
            Utils.listToArray(normals), Utils.listIntToArray(indices),
            Utils.listIntToArray(boneIds), Utils.listToArray(weights));
    Material material;
    int materialIdx = aiMesh.mMaterialIndex();
    if (materialIdx >= 0 && materialIdx < materials.size()) {
        material = materials.get(materialIdx);
    } else {
        material = new Material();
    }
    mesh.setMaterial(material);

    return mesh;
}
 
Example 3
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
    List<Float> vertices = new ArrayList<>();
    List<Float> textures = new ArrayList<>();
    List<Float> normals = new ArrayList<>();
    List<Integer> indices = new ArrayList<>();

    processVertices(aiMesh, vertices);
    processNormals(aiMesh, normals);
    processTextCoords(aiMesh, textures);
    processIndices(aiMesh, indices);

    // Texture coordinates may not have been populated. We need at least the empty slots
    if ( textures.size() == 0) {
        int numElements = (vertices.size() / 3) * 2;
        for (int i=0; i<numElements; i++) {
            textures.add(0.0f);
        }
    }

    Mesh mesh = new Mesh(Utils.listToArray(vertices),
            Utils.listToArray(textures),
            Utils.listToArray(normals),
            Utils.listIntToArray(indices)
    );
    Material material;
    int materialIdx = aiMesh.mMaterialIndex();
    if (materialIdx >= 0 && materialIdx < materials.size()) {
        material = materials.get(materialIdx);
    } else {
        material = new Material();
    }
    mesh.setMaterial(material);

    return mesh;
}
 
Example 4
Source File: StaticMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials) {
    List<Float> vertices = new ArrayList<>();
    List<Float> textures = new ArrayList<>();
    List<Float> normals = new ArrayList<>();
    List<Integer> indices = new ArrayList<>();

    processVertices(aiMesh, vertices);
    processNormals(aiMesh, normals);
    processTextCoords(aiMesh, textures);
    processIndices(aiMesh, indices);

    // Texture coordinates may not have been populated. We need at least the empty slots
    if ( textures.size() == 0) {
        int numElements = (vertices.size() / 3) * 2;
        for (int i=0; i<numElements; i++) {
            textures.add(0.0f);
        }
    }

    Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
            Utils.listToArray(normals), Utils.listIntToArray(indices));
    Material material;
    int materialIdx = aiMesh.mMaterialIndex();
    if (materialIdx >= 0 && materialIdx < materials.size()) {
        material = materials.get(materialIdx);
    } else {
        material = new Material();
    }
    mesh.setMaterial(material);

    return mesh;
}
 
Example 5
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private static Mesh processMesh(AIMesh aiMesh, List<Material> materials, List<Bone> boneList) {
    List<Float> vertices = new ArrayList<>();
    List<Float> textures = new ArrayList<>();
    List<Float> normals = new ArrayList<>();
    List<Integer> indices = new ArrayList<>();
    List<Integer> boneIds = new ArrayList<>();
    List<Float> weights = new ArrayList<>();

    processVertices(aiMesh, vertices);
    processNormals(aiMesh, normals);
    processTextCoords(aiMesh, textures);
    processIndices(aiMesh, indices);
    processBones(aiMesh, boneList, boneIds, weights);

    // Texture coordinates may not have been populated. We need at least the empty slots
    if ( textures.size() == 0) {
        int numElements = (vertices.size() / 3) * 2;
        for (int i=0; i<numElements; i++) {
            textures.add(0.0f);
        }
    }

    Mesh mesh = new Mesh(Utils.listToArray(vertices), Utils.listToArray(textures),
            Utils.listToArray(normals), Utils.listIntToArray(indices),
            Utils.listIntToArray(boneIds), Utils.listToArray(weights));
    Material material;
    int materialIdx = aiMesh.mMaterialIndex();
    if (materialIdx >= 0 && materialIdx < materials.size()) {
        material = materials.get(materialIdx);
    } else {
        material = new Material();
    }
    mesh.setMaterial(material);

    return mesh;
}