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

项目:nhglib    文件:PbrTextureAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    PbrTextureAttribute other = (PbrTextureAttribute) o;
    final int c = textureDescription.compareTo(other.textureDescription);
    if (c != 0) return c;
    if (uvIndex != other.uvIndex) return uvIndex - other.uvIndex;
    if (!MathUtils.isEqual(scaleU, other.scaleU)) return scaleU > other.scaleU ? 1 : -1;
    if (!MathUtils.isEqual(scaleV, other.scaleV)) return scaleV > other.scaleV ? 1 : -1;
    if (!MathUtils.isEqual(offsetU, other.offsetU)) return offsetU > other.offsetU ? 1 : -1;
    if (!MathUtils.isEqual(offsetV, other.offsetV)) return offsetV > other.offsetV ? 1 : -1;
    return 0;
}
项目:nhglib    文件:IBLAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    IBLAttribute other = (IBLAttribute) o;
    final int c = textureDescription.compareTo(other.textureDescription);
    if (c != 0) return c;
    if (uvIndex != other.uvIndex) return uvIndex - other.uvIndex;
    return 0;
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
@Override
public int compareTo (Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    TextureAttribute other = (TextureAttribute)o;
    final int c = textureDescription.compareTo(other.textureDescription);
    if (c != 0) return c;
    if (uvIndex != other.uvIndex) return uvIndex - other.uvIndex;
    if (!MathUtils.isEqual(scaleU, other.scaleU)) return scaleU > other.scaleU ? 1 : -1;
    if (!MathUtils.isEqual(scaleV, other.scaleV)) return scaleV > other.scaleV ? 1 : -1;
    if (!MathUtils.isEqual(offsetU, other.offsetU)) return offsetU > other.offsetU ? 1 : -1;
    if (!MathUtils.isEqual(offsetV, other.offsetV)) return offsetV > other.offsetV ? 1 : -1;
    return 0;
}
项目:Argent    文件:MaterialWrapper.java   
private <T extends Attribute> T getAttribute(long type, Class<T> cls) {
    String alias = TextureAttribute.getAttributeAlias(type);
    Attribute attr = mtl.get(type);
    if(attr == null)
        return null;
    return cls.cast(attr);
}
项目:Argent    文件:MaterialTypeAdapter.java   
@Override
public void write(final JsonWriter out, final Material value) throws IOException {
    if(value == null) { out.nullValue(); return; }
    out.beginObject();
        out.name("id").value(value.id);
        ArrayList<Attribute> attrList = new ArrayList<>();
        value.iterator().forEachRemaining(attrList::add);
        out.name("attributes").value(JSONSerializer.instance().serialize(attrList));
    out.endObject();
}
项目:Argent    文件:AttributeTypeAdapter.java   
@Override
public void write(JsonWriter out, Attribute value) throws IOException {
    if(value == null) {
        out.nullValue();
        return;
    }
    out.beginObject();
    String alias = value.getClass().getSimpleName();
    out.name("type").value(value.type);

    alias += "::" + value.getAttributeAlias(value.type);
    out.name("alias").value(alias);


    out.name("attrData").beginObject();
    if(value instanceof TextureAttribute) {
        out.name("offsetU").value(((TextureAttribute) value).offsetU);
        out.name("offsetV").value(((TextureAttribute) value).offsetV);
        out.name("scaleU").value(((TextureAttribute) value).scaleU);
        out.name("scaleV").value(((TextureAttribute) value).scaleV);
        out.name("textureDescriptor").value(JSONSerializer.instance().serialize(((TextureAttribute) value).textureDescription));
    }else if(value instanceof ColorAttribute) {
        out.name("colour").value(((ColorAttribute) value).color.toString());
    }else if(value instanceof BlendingAttribute) {
        out.name("alpha").value(((BlendingAttribute) value).opacity);
    }
    out.endObject();
    out.endObject();
}
项目: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;
}
项目:Alien-Ark    文件:MaterialForm.java   
private void addAttributeForm(Attribute attribute, final Material material) {
    if (attribute instanceof ColorAttribute) {
        final ColorAttribute colorAttribute = (ColorAttribute) attribute;
        String type = ColorAttribute.getAttributeAlias(colorAttribute.type);


        ColorForm.ColorChangeListener colorChangeListener = new ColorForm.ColorChangeListener() {
            @Override
            public void onColorChange(float r, float g, float b) {
                //replace(material, colorAttribute, attribute);
                listener.onMaterialChange(material);
            }
        };

        final ColorForm colorAttributeForm = new ColorForm(
                getSkin(), "ColorAttribute " + type, colorAttribute.color, colorChangeListener, new RemoveTableListener() {
            @Override
            public void onRemove(Table table) {
                material.remove(colorAttribute.type);
                listener.onMaterialChange(material);
                removeActor(table);
                pack();
                listener.onMaterialChange(material);
            }
        });
        add(colorAttributeForm).colspan(2).left().fill();
        row();
    }
    pack();
}
项目:Alien-Ark    文件:MaterialForm.java   
private void replace(Material m, Attribute oldAttribute, Attribute newAttribute) {
    Iterator<Attribute> iterator = m.iterator();
    while (iterator.hasNext()) {
        Attribute next = iterator.next();
        if (next.equals(oldAttribute)) {
            iterator.remove();
        }
    }
    m.set(newAttribute);
}
项目:Alien-Ark    文件:GsonMaterial.java   
public GsonMaterial(Material material) {
    Iterator<Attribute> iterator = material.iterator();

    while (iterator.hasNext()) {
        Attribute next = iterator.next();
        if (next instanceof ColorAttribute) {
            colorAttributes.add((ColorAttribute) next);
        }
    }

    this.id = material.id;
}
项目:Alien-Ark    文件:ControllerPlanet.java   
private void loadSphere(String planetId) {
    ModelLoader loader = new ObjLoader();
    sphereModel = loader.loadModel(Gdx.files.internal("models/sphere01.obj"),
            new SphereTextureProvider(planetId));
    environmentSphere = new ModelInstance(sphereModel);
    Attribute attribute = environmentSphere.materials.get(0).get(
            ColorAttribute.getAttributeType(ColorAttribute.DiffuseAlias));

    ((ColorAttribute) attribute).color.r = 1;
    ((ColorAttribute) attribute).color.g = 1;
    ((ColorAttribute) attribute).color.b = 1;

}
项目:libgdxcn    文件:DefaultShader.java   
protected void bindMaterial (final Renderable renderable) {
    if (currentMaterial == renderable.material) return;

    int cullFace = config.defaultCullFace == -1 ? defaultCullFace : config.defaultCullFace;
    int depthFunc = config.defaultDepthFunc == -1 ? defaultDepthFunc : config.defaultDepthFunc;
    float depthRangeNear = 0f;
    float depthRangeFar = 1f;
    boolean depthMask = true;

    currentMaterial = renderable.material;
    for (final Attribute attr : currentMaterial) {
        final long t = attr.type;
        if (BlendingAttribute.is(t)) {
            context.setBlending(true, ((BlendingAttribute)attr).sourceFunction, ((BlendingAttribute)attr).destFunction);
            set(u_opacity, ((BlendingAttribute)attr).opacity);
        } else if ((t & IntAttribute.CullFace) == IntAttribute.CullFace)
            cullFace = ((IntAttribute)attr).value;
        else if ((t & FloatAttribute.AlphaTest) == FloatAttribute.AlphaTest)
            set(u_alphaTest, ((FloatAttribute)attr).value);
        else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
            DepthTestAttribute dta = (DepthTestAttribute)attr;
            depthFunc = dta.depthFunc;
            depthRangeNear = dta.depthRangeNear;
            depthRangeFar = dta.depthRangeFar;
            depthMask = dta.depthMask;
        } else if (!config.ignoreUnimplemented) throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
    }

    context.setCullFace(cullFace);
    context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
    context.setDepthMask(depthMask);
}
项目:libgdxcn    文件:ParticleShader.java   
protected void bindMaterial(final Renderable renderable) {
    if (currentMaterial == renderable.material)
        return;

    int cullFace = config.defaultCullFace == -1 ? GL20.GL_BACK : config.defaultCullFace;
    int depthFunc = config.defaultDepthFunc == -1 ? GL20.GL_LEQUAL : config.defaultDepthFunc;
    float depthRangeNear = 0f;
    float depthRangeFar = 1f;
    boolean depthMask = true;

    currentMaterial = renderable.material;
    for (final Attribute attr : currentMaterial) {
        final long t = attr.type;
        if (BlendingAttribute.is(t)) {
            context.setBlending(true, ((BlendingAttribute)attr).sourceFunction, ((BlendingAttribute)attr).destFunction);
        }
        else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
            DepthTestAttribute dta = (DepthTestAttribute)attr;
            depthFunc = dta.depthFunc;
            depthRangeNear = dta.depthRangeNear;
            depthRangeFar = dta.depthRangeFar;
            depthMask = dta.depthMask;
        }
        else if(!config.ignoreUnimplemented)
            throw new GdxRuntimeException("Unknown material attribute: "+attr.toString());
    }

    context.setCullFace(cullFace);
    context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
    context.setDepthMask(depthMask);
}
项目:gaiasky    文件:AtmosphereShader.java   
protected void bindMaterial(final Renderable renderable) {
    if (currentMaterial == renderable.material)
        return;

    int cullFace = config.defaultCullFace == -1 ? defaultCullFace : config.defaultCullFace;
    int depthFunc = config.defaultDepthFunc == -1 ? defaultDepthFunc : config.defaultDepthFunc;
    float depthRangeNear = 0f;
    float depthRangeFar = 1f;
    boolean depthMask = true;

    currentMaterial = renderable.material;
    for (final Attribute attr : currentMaterial) {
        final long t = attr.type;
        if (BlendingAttribute.is(t)) {
            context.setBlending(true, ((BlendingAttribute) attr).sourceFunction, ((BlendingAttribute) attr).destFunction);
        } else if ((t & IntAttribute.CullFace) == IntAttribute.CullFace)
            cullFace = ((IntAttribute) attr).value;
        else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
            DepthTestAttribute dta = (DepthTestAttribute) attr;
            depthFunc = dta.depthFunc;
            depthRangeNear = dta.depthRangeNear;
            depthRangeFar = dta.depthRangeFar;
            depthMask = dta.depthMask;
        } else if (!config.ignoreUnimplemented)
            throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
    }

    context.setCullFace(cullFace);
    context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
    context.setDepthMask(depthMask);
}
项目:nhglib    文件:PbrTextureAttribute.java   
@Override
public Attribute copy() {
    return new PbrTextureAttribute(this);
}
项目:nhglib    文件:GammaCorrectionAttribute.java   
@Override
public Attribute copy() {
    return new GammaCorrectionAttribute();
}
项目:nhglib    文件:GammaCorrectionAttribute.java   
@Override
public int compareTo(Attribute o) {
    return 0;
}
项目:nhglib    文件:IBLAttribute.java   
@Override
public Attribute copy() {
    return null;
}
项目:nhglib    文件:NhgLightsAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    return 0;
}
项目:LibGDX-PBR    文件:PBRTextureAttribute.java   
@Override
public Attribute copy () {
    return new PBRTextureAttribute(this);
}
项目:Mundus    文件:TerrainTextureAttribute.java   
@Override
public Attribute copy() {
    return new TerrainTextureAttribute(this);
}
项目:Mundus    文件:TerrainTextureAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    TerrainTexture otherValue = ((TerrainTextureAttribute) o).terrainTexture;
    return terrainTexture.equals(otherValue) ? 0 : -1;
}
项目:Mundus    文件:SunLightsAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    return 0; // FIXME implement comparing
}
项目:Mundus    文件:DirectionalLightsAttribute.java   
@Override
public int compareTo(Attribute o) {
    if (type != o.type) return type < o.type ? -1 : 1;
    return 0; // FIXME implement comparing
}
项目:Mundus    文件:PickerIDAttribute.java   
@Override
public int compareTo(Attribute o) {
    return -1; // FIXME implement comparing
}
项目:Alien-Ark    文件:MaterialForm.java   
public MaterialForm(Skin skin, final Material material, String materialId,
                    final MaterialChangeListener listener) {
    this.listener = listener;

    final Iterator<Attribute> iterator = material.iterator();
    defaults().left().top().pad(4);
    add(new Label("Material: " + materialId, skin)).left().top().colspan(2);
    row();
    setSkin(skin);

    final SelectBox<String> attributeSelectBox = new SelectBox<String>(skin);
    attributeSelectBox.setItems(
            "diffuseColor",
            "specularColor",
            "ambientColor",
            "emissiveColor",
            "reflectionColor",
            "ambientLightColor",
            "fogColor"
    );

    add(attributeSelectBox);
    TextButton addButton = new TextButton("add", skin);
    addButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            String selected = attributeSelectBox.getSelected();
            long attributeType = ColorAttribute.getAttributeType(selected);
            ColorAttribute colorAttribute = new ColorAttribute(attributeType);
            material.set(colorAttribute);
            addAttributeForm(colorAttribute, material);
            listener.onMaterialChange(material);
        }
    });

    add(addButton);
    row();

    while (iterator.hasNext()) {
        Attribute attribute = iterator.next();
        addAttributeForm(attribute, material);
    }
}
项目:ForgE    文件:WaterAttribute.java   
@Override
public Attribute copy() {
  return new WaterAttribute();
}
项目:ForgE    文件:WaterAttribute.java   
@Override
public int compareTo(Attribute o) {
  if (type != o.type) return type < o.type ? -1 : 1;
  return 0;
}
项目:ForgE    文件:WaterElevationAttribute.java   
@Override
public Attribute copy() {
  return new WaterElevationAttribute(height);
}
项目:ForgE    文件:WaterElevationAttribute.java   
@Override
public int compareTo(Attribute o) {
  if (type != o.type) return type < o.type ? -1 : 1;
  return 0;
}
项目:ForgE    文件:SolidTerrainAttribute.java   
@Override
public Attribute copy() {
  return new SolidTerrainAttribute();
}
项目:ForgE    文件:SolidTerrainAttribute.java   
@Override
public int compareTo(Attribute o) {
  if (type != o.type) return type < o.type ? -1 : 1;
  return 0;
}
项目:libgdxcn    文件:DepthTestAttribute.java   
@Override
public Attribute copy () {
    return new DepthTestAttribute(this);
}
项目:libgdxcn    文件:FloatAttribute.java   
@Override
public Attribute copy () {
    return new FloatAttribute(type, value);
}
项目:libgdxcn    文件:TextureAttribute.java   
@Override
public Attribute copy () {
    return new TextureAttribute(this);
}
项目:libgdxcn    文件:ColorAttribute.java   
@Override
public Attribute copy () {
    return new ColorAttribute(this);
}
项目:libgdxcn    文件:IntAttribute.java   
@Override
public Attribute copy () {
    return new IntAttribute(type, value);
}
项目:libgdxcn    文件:CubemapAttribute.java   
@Override
public Attribute copy () {
    return new CubemapAttribute(this);
}
项目:libgdxcn    文件:ShaderTest.java   
@Override
public Attribute copy () {
    return new TestAttribute(value);
}
项目:libgdxcn    文件:ShaderTest.java   
@Override
protected boolean equals (Attribute other) {
    return ((TestAttribute)other).value == value;
}