package speiger.src.coreengine.rendering.models.loader; import java.util.List; import com.google.gson.JsonObject; import speiger.src.coreengine.rendering.models.GLDataType; import speiger.src.coreengine.utils.helpers.JsonUtil; public class VertexEntry { String name; int size; GLDataType glType; boolean optional; public VertexEntry(JsonObject obj) { this(obj.get("type").getAsString(), obj.get("length").getAsInt(), GLDataType.byName(obj.get("glType").getAsString()), JsonUtil.getOrDefault(obj, "optional", false)); } public VertexEntry(String name, int size, GLDataType glType) { this(name, size, glType, false); } public VertexEntry(String name, int size, GLDataType glType, boolean optional) { this.name = name; this.size = size; this.glType = glType; this.optional = optional; } public String getName() { return name; } public int getSize() { return size; } public int getByteSize() { return size * glType.getByteSize(); } public GLDataType getType() { return glType; } public boolean isOptional() { return optional; } public static int caculateByteSize(List array, boolean excludeOptional) { int result = 0; for(int i = 0,m=array.size();i array, boolean excludeOptional) { return excludeOptional ? calculateNonOptionalStride(array) : caclulateStride(array); } public static int calculateNonOptionalStride(List array) { int size = 0; for(int i = 0,m=array.size();i array) { int size = 0; for(int i = 0,m=array.size();i