Search in sources :

Example 6 with TFloatList

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();
}
Also used : GLTFBufferView(org.terasology.engine.rendering.gltf.model.GLTFBufferView) TFloatList(gnu.trove.list.TFloatList) GLTFAccessor(org.terasology.engine.rendering.gltf.model.GLTFAccessor) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 7 with TFloatList

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;
}
Also used : GLTFBufferView(org.terasology.engine.rendering.gltf.model.GLTFBufferView) Matrix4f(org.joml.Matrix4f) TFloatList(gnu.trove.list.TFloatList) GLTFAccessor(org.terasology.engine.rendering.gltf.model.GLTFAccessor) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 8 with TFloatList

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

Example 9 with TFloatList

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

Example 10 with TFloatList

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

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