public static BufferObject setStd140BufferLayout(List<StructField<?>> fields, Std140Layout serializer, BufferObject out) {// ,
                                                                                                                              // final
                                                                                                                              // List<Field>
                                                                                                                              // fieldList)
                                                                                                                              // {

        int pos = -1;

        List<BufferRegion> regions = new ArrayList<BufferRegion>();

        for (int i = 0; i < fields.size(); i++) {
            StructField<?> f = fields.get(i);
            Object v = f.getValue();

            int basicAlignment = serializer.getBasicAlignment(v);
            int length = serializer.estimateSize(v);

            int start = serializer.align(pos + 1, basicAlignment);
            int end = start + length - 1;

            if ((i == fields.size() - 1) || f.getGroup()!= fields.get(i + 1).getGroup()){// > fields.get(i + 1).getDepth()) {
                end = (serializer.align(end, 16)) - 1;
            }

            BufferRegion r = new BufferRegion(start, end);
            regions.add(r);
            pos = end;
        }

        out.setRegions(regions);

        return out;
    }
Get sorted List of StructFields from a Struct object

@param struct
           the struct object
@return the sorted list
jme3-core/src/main/java/com/jme3/util/struct/StructUtils.java