Java 类org.lwjgl.assimp.AIColor4D 实例源码

项目:oreon-engine    文件:AssimpStaticModelLoader.java   
private static Material processMaterial(AIMaterial aiMaterial, String texturesDir) {

        AIString path = AIString.calloc();
        Assimp.aiGetMaterialTexture(aiMaterial, Assimp.aiTextureType_DIFFUSE, 0, path, (IntBuffer) null, null, null, null, null, null);
        String textPath = path.dataString();

        Texture diffuseTexture = null;
        if (textPath != null && textPath.length() > 0) {
            diffuseTexture = new Texture();
            diffuseTexture.setPath(texturesDir + "/" + textPath);
        }

        AIColor4D color = AIColor4D.create();
        Vec3f diffuseColor = null;
        int result = Assimp.aiGetMaterialColor(aiMaterial, Assimp.AI_MATKEY_COLOR_AMBIENT, Assimp.aiTextureType_NONE, 0, color);
        if (result == 0) {
            diffuseColor = new Vec3f(color.r(), color.g(), color.b());
        }

        Material material = new Material();
        material.setDiffusemap(diffuseTexture);
        material.setColor(diffuseColor);

        return material;
    }