/** * Returns the buffer for the attribute at the provided index, or null if none can be found. The * buffer is returned filled and ready for reading. * * @param index The index to lookup * @return The attribute buffer, filled and flipped */ public ByteBuffer getAttributeBuffer(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getData(); }
/** * Returns the name of the attribute at the provided index, or null if none can be found. * * @param index The index to lookup * @return The name of the attribute, or null if none can be found */ public String getAttributeName(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getName(); }
/** * Returns the type of the attribute at the provided index, or null if none can be found. * * @param index The index to lookup * @return The type of the attribute, or null if none can be found */ public DataType getAttributeType(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getType(); }
/** * Returns the size of the attribute at the provided index, or -1 if none can be found. * * @param index The index to lookup * @return The size of the attribute, or -1 if none can be found */ public int getAttributeSize(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return -1; } return attribute.getSize(); }
/** * Erweitert die Geometrie um ein Vertexattribut vom Typ GL_FLOAT. * * @param index Index / Location des Attributs * @param size Anzahl der Komponenten des Attributs * @param offset Offset im Vertex gemessen in Byte */ public void addVertexAttribute(int index, int size, int offset) { VertexAttribute attr = new VertexAttribute(); attr.index = index; attr.size = size; attr.offset = offset; attributes.add(attr); }
private int calculateOffsets() { int count = 0; for (int i = 0; i < attributes.length; i++) { VertexAttribute attribute = attributes[i]; attribute.offset = count; if (attribute.usage == VertexAttributes.Usage.ColorPacked) count += 4; else count += 4 * attribute.numComponents; } return count; }
/** * Adds an attribute. * * @param attribute The attribute to add */ public void addAttribute(int index, VertexAttribute attribute) { attributes.put(index, attribute); nameToIndex.put(attribute.getName(), index); }