Search in sources :

Example 11 with TFloatList

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;
}
Also used : TFloatList(gnu.trove.list.TFloatList) TLongIterator(gnu.trove.iterator.TLongIterator) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 12 with TFloatList

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));
}
Also used : Matrix4f(org.joml.Matrix4f) TFloatList(gnu.trove.list.TFloatList) JsonParseException(com.google.gson.JsonParseException) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 13 with TFloatList

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();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) AABBf(org.terasology.joml.geom.AABBf) PersistedDataMap(org.terasology.persistence.typeHandling.PersistedDataMap) TFloatList(gnu.trove.list.TFloatList)

Example 14 with TFloatList

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();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedDataMap(org.terasology.persistence.typeHandling.PersistedDataMap) Rectanglef(org.terasology.joml.geom.Rectanglef) TFloatList(gnu.trove.list.TFloatList) TIntList(gnu.trove.list.TIntList)

Example 15 with TFloatList

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;
}
Also used : Vector3f(org.joml.Vector3f) TFloatList(gnu.trove.list.TFloatList)

Aggregations

TFloatList (gnu.trove.list.TFloatList)23 TFloatArrayList (gnu.trove.list.array.TFloatArrayList)12 TIntList (gnu.trove.list.TIntList)6 Vector3f (org.joml.Vector3f)5 GLTFAccessor (org.terasology.engine.rendering.gltf.model.GLTFAccessor)4 GLTFBufferView (org.terasology.engine.rendering.gltf.model.GLTFBufferView)4 JsonParseException (com.google.gson.JsonParseException)3 IOException (java.io.IOException)3 Quaternionf (org.joml.Quaternionf)3 PersistedDataArray (org.terasology.persistence.typeHandling.PersistedDataArray)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ArrayList (java.util.ArrayList)2 Matrix4f (org.joml.Matrix4f)2 Bone (org.terasology.engine.rendering.assets.skeletalmesh.Bone)2 AABBf (org.terasology.joml.geom.AABBf)2 Vector2f (org.terasology.math.geom.Vector2f)2 Vector3f (org.terasology.math.geom.Vector3f)2 PersistedDataMap (org.terasology.persistence.typeHandling.PersistedDataMap)2 TDoubleIterator (gnu.trove.iterator.TDoubleIterator)1 TIntIterator (gnu.trove.iterator.TIntIterator)1