List of usage examples for com.badlogic.gdx.graphics VertexAttributes VertexAttributes
public VertexAttributes(VertexAttribute... attributes)
From source file:com.gemserk.commons.gdx.graphics.Gdx2dMeshBuilder.java
License:Apache License
public Gdx2dMeshBuilder(int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords) { this.maxVertices = maxVertices; VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords); vertexAttributes = new VertexAttributes(attribs); vertexSize = vertexAttributes.vertexSize / 4; vertices = new float[maxVertices * vertexSize]; normalOffset = getOffset(vertexAttributes, Usage.Normal); colorOffset = getOffset(vertexAttributes, Usage.ColorPacked); texCoordOffset = getOffset(vertexAttributes, Usage.TextureCoordinates); }
From source file:com.perfectplay.org.SkyBox.java
License:Open Source License
public static Mesh genSkyBox() { Mesh mesh = new Mesh(true, 8, 14, new VertexAttributes(new VertexAttribute(Usage.Position, 3, "a_position"))); float[] cubeVerts = { -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, }; short[] indices = { 0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1 }; mesh.setVertices(cubeVerts);//from w ww .j av a 2 s.co m mesh.setIndices(indices); return mesh; }
From source file:gaia.cu9.ari.gaiaorbit.util.g3d.MeshBuilder2.java
License:Apache License
/** @param usage bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal and * TextureCoordinates is supported. */ public static VertexAttributes createAttributes(long usage) { final Array<VertexAttribute> attrs = new Array<VertexAttribute>(); if ((usage & Usage.Position) == Usage.Position) attrs.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE)); if ((usage & Usage.ColorUnpacked) == Usage.ColorUnpacked) attrs.add(new VertexAttribute(Usage.ColorUnpacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); if ((usage & Usage.ColorPacked) == Usage.ColorPacked) attrs.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); if ((usage & Usage.Normal) == Usage.Normal) attrs.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)); if ((usage & Usage.TextureCoordinates) == Usage.TextureCoordinates) attrs.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0")); final VertexAttribute attributes[] = new VertexAttribute[attrs.size]; for (int i = 0; i < attributes.length; i++) attributes[i] = attrs.get(i);/*from ww w . j a v a 2 s .co m*/ return new VertexAttributes(attributes); }