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

项目:Argent    文件:TextureDescriptorTypeAdapter.java   
@Override
public TextureDescriptor<Texture> read(JsonReader in) throws IOException {
    TextureDescriptor<Texture> descriptor = new TextureDescriptor<>();
    String[] refs = new String[5];
    in.beginObject();
    while(in.hasNext()) {
        switch(in.nextName()) {
            case "textureRef": refs[0] = in.nextString(); break;
            case "minFilter": refs[1] = in.nextString(); break;
            case "magFilter": refs[2] = in.nextString(); break;
            case "uWrap": refs[3] = in.nextString(); break;
            case "vWrap": refs[4] = in.nextString(); break;
        }
    }
    in.endObject();
    descriptor.texture      = Argent.content.get(refs[0], Texture.class);
    descriptor.minFilter    = Texture.TextureFilter.valueOf(refs[1]);
    descriptor.magFilter    = Texture.TextureFilter.valueOf(refs[2]);
    descriptor.uWrap        = Texture.TextureWrap.valueOf(refs[3]);
    descriptor.vWrap        = Texture.TextureWrap.valueOf(refs[4]);
    return descriptor;
}
项目:nhglib    文件:PbrTextureAttribute.java   
public <T extends Texture> PbrTextureAttribute(final long type, final TextureDescriptor<T> textureDescription, float offsetU,
                                               float offsetV, float scaleU, float scaleV, int uvIndex) {
    this(type, textureDescription);
    this.offsetU = offsetU;
    this.offsetV = offsetV;
    this.scaleU = scaleU;
    this.scaleV = scaleV;
    this.uvIndex = uvIndex;
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
public <T extends Texture> PBRTextureAttribute (final long type, final TextureDescriptor<T> textureDescription, float offsetU,
                                             float offsetV, float scaleU, float scaleV, int uvIndex) {
    this(type, textureDescription);
    this.offsetU = offsetU;
    this.offsetV = offsetV;
    this.scaleU = scaleU;
    this.scaleV = scaleV;
    this.uvIndex = uvIndex;
}
项目:Argent    文件:JSONSerializer.java   
private JSONSerializer() {
        GsonBuilder gb = new GsonBuilder();
        // TextureDescriptor
        gb.registerTypeAdapter(TextureDescriptor.class, new TextureDescriptorTypeAdapter());
        gb.registerTypeAdapterFactory(new TextureDescriptorTypeAdapterFactory());
        // Material
        gb.registerTypeAdapter(Material.class, new MaterialTypeAdapter());
        gb.registerTypeAdapterFactory(new MaterialTypeAdapterFactory());
//        gb.registerTypeAdapter(DynamicShader.Info.class, new DynamicShaderInfoTypeAdapter());
        gb.setPrettyPrinting();
        gson = gb.create();
    }
项目:Argent    文件:MaterialTypeAdapter.java   
private TextureDescriptor<Texture> buildDescriptor(LinkedTreeMap map) {
    TextureDescriptor<Texture> desc = new TextureDescriptor<>();
    if(map.containsKey("textureRef")) desc.texture = Argent.content.get(map.get("textureRef").toString(), Texture.class);
    if(map.containsKey("minFilter"))  desc.minFilter = Texture.TextureFilter.valueOf(map.get("minFilter").toString());
    if(map.containsKey("magFilter"))  desc.magFilter = Texture.TextureFilter.valueOf(map.get("magFilter").toString());
    if(map.containsKey("uWrap"))      desc.uWrap = Texture.TextureWrap.valueOf(map.get("uWrap").toString());
    if(map.containsKey("vWrap"))      desc.vWrap = Texture.TextureWrap.valueOf(map.get("vWrap").toString());
    return desc;
}
项目:Argent    文件:AttributeTypeAdapter.java   
@Override
public Attribute read(JsonReader in) throws IOException {
    Attribute attr = null;
    long type = -1;
    String alias = "";
    in.beginObject();
    while(in.hasNext()) {
        switch(in.nextName()) {
            case "type": type = in.nextLong(); break;
            case "alias": alias = in.nextString(); break;
            case "attrData":
                attr = buildFromAlias(alias);
                if(attr == null) break;
                in.beginObject();
                while(in.hasNext()) {
                    switch(in.nextName()) {
                        case "offsetU":
                            ((TextureAttribute)attr).offsetU = (float) in.nextDouble(); break;
                        case "offsetV":
                            ((TextureAttribute)attr).offsetV = (float) in.nextDouble(); break;
                        case "scaleU":
                            ((TextureAttribute)attr).scaleU = (float) in.nextDouble(); break;
                        case "scaleV":
                            ((TextureAttribute)attr).scaleV = (float) in.nextDouble(); break;
                        case "textureDescriptor":
                            ((TextureAttribute)attr).textureDescription.set(JSONSerializer.instance().deserialize(in.nextString(), TextureDescriptor.class)); break;
                        case "colour":
                            ((ColorAttribute)attr).color.set(Color.valueOf(in.nextString())); break;
                        case "alpha":
                            ((BlendingAttribute)attr).opacity = (float) in.nextDouble(); break;
                    }
                }
                in.endObject();
                break;
        }
    }
    in.endObject();
    return attr;
}
项目:Argent    文件:TextureDescriptorTypeAdapter.java   
@Override
    public void write(JsonWriter out, TextureDescriptor<Texture> value) throws IOException {
        if(value == null) { out.nullValue(); return; }
        assertTextureDescriptor(value);
        out.beginObject();
        out.name("textureRef").value(Argent.content.getRef(value.texture));
//        out.name("textureRef").value(value.texture.toString());
        out.name("minFilter").value(value.minFilter.name());
        out.name("magFilter").value(value.magFilter.name());
        out.name("uWrap").value(value.uWrap.name());
        out.name("vWrap").value(value.vWrap.name());

        out.endObject();
    }
项目:Argent    文件:TextureDescriptorTypeAdapter.java   
private void assertTextureDescriptor(TextureDescriptor<Texture> value) {
    if(value.texture == null) value.texture = SpriteCache.pixel();
    if(value.minFilter == null) value.minFilter = Texture.TextureFilter.Linear;
    if(value.magFilter == null) value.magFilter = Texture.TextureFilter.Linear;
    if(value.uWrap == null) value.uWrap = Texture.TextureWrap.ClampToEdge;
    if(value.vWrap == null) value.vWrap = Texture.TextureWrap.ClampToEdge;
}
项目:libgdxcn    文件:TextureAttribute.java   
public <T extends Texture> TextureAttribute (final long type, final TextureDescriptor<T> textureDescription, float offsetU,
    float offsetV, float scaleU, float scaleV, int uvIndex) {
    this(type, textureDescription);
    this.offsetU = offsetU;
    this.offsetV = offsetV;
    this.scaleU = scaleU;
    this.scaleV = scaleV;
    this.uvIndex = uvIndex;
}
项目:libgdxcn    文件:DirectionalShadowLight.java   
/** @deprecated Experimental, likely to change, do not use! */
public DirectionalShadowLight (int shadowMapWidth, int shadowMapHeight, float shadowViewportWidth, float shadowViewportHeight,
    float shadowNear, float shadowFar) {
    fbo = new FrameBuffer(Format.RGBA8888, shadowMapWidth, shadowMapHeight, true);
    cam = new OrthographicCamera(shadowViewportWidth, shadowViewportHeight);
    cam.near = shadowNear;
    cam.far = shadowFar;
    halfHeight = shadowViewportHeight * 0.5f;
    halfDepth = shadowNear + 0.5f * (shadowFar - shadowNear);
    textureDesc = new TextureDescriptor();
    textureDesc.minFilter = textureDesc.magFilter = Texture.TextureFilter.Nearest;
    textureDesc.uWrap = textureDesc.vWrap = Texture.TextureWrap.ClampToEdge;
}
项目:nhglib    文件:PbrTextureAttribute.java   
public PbrTextureAttribute(final long type) {
    super(type);
    if (!is(type)) throw new GdxRuntimeException("Invalid type specified");
    textureDescription = new TextureDescriptor<>();
}
项目:nhglib    文件:PbrTextureAttribute.java   
public <T extends Texture> PbrTextureAttribute(final long type, final TextureDescriptor<T> textureDescription) {
    this(type);
    this.textureDescription.set(textureDescription);
}
项目:nhglib    文件:PbrTextureAttribute.java   
public <T extends Texture> PbrTextureAttribute(final long type, final TextureDescriptor<T> textureDescription, float offsetU,
                                               float offsetV, float scaleU, float scaleV) {
    this(type, textureDescription, offsetU, offsetV, scaleU, scaleV, 0);
}
项目:nhglib    文件:IBLAttribute.java   
public IBLAttribute(final long type) {
    super(type);
    if (!is(type)) throw new GdxRuntimeException("Invalid type specified");
    textureDescription = new TextureDescriptor<>();
}
项目:nhglib    文件:IBLAttribute.java   
public <T extends Cubemap> IBLAttribute(final long type, final TextureDescriptor<T> textureDescription) {
    this(type);
    this.textureDescription.set(textureDescription);
}
项目:nhglib    文件:IBLAttribute.java   
public <T extends Cubemap> IBLAttribute(final long type, final TextureDescriptor<T> textureDescription, int uvIndex) {
    this(type, textureDescription);
    this.uvIndex = uvIndex;
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
public PBRTextureAttribute (final long type) {
    super(type);
    if (!is(type)) throw new GdxRuntimeException("Invalid type specified");
    textureDescription = new TextureDescriptor<Texture>();
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
public <T extends Texture> PBRTextureAttribute (final long type, final TextureDescriptor<T> textureDescription) {
    this(type);
    this.textureDescription.set(textureDescription);
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
public <T extends Texture> PBRTextureAttribute (final long type, final TextureDescriptor<T> textureDescription, float offsetU,
                                             float offsetV, float scaleU, float scaleV) {
    this(type, textureDescription, offsetU, offsetV, scaleU, scaleV, 0);
}
项目:Argent    文件:TextureDescriptorTypeAdapterFactory.java   
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
    if(!TextureDescriptor.class.isAssignableFrom(type.getRawType()))
        return null;
    return (TypeAdapter<T>) new TextureDescriptorTypeAdapter();
}
项目:libgdxcn    文件:BaseShader.java   
public final boolean set (final int uniform, final TextureDescriptor textureDesc) {
    if (locations[uniform] < 0) return false;
    program.setUniformi(locations[uniform], context.textureBinder.bind(textureDesc));
    return true;
}
项目:libgdxcn    文件:TextureAttribute.java   
public TextureAttribute (final long type) {
    super(type);
    if (!is(type)) throw new GdxRuntimeException("Invalid type specified");
    textureDescription = new TextureDescriptor<Texture>();
}
项目:libgdxcn    文件:TextureAttribute.java   
public <T extends Texture> TextureAttribute (final long type, final TextureDescriptor<T> textureDescription) {
    this(type);
    this.textureDescription.set(textureDescription);
}
项目:libgdxcn    文件:TextureAttribute.java   
public <T extends Texture> TextureAttribute (final long type, final TextureDescriptor<T> textureDescription, float offsetU,
    float offsetV, float scaleU, float scaleV) {
    this(type, textureDescription, offsetU, offsetV, scaleU, scaleV, 0);
}
项目:libgdxcn    文件:CubemapAttribute.java   
public CubemapAttribute (final long type) {
    super(type);
    if (!is(type)) throw new GdxRuntimeException("Invalid type specified");
    textureDescription = new TextureDescriptor<Cubemap>();
}
项目:libgdxcn    文件:CubemapAttribute.java   
public <T extends Cubemap> CubemapAttribute (final long type, final TextureDescriptor<T> textureDescription) {
    this(type);
    this.textureDescription.set(textureDescription);
}
项目: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    文件:DirectionalShadowLight.java   
@Override
public TextureDescriptor getDepthMap () {
    textureDesc.texture = fbo.getColorBufferTexture();
    return textureDesc;
}
项目:gaiasky    文件:ShadowMapImpl.java   
public ShadowMapImpl(Matrix4 trans, Texture tex) {
    super();
    this.trans = trans;
    this.td = new TextureDescriptor<Texture>(tex);
}
项目:gaiasky    文件:ShadowMapImpl.java   
@Override
public TextureDescriptor<Texture> getDepthMap() {
    return td;
}
项目:gaiasky    文件:DepthMapAttribute.java   
public DepthMapAttribute(long type) {
    super(type);
    textureDescription = new TextureDescriptor<Texture>();
}
项目:gaiasky    文件:DepthMapAttribute.java   
public DepthMapAttribute(long type, Texture tex) {
    super(type);
    textureDescription = new TextureDescriptor<Texture>(tex);
}
项目:libgdxcn    文件:ShadowMap.java   
TextureDescriptor getDepthMap ();