@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; }
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; }
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; }
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(); }
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; }
@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; }
@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(); }
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; }
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; }
/** @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; }
public PbrTextureAttribute(final long type) { super(type); if (!is(type)) throw new GdxRuntimeException("Invalid type specified"); textureDescription = new TextureDescriptor<>(); }
public <T extends Texture> PbrTextureAttribute(final long type, final TextureDescriptor<T> textureDescription) { this(type); this.textureDescription.set(textureDescription); }
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); }
public IBLAttribute(final long type) { super(type); if (!is(type)) throw new GdxRuntimeException("Invalid type specified"); textureDescription = new TextureDescriptor<>(); }
public <T extends Cubemap> IBLAttribute(final long type, final TextureDescriptor<T> textureDescription) { this(type); this.textureDescription.set(textureDescription); }
public <T extends Cubemap> IBLAttribute(final long type, final TextureDescriptor<T> textureDescription, int uvIndex) { this(type, textureDescription); this.uvIndex = uvIndex; }
public PBRTextureAttribute (final long type) { super(type); if (!is(type)) throw new GdxRuntimeException("Invalid type specified"); textureDescription = new TextureDescriptor<Texture>(); }
public <T extends Texture> PBRTextureAttribute (final long type, final TextureDescriptor<T> textureDescription) { this(type); this.textureDescription.set(textureDescription); }
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); }
@Override public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { if(!TextureDescriptor.class.isAssignableFrom(type.getRawType())) return null; return (TypeAdapter<T>) new TextureDescriptorTypeAdapter(); }
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; }
public TextureAttribute (final long type) { super(type); if (!is(type)) throw new GdxRuntimeException("Invalid type specified"); textureDescription = new TextureDescriptor<Texture>(); }
public <T extends Texture> TextureAttribute (final long type, final TextureDescriptor<T> textureDescription) { this(type); this.textureDescription.set(textureDescription); }
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); }
public CubemapAttribute (final long type) { super(type); if (!is(type)) throw new GdxRuntimeException("Invalid type specified"); textureDescription = new TextureDescriptor<Cubemap>(); }
public <T extends Cubemap> CubemapAttribute (final long type, final TextureDescriptor<T> textureDescription) { this(type); this.textureDescription.set(textureDescription); }
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; }
@Override public TextureDescriptor getDepthMap () { textureDesc.texture = fbo.getColorBufferTexture(); return textureDesc; }
public ShadowMapImpl(Matrix4 trans, Texture tex) { super(); this.trans = trans; this.td = new TextureDescriptor<Texture>(tex); }
@Override public TextureDescriptor<Texture> getDepthMap() { return td; }
public DepthMapAttribute(long type) { super(type); textureDescription = new TextureDescriptor<Texture>(); }
public DepthMapAttribute(long type, Texture tex) { super(type); textureDescription = new TextureDescriptor<Texture>(tex); }
TextureDescriptor getDepthMap ();