/** Returns the offset for the first VertexAttribute with the specified usage. * @param usage The usage of the VertexAttribute. */ public int getOffset (int usage) { return getOffset(usage, 0); }
/** Returns the offset for the first VertexAttribute with the specified usage. * @param usage The usage of the VertexAttribute. */ public int getOffset (int usage) { return getOffset(usage, 0); }
public HeightField (boolean isStatic, int width, int height, boolean smooth, VertexAttributes attributes) { this.posPos = attributes.getOffset(Usage.Position, -1); this.norPos = attributes.getOffset(Usage.Normal, -1); this.uvPos = attributes.getOffset(Usage.TextureCoordinates, -1); this.colPos = attributes.getOffset(Usage.ColorUnpacked, -1); smooth = smooth || (norPos < 0); // cant have sharp edges without normals this.width = width; this.height = height; this.smooth = smooth; this.data = new float[width * height]; this.stride = attributes.vertexSize / 4; final int numVertices = smooth ? width * height : (width - 1) * (height - 1) * 4; final int numIndices = (width - 1) * (height - 1) * 6; this.mesh = new Mesh(isStatic, numVertices, numIndices, attributes); this.vertices = new float[numVertices * stride]; setIndices(); }
/** Returns the offset for the first VertexAttribute with the specified usage. * @param usage The usage of the VertexAttribute. */ public int getOffset (int usage) { return getOffset(usage, 0); }
private Terrain(int vertexResolution) { this.transform = new Matrix4(); this.attribs = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates); this.posPos = attribs.getOffset(VertexAttributes.Usage.Position, -1); this.norPos = attribs.getOffset(VertexAttributes.Usage.Normal, -1); this.uvPos = attribs.getOffset(VertexAttributes.Usage.TextureCoordinates, -1); this.stride = attribs.vertexSize / 4; this.vertexResolution = vertexResolution; this.heightData = new float[vertexResolution * vertexResolution]; this.terrainTexture = new TerrainTexture(); this.terrainTexture.setTerrain(this); material = new Material(); material.set(new TerrainTextureAttribute(TerrainTextureAttribute.ATTRIBUTE_SPLAT0, terrainTexture)); }