Package com.badlogic.gdx.graphics

Examples of com.badlogic.gdx.graphics.Mesh


    startX = new float[rays];
    startY = new float[rays];
    this.chain = (chain != null) ?
           new FloatArray(chain) : new FloatArray();
   
    lightMesh = new Mesh(
        VertexDataType.VertexArray, false, vertexNum, 0,
        new VertexAttribute(Usage.Position, 2, "vertex_positions"),
        new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
        new VertexAttribute(Usage.Generic, 1, "s"));
    softShadowMesh = new Mesh(
        VertexDataType.VertexArray, false, vertexNum * 2,
        0, new VertexAttribute(Usage.Position, 2, "vertex_positions"),
        new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
        new VertexAttribute(Usage.Generic, 1, "s"));
    setMesh();
View Full Code Here


   * @param defaultShader The default shader to use. This is not owned by the PolygonSpriteBatch and must be disposed separately. */
  public PolygonSpriteBatch (int size, ShaderProgram defaultShader) {
    // 32767 is max index, so 32767 / 3 - (32767 / 3 % 3) = 10920.
    if (size > 10920) throw new IllegalArgumentException("Can't have more than 10920 triangles per batch: " + size);

    mesh = new Mesh(VertexDataType.VertexArray, false, size, size * 3, new VertexAttribute(Usage.Position, 2,
      ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
      new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

    vertices = new float[size * VERTEX_SIZE];
    triangles = new short[size * 3];
 
View Full Code Here

    totalRenderCalls++;
    int trianglesInBatch = triangleIndex;
    if (trianglesInBatch > maxTrianglesInBatch) maxTrianglesInBatch = trianglesInBatch;

    lastTexture.bind();
    Mesh mesh = this.mesh;
    mesh.setVertices(vertices, 0, vertexIndex);
    mesh.setIndices(triangles, 0, triangleIndex);

    if (blendingDisabled) {
      Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
      Gdx.gl.glEnable(GL20.GL_BLEND);
      if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    mesh.render(customShader != null ? customShader : shader, GL20.GL_TRIANGLES, 0, trianglesInBatch);

    vertexIndex = 0;
    triangleIndex = 0;
  }
View Full Code Here

   * @param defaultShader The default shader to use. This is not owned by the SpriteBatch and must be disposed separately. */
  public SpriteBatch (int size, ShaderProgram defaultShader) {
    // 32767 is max index, so 32767 / 6 - (32767 / 6 % 3) = 5460.
    if (size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

    mesh = new Mesh(VertexDataType.VertexArray, false, size * 4, size * 6, new VertexAttribute(Usage.Position, 2,
      ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
      new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));

    projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

View Full Code Here

    int spritesInBatch = idx / 20;
    if (spritesInBatch > maxSpritesInBatch) maxSpritesInBatch = spritesInBatch;
    int count = spritesInBatch * 6;

    lastTexture.bind();
    Mesh mesh = this.mesh;
    mesh.setVertices(vertices, 0, idx);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(count);

    if (blendingDisabled) {
      Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
      Gdx.gl.glEnable(GL20.GL_BLEND);
      if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    mesh.render(customShader != null ? customShader : shader, GL20.GL_TRIANGLES, 0, count);

    idx = 0;
  }
View Full Code Here

  }

  @Deprecated
  public static Model createFromMesh (final float[] vertices, final VertexAttribute[] attributes, final short[] indices,
    int primitiveType, final Material material) {
    final Mesh mesh = new Mesh(false, vertices.length, indices.length, attributes);
    mesh.setVertices(vertices);
    mesh.setIndices(indices);
    return createFromMesh(mesh, 0, indices.length, primitiveType, material);
  }
View Full Code Here

    this.maxVertices = maxVertices;
    this.numTexCoords = numTexCoords;
    this.shader = shader;

    VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords);
    mesh = new Mesh(false, maxVertices, 0, attribs);

    vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)];
    vertexSize = mesh.getVertexAttributes().vertexSize / 4;
    normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0;
    colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4
View Full Code Here

  public SpriteCache (int size, ShaderProgram shader, boolean useIndices) {
    this.shader = shader;

    if (useIndices && size > 5460) throw new IllegalArgumentException("Can't have more than 5460 sprites per batch: " + size);

    mesh = new Mesh(true, size * (useIndices ? 4 : 6), useIndices ? size * 6 : 0, new VertexAttribute(Usage.Position, 2,
      ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
      new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
    mesh.setAutoBind(false);

    if (useIndices) {
View Full Code Here

  /** End building the mesh and returns the mesh */
  public Mesh end () {
    if (this.attributes == null) throw new RuntimeException("Call begin() first");
    endpart();

    final Mesh mesh = new Mesh(true, vertices.size / stride, indices.size, attributes);
    mesh.setVertices(vertices.items, 0, vertices.size);
    mesh.setIndices(indices.items, 0, indices.size);

    for (MeshPart p : parts)
      p.mesh = mesh;
    parts.clear();

View Full Code Here

    renderable.primitiveType = GL20.GL_TRIANGLES;
    renderable.meshPartOffset = 0;
    renderable.material = new Materialnew 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;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.Mesh

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.