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

项目: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);
      }
  }
项目:origin    文件:ShadowShader.java   
@Override
    public void render(Renderable renderable, Attributes combinedAttributes)
    {

//      context.setCullFace(GL_BACK);
        // Classic depth test
        context.setDepthTest(GL20.GL_LEQUAL);
        // Deactivate blending on first pass
        context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);

        context.setDepthMask(true);

        if (!combinedAttributes.has(BlendingAttribute.Type))
            context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

        super.render(renderable, combinedAttributes);


//      program.begin();
//      super.render(renderable, combinedAttributes);
//      program.end();
    }
项目:ForgE    文件:TerrainBuilder.java   
private VoxelChunkRenderable buildFaceForChunkWithAssembler(Chunk chunk, VoxelsAssembler assembler, boolean haveTransparency) {
  if (!assembler.isEmpty()) {
    VoxelChunkRenderable renderable   = new VoxelChunkRenderable();
    renderable.primitiveType          = GL30.GL_TRIANGLES;

    if (ForgE.config.getBool(Config.Key.GenerateWireframe))
      renderable.wireframe           = assembler.wireframe();
    renderable.triangleCount         = assembler.getTriangleCount();
    renderable.meshFactory           = assembler.meshFactory(MeshVertexInfo.voxelTypes());

    renderable.worldTransform.idt();
    renderable.material = new Material(new SolidTerrainAttribute());
    if (haveTransparency) {
      renderable.material.set(new BlendingAttribute(true,1f));
    }

    chunk.addFace(renderable);
    return renderable;
  } else {
    return null;
  }
}
项目:ForgE    文件:VoxelChunkRenderableFactorySerializer.java   
@Override
public void write(Kryo kryo, Output output, VoxelChunkRenderableFactory object) {
  output.writeInt(object.triangleCount);
  output.writeInt(object.primitiveType);

  output.writeBoolean(object.material.has(SolidTerrainAttribute.Type));
  output.writeBoolean(object.material.has(BlendingAttribute.Type));
  output.writeBoolean(object.material.has(WaterAttribute.Type));

  output.writeInt(object.attributes.length);
  for (MeshVertexInfo.AttributeType attribute : object.attributes) {
    kryo.writeObject(output, attribute);
  }
  output.writeInt(object.meshFactory.verties.length);
  output.writeInt(object.meshFactory.indices.length);

  output.writeFloats(object.meshFactory.verties);
  output.writeShorts(object.meshFactory.indices);
}
项目:libgdxcn    文件:DepthShader.java   
@Override
public boolean canRender (Renderable renderable) {
    if (renderable.material.has(BlendingAttribute.Type)) {
        if ((materialMask & BlendingAttribute.Type) != BlendingAttribute.Type)
            return false;
        if (renderable.material.has(TextureAttribute.Diffuse) != ((materialMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse))
            return false;
    }
    final boolean skinned = ((renderable.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight);
    if (skinned != (numBones > 0)) return false;
    if (!skinned) return true;
    int w = 0;
    final int n = renderable.mesh.getVertexAttributes().size();
    for (int i = 0; i < n; i++) {
        final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
        if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit);
    }
    return w == weights;
}
项目:libgdxcn    文件:DepthShader.java   
@Override
public void render (final Renderable renderable) {
    if (renderable.material.has(BlendingAttribute.Type)) {
        final BlendingAttribute blending = (BlendingAttribute)renderable.material.get(BlendingAttribute.Type);
        renderable.material.remove(BlendingAttribute.Type);
        final boolean hasAlphaTest = renderable.material.has(FloatAttribute.AlphaTest);
        if (!hasAlphaTest)
            renderable.material.set(alphaTestAttribute);
        if (blending.opacity >= ((FloatAttribute)renderable.material.get(FloatAttribute.AlphaTest)).value)
            super.render(renderable);
        if (!hasAlphaTest)
            renderable.material.remove(FloatAttribute.AlphaTest);
        renderable.material.set(blending);
    } else
        super.render(renderable);
}
项目:HelixEngine    文件:TileHighlightDisplayable.java   
public TileHighlightDisplayable() {
  ModelBuilder modelBuilder = new ModelBuilder();

  Model model
      = modelBuilder.createRect(0, 0, Z_OFFSET,
                                1, 0, Z_OFFSET,
                                1, 1, Z_OFFSET,
                                0, 1, Z_OFFSET,
                                0, 0, 1,
                                GL20.GL_TRIANGLES,
                                new Material(
                                    new ColorAttribute(
                                        ColorAttribute.createDiffuse(color)),
                                    new BlendingAttribute(
                                        GL20.GL_SRC_ALPHA,
                                        GL20.GL_ONE_MINUS_SRC_ALPHA)),
                                VertexAttributes.Usage.Position |
                                VertexAttributes.Usage.TextureCoordinates);

  instance = new ModelInstance(model);
}
项目:HelixEngine    文件:AreaDisplayable.java   
public AreaDisplayable(Model model) {
  instance = new ModelInstance(model);

  animationController = new AnimationController(instance);

  instance.transform.rotate(new Vector3(1, 0, 0), 90);

  for (Material material : instance.materials) {
    TextureAttribute ta
        = (TextureAttribute) material.get(TextureAttribute.Diffuse);

    ta.textureDescription.magFilter = Texture.TextureFilter.Nearest;
    ta.textureDescription.minFilter = Texture.TextureFilter.Nearest;

    material.set(ta);
    material.set(ColorAttribute.createDiffuse(Color.WHITE));

    BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA,
                                                 GL20.GL_ONE_MINUS_SRC_ALPHA);

    material.set(ba);
  }
}
项目:bladecoder-adventure-engine    文件:Utils3D.java   
public static void createFloor() {

        ModelBuilder modelBuilder = new ModelBuilder();
        modelBuilder.begin();
        MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
                Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(
                        ColorAttribute.createDiffuse(Color.WHITE)));
        mpb.setColor(1f, 1f, 1f, 1f);
//      mpb.box(0, -0.1f, 0, 10, .2f, 10);
        mpb.rect(-10, 0, -10, 
                -10, 0, 10,
                10, 0, 10,
                10, 0, -10, 0, 1, 0);
        floorModel = modelBuilder.end();
        floorInstance = new ModelInstance(floorModel);

        // TODO Set only when FBO is active
        floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
    }
项目:BotLogic    文件:LedEntity.java   
public LedEntity(Model model) {
  super(model);

  light = new PointLight();
  light.set(new Color(1f,1f, 1f, 1f), Vector3.Zero, 2f);

  for (Material material : instance.materials) {

    if (material.id.contains("Led")) {
      this.colorAttr = (ColorAttribute)material.get(ColorAttribute.Diffuse);
      colorAttr.color.set(Color.WHITE);

      this.blendingAttribute = (BlendingAttribute)material.get(BlendingAttribute.Type);
      blendingAttribute.opacity = 1.0f;
      blendingAttribute.sourceFunction = GL20.GL_ONE;
      blendingAttribute.destFunction = GL20.GL_SRC_ALPHA;

    }
  }
}
项目:gdx-proto    文件:ModelManager.java   
public void createBillboardTest() {
    ModelBuilder mb = new ModelBuilder();
    mb.begin();

    long attr = Usage.TextureCoordinates | Usage.Position | Usage.Normal;
    TextureRegion region = Assets.getAtlas().findRegion("sprites/test-guy");
    Material mat = new Material(TextureAttribute.createDiffuse(region.getTexture()));
    boolean blended = true;
    float opacity = 1f;
    mat.set(new BlendingAttribute(blended, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, opacity));
    MeshPartBuilder mpb = mb.part("rect", GL20.GL_TRIANGLES, attr, mat);
    mpb.setUVRange(region);
    // the coordinates are offset so that we can easily set the center position to align with the entity's body
    float sz = 2f; // size
    float b = -sz/2; // base
    float max = sz/2; // max
    Vector3 bl = new Vector3(b, b, 0f);
    Vector3 br = new Vector3(b, max, 0f);
    Vector3 tr = new Vector3(max, max, 0f);
    Vector3 tl = new Vector3(max, b, 0f);
    Vector3 norm = new Vector3(0f, 0f, 1f);
    mpb.rect(bl, tl, tr, br, norm);
    billboardTestModel = mb.end();
}
项目:gdx-proto    文件:Shadow.java   
public static void init() {
    list = new Array<>();
    ModelBuilder mb = new ModelBuilder();
    Vector3 norm = new Vector3(0f, 1f, 0f);
    Texture texture = Assets.manager.get("textures/shadow.png", Texture.class);
    Material material = new Material(TextureAttribute.createDiffuse(texture));
    material.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.7f));
    //material.set(new DepthTestAttribute(0)); // disable depth testing
    long attr = Usage.Position | Usage.TextureCoordinates;
    float s = 1f;
    model = mb.createRect(
            -s, 0f, -s,// bl
            -s, 0f, s, // tl
            s, 0f, s,  // tr
            s, 0f, -s,  // br
            norm.x, norm.y, norm.z,
            material,
            attr
    );
}
项目:Cubes_2    文件:Assets.java   
private static PackedTextureSheet getPackedTextureSheet(AssetType... assetType) {
    if (Adapter.isDedicatedServer())
        return null;
    TexturePacker texturePacker = new TexturePacker(2048, 2048, 1, true);
    Pixmap pixmap;
    getPacketTextureSheetFor(assetType, texturePacker, pixmap);

    FileHandle fileHandle = assetsFolder.child("packed");
    fileHandle.mkdirs();
    Compatibility.get().nomedia(fileHandle);
    fileHandle = fileHandle.child(assetType[0].name() + ".cim");

    try {
        PixmapIO.writeCIM(fileHandle, texturePacker.getPixmap());
    } catch (GdxRuntimeException e) {
        Log.error("Failed to write packed image", e);
    }

    Texture texture = new Texture(fileHandle);
    texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
    PackedTextureSheet packedTextureSheet = new PackedTextureSheet(
            new Material(TextureAttribute.createDiffuse(texture)));
    packedTextureSheet.getMaterial().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));

    Map<Asset, TexturePacker.PackRectangle> rectangles = texturePacker.getRectangles();
    int num = 0;
    for (Map.Entry<Asset, TexturePacker.PackRectangle> entry : rectangles.entrySet()) {
        num++;
        TextureRegion textureRegion = new TextureRegion(texture, entry.getValue().x, entry.getValue().y,
                entry.getValue().width, entry.getValue().height);
        entry.getKey().setPackedTextureRegion(textureRegion, packedTextureSheet);
        packedTextureSheet.getPackedTextures().put(entry.getKey().toString(), textureRegion);
    }

    for (AssetType type : assetType) {
        type.setPackedTextureSheet(packedTextureSheet);
    }
    return packedTextureSheet;
}
项目:nhglib    文件:ParticleShader.java   
@Override
public void render(final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type)) {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }

    bindMaterial(renderable);

    super.render(renderable);
}
项目: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    文件:DepthMapShader.java   
@Override
public void render(final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type)) {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    } else {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }

    updateBones(renderable);
    super.render(renderable);
}
项目: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));
}
项目:Argent    文件:SimpleTextureShader.java   
@Override
public void render(final Renderable renderable)
{
    if (!renderable.material.has(BlendingAttribute.Type))
    {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    else
    {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目:Argent    文件:ShadowMapShader.java   
@Override
public void render(final Renderable renderable)
{
    if (!renderable.material.has(BlendingAttribute.Type))
    {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    else
    {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目:Argent    文件:VolumetricDepthShader.java   
@Override
public void render(final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type)) {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    } else {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目:Argent    文件:DynamicShader.java   
@Override
public void render(final Renderable renderable)  {
    if (!renderable.material.has(BlendingAttribute.Type))  {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }else{
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目:Argent    文件:NormalTextureShader.java   
@Override
public void render(final Renderable renderable)
{
    if (!renderable.material.has(BlendingAttribute.Type))
    {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    else
    {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目:Argent    文件:DepthMapShader.java   
@Override
public void render(final Renderable renderable)
{
    if (!renderable.material.has(BlendingAttribute.Type))
    {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    else
    {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }
    super.render(renderable);
}
项目: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;
}
项目:ChessGDX    文件:GridSpaceHighlighter.java   
/**
 * Typically transparent plane that covers a board grid space. Can change
 * color to specify legal or illegal moves to the user.
 * 
 * @param fullModelInstance
 * @param indexPosition
 *            Chesspresso notation board location (0 to 63)
 */
public GridSpaceHighlighter(ModelInstance fullModelInstance, int indexPosition) {
    super(fullModelInstance);

    mGridState = GridState.NONE;
    mAlphaBlend = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.0f);

    // translate to starting board position
    Vector3 initialPosition = getGridToPerspectiveTranslation(indexPosition);
    setTranslation(initialPosition);

    fullModelInstance.materials.get(0).set(mAlphaBlend);
}
项目:Radix    文件:GameRenderer.java   
private void drawBlockSelection() {
    int curProgressInt = Math.round(RadixClient.getInstance().getPlayer().getBreakPercent() * 10) - 1;
    if ((blockBreakModel == null || blockBreakStage != curProgressInt) && curProgressInt >= 0) {
        if (blockBreakModel != null)
            blockBreakModel.dispose();

        blockBreakStage = curProgressInt;

        ModelBuilder builder = new ModelBuilder();
        blockBreakModel = builder.createBox(1f, 1f, 1f,
                new Material(TextureAttribute.createDiffuse(blockBreakStages[blockBreakStage]),
                        new BlendingAttribute(),
                        FloatAttribute.createAlphaTest(0.25f)),
                VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates);
        blockBreakModelInstance = new ModelInstance(blockBreakModel);
    }

    Vec3i curBlk = RadixClient.getInstance().getSelectedBlock();
    if (curBlk != null && curProgressInt >= 0) {
        Gdx.gl.glPolygonOffset(100000, 2000000);
        blockOverlayBatch.begin(RadixClient.getInstance().getCamera());
        blockBreakModelInstance.transform.translate(curBlk.x + 0.5f, curBlk.y + 0.5f, curBlk.z + 0.5f);
        blockOverlayBatch.render(blockBreakModelInstance);
        blockBreakModelInstance.transform.translate(-(curBlk.x + 0.5f), -(curBlk.y + 0.5f), -(curBlk.z + 0.5f));
        blockOverlayBatch.end();
        Gdx.gl.glPolygonOffset(100000, -2000000);
    }
}
项目:GdxDemo3D    文件:ModelFactory.java   
public static Model buildBillboardModel(Texture texture, float width, float height) {
    TextureRegion textureRegion = new TextureRegion(texture, texture.getWidth(), texture.getHeight());
    Material material = new Material();
    material.set(new TextureAttribute(TextureAttribute.Diffuse, textureRegion));
    material.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
    material.set(new BlendingAttribute());
    return ModelFactory.buildPlaneModel(width, height, material, 0, 0, 1, 1);
}
项目:Alien-Ark    文件:Rocket.java   
public void drawModel(ModelBatch modelBatch, Environment environment, ParticleEffect[] thrustEffect,
                      ParticleEffect effectExplosion) {

    if (!exploded) {
        modelBatch.render(rocketModelInstance, environment);

        long damageDelay = System.currentTimeMillis() - lastDamageTime;
        if (damageDelay < MIN_DAMAGE_DELAY_MILLIS) {
            float opacity = (float) damageDelay / (float) (MIN_DAMAGE_DELAY_MILLIS);
            ((BlendingAttribute) shieldModelInstance.materials.get(0).get(BlendingAttribute.Type)).opacity = opacity;
            modelBatch.render(shieldModelInstance, environment);
        }

        if (tractorBeamVisible) {
            modelBatch.render(tractorBeamModelInstance, environment);
        }
    }

    thrustMatrix1.set(rocketModelInstance.transform);
    tmpMatrix.setToRotation(0, 1, 0, drill);
    tmpMatrix.trn(0, 1, 0.35f);
    thrustMatrix1.mul(tmpMatrix);
    thrustEffect[0].setTransform(thrustMatrix1);

    thrustMatrix2.set(rocketModelInstance.transform);
    tmpMatrix.setToRotation(0, 1, 0, drill);
    tmpMatrix.trn(-0.35f, 1, -0.20f);
    thrustMatrix2.mul(tmpMatrix);
    thrustEffect[1].setTransform(thrustMatrix2);


    thrustMatrix3.set(rocketModelInstance.transform);
    tmpMatrix.setToRotation(0, 1, 0, drill);
    tmpMatrix.trn(0.350f, 1, -0.25f);
    thrustMatrix3.mul(tmpMatrix);
    thrustEffect[2].setTransform(thrustMatrix3);


    effectExplosion.setTransform(rocketModelInstance.transform);
}
项目:ForgE    文件:CameraRenderableSorter.java   
public int compare (final Renderable o1, final Renderable o2) {
  final boolean b1 = o1.material != null && o1.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o1.material.get(BlendingAttribute.Type)).blended;
  final boolean b2 = o2.material != null && o2.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o2.material.get(BlendingAttribute.Type)).blended;
  if (b1 != b2) return b1 ? 1 : -1;

  o1.worldTransform.getTranslation(tmpV1);
  o2.worldTransform.getTranslation(tmpV2);
  final float dst = (int)(SORT_FACTOR * camera.position.dst2(tmpV1)) - (int)(SORT_FACTOR * camera.position.dst2(tmpV2));
  final int result = dst < 0 ? -1 : (dst > 0 ? 1 : 0);
  return b1 ? -result : result;
}
项目:ForgE    文件:VoxelChunkRenderableFactorySerializer.java   
@Override
public VoxelChunkRenderableFactory read(Kryo kryo, Input input, Class<VoxelChunkRenderableFactory> type) {
  VoxelChunkRenderableFactory factory = new VoxelChunkRenderableFactory();
  factory.triangleCount               = input.readInt();
  factory.primitiveType               = input.readInt();

  factory.material                    = new Material();
  if (input.readBoolean())
    factory.material.set(new SolidTerrainAttribute());

  if (input.readBoolean())
    factory.material.set(new BlendingAttribute());

  if (input.readBoolean())
    factory.material.set(new WaterAttribute());

  int attributeCount                  = input.readInt();
  factory.attributes                  = new MeshVertexInfo.AttributeType[attributeCount];
  for (int i = 0; i < attributeCount; i++) {
    factory.attributes[i] = kryo.readObject(input, MeshVertexInfo.AttributeType.class);
  }

  int vertCount                       = input.readInt();
  int indiCount                       = input.readInt();

  factory.meshFactory                 = new MeshFactory(input.readFloats(vertCount), input.readShorts(indiCount), factory.attributes);

  return factory;
}
项目:libgdxcn    文件:DefaultShader.java   
@Override
public void render (final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type))
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    bindMaterial(renderable);
    if (lighting) bindLights(renderable);
    super.render(renderable);
}
项目: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    文件:DefaultRenderableSorter.java   
@Override
public int compare (final Renderable o1, final Renderable o2) {
    final boolean b1 = o1.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o1.material.get(BlendingAttribute.Type)).blended;
    final boolean b2 = o2.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o2.material.get(BlendingAttribute.Type)).blended;
    if (b1 != b2) return b1 ? 1 : -1;
    // FIXME implement better sorting algorithm
    // final boolean same = o1.shader == o2.shader && o1.mesh == o2.mesh && (o1.lights == null) == (o2.lights == null) &&
    // o1.material.equals(o2.material);
    o1.worldTransform.getTranslation(tmpV1);
    o2.worldTransform.getTranslation(tmpV2);
    final float dst = (int)(1000f * camera.position.dst2(tmpV1)) - (int)(1000f * camera.position.dst2(tmpV2));
    final int result = dst < 0 ? -1 : (dst > 0 ? 1 : 0);
    return b1 ? -result : result;
}
项目: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    文件:ModelInstanceRenderer.java   
@Override
public void update () {
    for(int i=0, positionOffset = 0, c = controller.particles.size;
        i< c; 
        ++i, positionOffset += renderData.positionChannel.strideSize){
        ModelInstance instance = renderData.modelInstanceChannel.data[i];
        float scale = hasScale ? renderData.scaleChannel.data[i] : 1;
        float qx=0, qy=0, qz=0, qw=1;
        if(hasRotation){
            int rotationOffset = i* renderData.rotationChannel.strideSize;
            qx = renderData.rotationChannel.data[rotationOffset + ParticleChannels.XOffset];
            qy = renderData.rotationChannel.data[rotationOffset + ParticleChannels.YOffset]; 
            qz = renderData.rotationChannel.data[rotationOffset + ParticleChannels.ZOffset];
            qw = renderData.rotationChannel.data[rotationOffset + ParticleChannels.WOffset];
        }

        instance.transform.set( renderData.positionChannel.data[positionOffset + ParticleChannels.XOffset],
            renderData.positionChannel.data[positionOffset + ParticleChannels.YOffset],
            renderData.positionChannel.data[positionOffset + ParticleChannels.ZOffset],
            qx, qy, qz, qw,
            scale, scale, scale);
        if(hasColor){
            int colorOffset = i*renderData.colorChannel.strideSize;
            ColorAttribute colorAttribute = (ColorAttribute)instance.materials.get(0).get(ColorAttribute.Diffuse);
            BlendingAttribute blendingAttribute = (BlendingAttribute)instance.materials.get(0).get(BlendingAttribute.Type);
            colorAttribute.color.r = renderData.colorChannel.data[colorOffset +ParticleChannels.RedOffset];
            colorAttribute.color.g = renderData.colorChannel.data[colorOffset +ParticleChannels.GreenOffset];
            colorAttribute.color.b = renderData.colorChannel.data[colorOffset +ParticleChannels.BlueOffset];
            if(blendingAttribute != null)
                blendingAttribute.opacity  = renderData.colorChannel.data[colorOffset +ParticleChannels.AlphaOffset];
        }
    }
    super.update();
}
项目:libgdxcn    文件:ParticleShader.java   
@Override
public void render (final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type))
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    bindMaterial(renderable);
    super.render(renderable);
}
项目: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);
}
项目:libgdxcn    文件:SkeletonTest.java   
@Override
protected void onLoaded () {
    if (currentlyLoading == null || currentlyLoading.isEmpty()) return;

    instances.clear();
    animationControllers.clear();
    final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
    for (Material m : instance.materials)
        m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f));
    instances.add(instance);
    if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance));
    currentlyLoading = null;
}