Example usage for com.badlogic.gdx.graphics VertexAttributes findByUsage

List of usage examples for com.badlogic.gdx.graphics VertexAttributes findByUsage

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics VertexAttributes findByUsage.

Prototype

public VertexAttribute findByUsage(int usage) 

Source Link

Document

Returns the first VertexAttribute for the given usage.

Usage

From source file:gaia.cu9.ari.gaiaorbit.util.g3d.MeshBuilder2.java

License:Apache License

/** Begin building a mesh */
public void begin(final VertexAttributes attributes, int primitiveType) {
    if (this.attributes != null)
        throw new RuntimeException("Call end() first");
    this.attributes = attributes;
    this.vertices.clear();
    this.indices.clear();
    this.parts.clear();
    this.vindex = 0;
    this.istart = 0;
    this.part = null;
    this.stride = attributes.vertexSize / 4;
    this.vertex = new float[stride];
    VertexAttribute a = attributes.findByUsage(Usage.Position);
    if (a == null)
        throw new GdxRuntimeException("Cannot build mesh without position attribute");
    posOffset = a.offset / 4;//  w  w  w .  j  a v  a 2  s.  co m
    posSize = a.numComponents;
    a = attributes.findByUsage(Usage.Normal);
    norOffset = a == null ? -1 : a.offset / 4;
    a = attributes.findByUsage(Usage.ColorUnpacked);
    colOffset = a == null ? -1 : a.offset / 4;
    colSize = a == null ? 0 : a.numComponents;
    a = attributes.findByUsage(Usage.ColorPacked);
    cpOffset = a == null ? -1 : a.offset / 4;
    a = attributes.findByUsage(Usage.TextureCoordinates);
    uvOffset = a == null ? -1 : a.offset / 4;
    setColor(null);
    this.primitiveType = primitiveType;
}