Java 类com.badlogic.gdx.graphics.g3d.utils.TextureProvider 实例源码

项目:libgdxcn    文件:ModelLoader.java   
@Override
public Model loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }
    data = null;
    return result;
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
@Override
public HeadlessModel loadSync (AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final HeadlessModel result = new HeadlessModel(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }
    data = null;
    return result;
}
项目:nhglib    文件:NhgModelLoader.java   
@Override
public Model loadSync(AssetManager manager, String fileName, FileHandle file, P parameters) {
    ModelData data = null;
    synchronized (items) {
        for (int i = 0; i < items.size; i++) {
            if (items.get(i).key.equals(fileName)) {
                data = items.get(i).value;
                items.removeIndex(i);
            }
        }
    }
    if (data == null) return null;
    final Model result = new Model(data, new TextureProvider.AssetTextureProvider(manager));
    // need to remove the textures from the managed disposables, or else ref counting
    // doesn't work!
    Iterator<Disposable> disposables = result.getManagedDisposables().iterator();
    while (disposables.hasNext()) {
        Disposable disposable = disposables.next();
        if (disposable instanceof Texture) {
            disposables.remove();
        }
    }

    // Automatically convert all materials to PBR
    for (Material material : result.materials) {
        TextureAttribute textureAttribute = (TextureAttribute) material.get(TextureAttribute.Diffuse);

        if (textureAttribute != null) {
            material.set(PbrTextureAttribute.createAlbedo(textureAttribute.textureDescription.texture));
        }
    }

    data = null;
    return result;
}
项目:libgdxcn    文件:Model.java   
private void load (ModelData modelData, TextureProvider textureProvider) {
    loadMeshes(modelData.meshes);
    loadMaterials(modelData.materials, textureProvider);
    loadNodes(modelData.nodes);
    loadAnimations(modelData.animations);
    calculateTransforms();
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}.
 */
public Model loadModel(final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new Model(data, textureProvider);
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}.
 */
public Model loadModel(final FileHandle fileHandle, P parameters) {
    return loadModel(fileHandle, new TextureProvider.FileTextureProvider(), parameters);
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}.
 */
public Model loadModel(final FileHandle fileHandle, TextureProvider textureProvider) {
    return loadModel(fileHandle, textureProvider, null);
}
项目:nhglib    文件:NhgModelLoader.java   
/**
 * Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}.
 */
public Model loadModel(final FileHandle fileHandle) {
    return loadModel(fileHandle, new TextureProvider.FileTextureProvider(), null);
}
项目:libgdxcn    文件:Model.java   
/** Constructs a new Model based on the {@link ModelData}.
 * @param modelData the {@link ModelData} got from e.g. {@link ModelLoader}
 * @param textureProvider the {@link TextureProvider} to use for loading the textures */
public Model (ModelData modelData, TextureProvider textureProvider) {
    load(modelData, textureProvider);
}
项目:libgdxcn    文件:Model.java   
private void loadMaterials (Iterable<ModelMaterial> modelMaterials, TextureProvider textureProvider) {
    for (ModelMaterial mtl : modelMaterials) {
        this.materials.add(convertMaterial(mtl, textureProvider));
    }
}
项目:libgdxcn    文件:Model.java   
private Material convertMaterial (ModelMaterial mtl, TextureProvider textureProvider) {
    Material result = new Material();
    result.id = mtl.id;
    if (mtl.ambient != null) result.set(new ColorAttribute(ColorAttribute.Ambient, mtl.ambient));
    if (mtl.diffuse != null) result.set(new ColorAttribute(ColorAttribute.Diffuse, mtl.diffuse));
    if (mtl.specular != null) result.set(new ColorAttribute(ColorAttribute.Specular, mtl.specular));
    if (mtl.emissive != null) result.set(new ColorAttribute(ColorAttribute.Emissive, mtl.emissive));
    if (mtl.reflection != null) result.set(new ColorAttribute(ColorAttribute.Reflection, mtl.reflection));
    if (mtl.shininess > 0f) result.set(new FloatAttribute(FloatAttribute.Shininess, mtl.shininess));
    if (mtl.opacity != 1.f) result.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, mtl.opacity));

    ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();

    // FIXME uvScaling/uvTranslation totally ignored
    if (mtl.textures != null) {
        for (ModelTexture tex : mtl.textures) {
            Texture texture;
            if (textures.containsKey(tex.fileName)) {
                texture = textures.get(tex.fileName);
            } else {
                texture = textureProvider.load(tex.fileName);
                textures.put(tex.fileName, texture);
                disposables.add(texture);
            }

            TextureDescriptor descriptor = new TextureDescriptor(texture);
            descriptor.minFilter = texture.getMinFilter();
            descriptor.magFilter = texture.getMagFilter();
            descriptor.uWrap = texture.getUWrap();
            descriptor.vWrap = texture.getVWrap();

            float offsetU = tex.uvTranslation == null ? 0f : tex.uvTranslation.x;
            float offsetV = tex.uvTranslation == null ? 0f : tex.uvTranslation.y;
            float scaleU = tex.uvScaling == null ? 1f : tex.uvScaling.x;
            float scaleV = tex.uvScaling == null ? 1f : tex.uvScaling.y;

            switch (tex.usage) {
            case ModelTexture.USAGE_DIFFUSE:
                result.set(new TextureAttribute(TextureAttribute.Diffuse, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_SPECULAR:
                result.set(new TextureAttribute(TextureAttribute.Specular, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_BUMP:
                result.set(new TextureAttribute(TextureAttribute.Bump, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_NORMAL:
                result.set(new TextureAttribute(TextureAttribute.Normal, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_AMBIENT:
                result.set(new TextureAttribute(TextureAttribute.Ambient, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_EMISSIVE:
                result.set(new TextureAttribute(TextureAttribute.Emissive, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            case ModelTexture.USAGE_REFLECTION:
                result.set(new TextureAttribute(TextureAttribute.Reflection, descriptor, offsetU, offsetV, scaleU, scaleV));
                break;
            }
        }
    }

    return result;
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}. */
public Model loadModel (final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new Model(data, textureProvider);
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}. */
public Model loadModel (final FileHandle fileHandle, P parameters) {
    return loadModel(fileHandle, new TextureProvider.FileTextureProvider(), parameters);
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}. */
public Model loadModel (final FileHandle fileHandle, TextureProvider textureProvider) {
    return loadModel(fileHandle, textureProvider, null);
}
项目:libgdxcn    文件:ModelLoader.java   
/** Directly load the model on the calling thread. The model with not be managed by an {@link AssetManager}. */
public Model loadModel (final FileHandle fileHandle) {
    return loadModel(fileHandle, new TextureProvider.FileTextureProvider(), null);
}
项目:gdx-proto    文件:HeadlessModel.java   
/** Constructs a new Model based on the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData}.
 * @param modelData the {@link com.badlogic.gdx.graphics.g3d.model.data.ModelData} got from e.g. {@link com.badlogic.gdx.assets.loaders.ModelLoader}
 * @param textureProvider the {@link com.badlogic.gdx.graphics.g3d.utils.TextureProvider} to use for loading the textures */
public HeadlessModel(ModelData modelData, TextureProvider textureProvider) {
    load(modelData, textureProvider);
}
项目:gdx-proto    文件:HeadlessModel.java   
private void load (ModelData modelData, TextureProvider textureProvider) {
    loadMeshes(modelData.meshes);
    loadNodes(modelData.nodes);
    loadAnimations(modelData.animations);
    calculateTransforms();
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the HeadlessModel on the calling thread. The HeadlessModel with not be managed by an {@link com.badlogic.gdx.assets.AssetManager}. */
public HeadlessModel loadHeadlessModel (final FileHandle fileHandle, TextureProvider textureProvider, P parameters) {
    final ModelData data = loadModelData(fileHandle, parameters);
    return data == null ? null : new HeadlessModel(data, textureProvider);
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the HeadlessModel on the calling thread. The HeadlessModel with not be managed by an {@link com.badlogic.gdx.assets.AssetManager}. */
public HeadlessModel loadHeadlessModel (final FileHandle fileHandle, P parameters) {
    return loadHeadlessModel(fileHandle, new TextureProvider.FileTextureProvider(), parameters);
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the HeadlessModel on the calling thread. The HeadlessModel with not be managed by an {@link com.badlogic.gdx.assets.AssetManager}. */
public HeadlessModel loadHeadlessModel (final FileHandle fileHandle, TextureProvider textureProvider) {
    return loadHeadlessModel(fileHandle, textureProvider, null);
}
项目:gdx-proto    文件:HeadlessModelLoader.java   
/** Directly load the HeadlessModel on the calling thread. The HeadlessModel with not be managed by an {@link com.badlogic.gdx.assets.AssetManager}. */
public HeadlessModel loadHeadlessModel (final FileHandle fileHandle) {
    return loadHeadlessModel(fileHandle, new TextureProvider.FileTextureProvider(), null);
}