use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class GLTFCommonFormat method readFloatBuffer.
protected TFloatList readFloatBuffer(MeshAttributeSemantic semantic, GLTFPrimitive gltfPrimitive, GLTF gltf, List<byte[]> loadedBuffers) throws IOException {
GLTFAccessor gltfAccessor = getAccessor(semantic, gltfPrimitive, gltf);
if (gltfAccessor != null && gltfAccessor.getBufferView() != null) {
GLTFBufferView bufferView = gltf.getBufferViews().get(gltfAccessor.getBufferView());
TFloatList floats = new TFloatArrayList();
readBuffer(loadedBuffers.get(bufferView.getBuffer()), gltfAccessor, bufferView, floats);
return floats;
}
return new TFloatArrayList();
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class GLTFCommonFormat method loadMat4fList.
protected List<Matrix4f> loadMat4fList(int inverseBindMatrices, GLTF gltf, List<byte[]> loadedBuffers) {
GLTFAccessor accessor = gltf.getAccessors().get(inverseBindMatrices);
GLTFBufferView bufferView = gltf.getBufferViews().get(accessor.getBufferView());
byte[] buffer = loadedBuffers.get(bufferView.getBuffer());
TFloatList values = new TFloatArrayList();
readBuffer(buffer, accessor, bufferView, values);
List<Matrix4f> matricies = Lists.newArrayList();
for (int i = 0; i < values.size(); i += 16) {
Matrix4f mat = new Matrix4f(values.get(i), values.get(i + 1), values.get(i + 2), values.get(i + 3), values.get(i + 4), values.get(i + 5), values.get(i + 6), values.get(i + 7), values.get(i + 8), values.get(i + 9), values.get(i + 10), values.get(i + 11), values.get(i + 12), values.get(i + 13), values.get(i + 14), values.get(i + 15));
matricies.add(mat);
}
return matricies;
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class QuaternionfDeserializer method deserialize.
@Override
public Quaternionf deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
TFloatList result = new TFloatArrayList();
json.getAsJsonArray().forEach(x -> result.add(x.getAsFloat()));
if (result.size() != 4) {
throw new JsonParseException("Incorrect number of values for ImmutableQuat4f - expected 4");
}
return new Quaternionf(result.get(0), result.get(1), result.get(2), result.get(3));
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class TFloatListDeserializer method deserialize.
@Override
public TFloatList deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
TFloatList result = new TFloatArrayList();
json.getAsJsonArray().forEach(x -> result.add(x.getAsFloat()));
return result;
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class TroveUtils method doubleToFloat.
public static TFloatList doubleToFloat(TDoubleList list) {
TFloatList result = new TFloatArrayList(list.size());
TDoubleIterator iterator = list.iterator();
while (iterator.hasNext()) {
double i = iterator.next();
result.add((float) i);
}
return result;
}
Aggregations