Adds a new mesh to the object, constructed from the given memblock. The first 4 bytes of the memblock represent the number of vertices in the mesh. The second 4 bytes represent the number of indices in the mesh, this may be 0 in which case every three vertices represents a polygon, and no vertices can be shared. If the number of indices is greater than 0 then every three indices represent a polygon and vertices may be shared between polygons. Indices start at 0 so index 0 references the first vertex in the list. The third 4 bytes represents the number of attributes per vertex, e.g. position, normals, and UV data are all potential attributes, so a vertex containing all three would have 3 attributes. A vertex must have a position attribute, everything else is optional. The fourth 4 bytes represent the size of a single vertex in bytes, this can be calculated from the attribute data but is given for convenience. The fifth 4 bytes is offset for the beginning of the vertex data, so you can reach it easily. The sixth 4 bytes is offset for the beginning of the index data, will be 0 if there are no indices. After those 6 values, starting at offset 24, is the vertex attribute data. The vertex attribute data describes how the vertex data is laid out, for example if it has normals, UV data, etc. For each attribute there is a 1 byte data type, 1 byte component count, 1 byte normalize flag, 1 byte string length, and X bytes of string data for the attribute name. The data type will be 0 for floats (used for almost everything, e.g. position, normals, etc) or 1 for unsigned bytes (used for vertex colors). The component count is the number of values per attribute, e.g. position has 3 components, x,y,z, UV data has 2 components, and vertex colors have 4 components. Note that any unsigned byte data type must have 4 components even if some are unused. The normalize flag is only used for unsigned byte data types and will convert values in the range 0-255 into 0.0-1.0 for use in a shader. Usually the normalize flag will be 1 for color attributes and 0 for everything else. The string length byte must always be a multiple of 4 for alignment reasons, the string itself might have slightly less characters but always round up to the nearest multiple of 4 for the string length value. e.g. a string of length 5 should have a string length value of 8. Note that a string of 4 characters has a null terminator on the end which makes it length 5, so even though it has a multiple of 4 characters already it must use a length value of 8 due to the null terminator. The attribute name string will be used by the shader to recognise what the vertex data is, the attribute names recognised by AGK are "position", "normal", "tangent", "binormal", "color", "uv", "uv1", "boneweights", and "boneindices", however you may add attributes with any name you like as long as you write a matching shader that has the same names. If you are not using your own shader and instead rely on AGK to draw the object then you must stick to the above attribute names. Following the attribute data is the raw vertex data, which usually starts with the "position" attribute. It will be a 4 byte float for the X position, a 4 byte float for the Y position, and a 4 byte float for the Z position. This continues for each attribute specified in the attribute data. Note that color data will always be 4 bytes in total, 1 unsigned byte for each color channel. You can access individual vertices by using the vertex size provided above and the vertex index like so offset=vertexDataOffset+(vertexIndex*vertexSize). Lastly is the index data, if present. Each index is a 4 byte integer which references a vertex in the vertex data. Every three indices represents a polygon.


AddObjectMeshFromMemblock( objID, memID )