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

项目:ZombieInvadersVR    文件:GameObject.java   
public GameObject(ScreenBase context, Model model, BoundingBox bounds) {
super(model);
this.context = context;
this.customBounds = bounds;

      this.bounds = this.customBounds != null ? this.customBounds : new BoundingBox();
      this.center = new Vector3();
      this.enabled = true;
      updateBox();

      this.animations = new AnimationController(this);
      this.blending = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

      for(Material item : materials){
        item.set(new DepthTestAttribute(GL20.GL_LEQUAL, 0.01f, 25f, true));
    item.set(FloatAttribute.createAlphaTest(0.01f));
        item.set(blending);
      }
  }
项目:gdx-proto    文件:Sky.java   
public static void createSkyBox (Texture xpos, Texture xneg, Texture ypos, Texture yneg, Texture zpos, Texture zneg) {
    modelInstance = new ModelInstance(model, "Skycube");

    // Set material textures
    modelInstance.materials.get(0).set(TextureAttribute.createDiffuse(xpos));
    modelInstance.materials.get(1).set(TextureAttribute.createDiffuse(xneg));
    modelInstance.materials.get(2).set(TextureAttribute.createDiffuse(ypos));
    modelInstance.materials.get(3).set(TextureAttribute.createDiffuse(yneg));
    modelInstance.materials.get(5).set(TextureAttribute.createDiffuse(zpos));
    modelInstance.materials.get(4).set(TextureAttribute.createDiffuse(zneg));

    //Disable depth test
    modelInstance.materials.get(0).set(new DepthTestAttribute(0));
    modelInstance.materials.get(1).set(new DepthTestAttribute(0));
    modelInstance.materials.get(2).set(new DepthTestAttribute(0));
    modelInstance.materials.get(3).set(new DepthTestAttribute(0));
    modelInstance.materials.get(4).set(new DepthTestAttribute(0));
    modelInstance.materials.get(5).set(new DepthTestAttribute(0));

    enabled = true;
}
项目:nhglib    文件: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, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
        } 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    文件:PointSpriteSoftParticleBatch.java   
protected void allocRenderable() {
    renderable = new Renderable();
    renderable.meshPart.primitiveType = GL20.GL_POINTS;
    renderable.meshPart.offset = 0;
    renderable.material = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
            new DepthTestAttribute(GL20.GL_LEQUAL, false), TextureAttribute.createDiffuse((Texture) null));
}
项目: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    文件:BillboardParticleBatch.java   
protected Renderable allocRenderable(){
    Renderable renderable = new Renderable();
    renderable.primitiveType = GL20.GL_TRIANGLES;
    renderable.meshPartOffset = 0;
    renderable.material = new Material( new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
        new DepthTestAttribute(GL20.GL_LEQUAL, false),
        TextureAttribute.createDiffuse(texture));
    renderable.mesh = new Mesh(false, MAX_VERTICES_PER_MESH, MAX_PARTICLES_PER_MESH*6, currentAttributes);
    renderable.mesh.setIndices(indices);
    renderable.shader = shader;
    return renderable;
}
项目:libgdxcn    文件:PointSpriteParticleBatch.java   
protected void allocRenderable(){
    renderable = new Renderable();
    renderable.primitiveType = GL20.GL_POINTS;
    renderable.meshPartOffset = 0;
    renderable.material = new Material( new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
        new DepthTestAttribute(GL20.GL_LEQUAL, false),
        TextureAttribute.createDiffuse((Texture)null));
}
项目: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);
}
项目:gdx-proto    文件:Sky.java   
public static void createSkyBox (Texture skybox) {
    modelInstance = new ModelInstance(model, "Skybox");

    // Set material texutres and Disable depth test
    modelInstance.materials.get(0).set(TextureAttribute.createDiffuse(skybox));
    modelInstance.materials.get(0).set(new DepthTestAttribute(0));

    enabled = true;
}