private float[] readVertices(CtmInputStream input, Grid grid, int vcount, float precision) { checkTag(input.readLittleInt(), VERT); int[] intVertices = input.readPackedInts(vcount, Mesh.CTM_POSITION_ELEMENT_COUNT, false); checkTag(input.readLittleInt(), GIDX); int[] gridIndices = input.readPackedInts(vcount, 1, false); for (int i = 1; i < vcount; i++) { gridIndices[i] += gridIndices[i - 1]; } return(CommonAlgorithm.restoreVertices(intVertices, gridIndices, grid, precision)); }
private float[] readNormals(CtmInputStream input, float[] vertices, int[] indices, float normalPrecision, int vcount) { checkTag(input.readLittleInt(), NORM); int[] intNormals = input.readPackedInts(vcount, Mesh.CTM_NORMAL_ELEMENT_COUNT, false); return(restoreNormals(intNormals, vertices, indices, normalPrecision)); }
private int[] readIndices(CtmInputStream input, int triCount, int vcount) { checkTag(input.readLittleInt(), INDX); int[] indices = input.readPackedInts(triCount, 3, false); restoreIndices(triCount, indices); foreach(int i in indices) { if (i > vcount) { throw new InvalidDataException("One element of the indice array " + "points to a none existing vertex(id: " + i + ")"); } } return indices; }
private AttributeData readAttribute(CtmInputStream input, int vc) { checkTag(input.readLittleInt(), ATTR); String name = input.readString(); float precision = input.readLittleFloat(); if (precision <= 0f) { throw new InvalidDataException("An attribute precision value <= 0.0 was read"); } int[] intData = input.readPackedInts(vc, Mesh.CTM_ATTR_ELEMENT_COUNT, true); float[] data = restoreAttribs(precision, intData); return new AttributeData(name, null, precision, data); }
private int[] readIndices(CtmInputStream input, int triCount, int vcount) { checkTag(input.readLittleInt(), INDX); int[] indices = input.readPackedInts(triCount, 3, false); restoreIndices(triCount, indices); foreach (int i in indices) { if (i > vcount) { throw new InvalidDataException("One element of the indice array " + "points to a none existing vertex(id: " + i + ")"); } } return(indices); }
private AttributeData readUvData(CtmInputStream input, int vcount) { checkTag(input.readLittleInt(), TEXC); String name = input.readString(); String material = input.readString(); float precision = input.readLittleFloat(); if (precision <= 0f) { throw new InvalidDataException("A uv precision value <= 0.0 was read"); } int[] intCoords = input.readPackedInts(vcount, Mesh.CTM_UV_ELEMENT_COUNT, true); float[] data = restoreUVCoords(precision, intCoords); return(new AttributeData(name, material, precision, data)); }
private AttributeData readAttribute(CtmInputStream input, int vc) { checkTag(input.readLittleInt(), ATTR); String name = input.readString(); float precision = input.readLittleFloat(); if (precision <= 0f) { throw new InvalidDataException("An attribute precision value <= 0.0 was read"); } int[] intData = input.readPackedInts(vc, Mesh.CTM_ATTR_ELEMENT_COUNT, true); float[] data = restoreAttribs(precision, intData); return(new AttributeData(name, null, precision, data)); }
private AttributeData readUvData(CtmInputStream input, int vcount) { checkTag(input.readLittleInt(), TEXC); String name = input.readString(); String material = input.readString(); float precision = input.readLittleFloat(); if (precision <= 0f) { throw new InvalidDataException("A uv precision value <= 0.0 was read"); } int[] intCoords = input.readPackedInts(vcount, Mesh.CTM_UV_ELEMENT_COUNT, true); float[] data = restoreUVCoords(precision, intCoords); return new AttributeData(name, material, precision, data); }
private float[] readNormals(CtmInputStream input, float[] vertices, int[] indices, float normalPrecision, int vcount) { checkTag(input.readLittleInt(), NORM); int[] intNormals = input.readPackedInts(vcount, Mesh.CTM_NORMAL_ELEMENT_COUNT, false); return restoreNormals(intNormals, vertices, indices, normalPrecision); }
private float[] readVertices(CtmInputStream input, Grid grid, int vcount, float precision) { checkTag(input.readLittleInt(), VERT); int[] intVertices = input.readPackedInts(vcount, Mesh.CTM_POSITION_ELEMENT_COUNT, false); checkTag(input.readLittleInt(), GIDX); int[] gridIndices = input.readPackedInts(vcount, 1, false); for (int i = 1; i < vcount; i++) { gridIndices[i] += gridIndices[i - 1]; } return CommonAlgorithm.restoreVertices(intVertices, gridIndices, grid, precision); }
protected override int[] readIntArray(CtmInputStream input, int count, int size, bool signed) { return(input.readPackedInts(count, size, signed)); }