use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class TroveUtils method longToFloat.
public static TFloatList longToFloat(TLongList list) {
TFloatList result = new TFloatArrayList(list.size());
TLongIterator iterator = list.iterator();
while (iterator.hasNext()) {
long i = iterator.next();
result.add(i);
}
return result;
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class Matrix4fDeserializer method deserialize.
@Override
public Matrix4f deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
TFloatList result = new TFloatArrayList();
json.getAsJsonArray().forEach(x -> result.add(x.getAsFloat()));
if (result.size() != 16) {
throw new JsonParseException("Incorrect number of values for ImmutableMatrix4f - expected 16");
}
return new Matrix4f(result.get(0), result.get(1), result.get(2), result.get(3), result.get(4), result.get(5), result.get(6), result.get(7), result.get(8), result.get(9), result.get(10), result.get(11), result.get(12), result.get(13), result.get(14), result.get(15));
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class AABBfTypeHandler method deserialize.
@Override
public Optional<AABBf> deserialize(PersistedData data) {
if (!data.isNull() && data.isValueMap()) {
PersistedDataMap map = data.getAsValueMap();
PersistedDataArray minDataArr = map.get(MIN_FIELD).getAsArray();
PersistedDataArray maxDataArr = map.get(MAX_FIELD).getAsArray();
TFloatList minArr = minDataArr.getAsFloatArray();
TFloatList maxArr = maxDataArr.getAsFloatArray();
return Optional.of(new AABBf(minArr.get(0), minArr.get(1), minArr.get(2), maxArr.get(0), maxArr.get(1), maxArr.get(2)));
}
return Optional.empty();
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class RectanglefTypeHandler method deserialize.
@Override
public Optional<Rectanglef> deserialize(PersistedData data) {
if (!data.isNull() && data.isValueMap()) {
PersistedDataMap map = data.getAsValueMap();
PersistedDataArray minDataArr = map.get(MIN_FIELD).getAsArray();
TFloatList minArr = minDataArr.getAsFloatArray();
if (map.has(SIZE_FIELD)) {
PersistedDataArray sizedataArray = map.get(SIZE_FIELD).getAsArray();
TIntList sizeArr = sizedataArray.getAsIntegerArray();
return Optional.of(new Rectanglef(minArr.get(0), minArr.get(1)).setSize(sizeArr.get(0), sizeArr.get(1)));
}
PersistedDataArray maxDataArr = map.get(MAX_FIELD).getAsArray();
TFloatList maxArr = maxDataArr.getAsFloatArray();
return Optional.of(new Rectanglef(minArr.get(0), minArr.get(1), maxArr.get(0), maxArr.get(1)));
}
return Optional.empty();
}
use of gnu.trove.list.TFloatList in project Terasology by MovingBlocks.
the class GLTFAnimationFormat method getVector3fs.
private List<Vector3f> getVector3fs(GLTF gltf, List<byte[]> loadedBuffers, int accessorIndex) throws IOException {
TFloatList floats = getFloats(gltf, loadedBuffers, accessorIndex);
List<Vector3f> vectors = Lists.newArrayListWithCapacity(floats.size() / 3);
for (int i = 0; i < floats.size(); i += 3) {
vectors.add(new Vector3f(floats.get(i), floats.get(i + 1), floats.get(i + 2)));
}
return vectors;
}
Aggregations