Search in sources :

Example 36 with Entry

use of com.jme3.util.IntMap.Entry in project jmonkeyengine by jMonkeyEngine.

the class SkeletonLoader method endElement.

public void endElement(String uri, String name, String qName) {
    if (qName.equals("translate") || qName.equals("position") || qName.equals("scale")) {
    } else if (qName.equals("axis")) {
    } else if (qName.equals("rotate") || qName.equals("rotation")) {
        rotation = new Quaternion();
        axis.normalizeLocal();
        rotation.fromAngleNormalAxis(angle, axis);
        angle = 0;
        axis = null;
    } else if (qName.equals("bone")) {
        bone.setBindTransforms(position, rotation, scale);
        bone = null;
        position = null;
        rotation = null;
        scale = null;
    } else if (qName.equals("bonehierarchy")) {
        Bone[] bones = new Bone[indexToBone.size()];
        // also assign the bones to the bonelist
        for (Map.Entry<Integer, Bone> entry : indexToBone.entrySet()) {
            Bone bone = entry.getValue();
            bones[entry.getKey()] = bone;
        }
        indexToBone.clear();
        skeleton = new Skeleton(bones);
    } else if (qName.equals("animation")) {
        animations.add(animation);
        animation = null;
    } else if (qName.equals("track")) {
        if (track != null) {
            // if track has keyframes
            tracks.add(track);
            track = null;
        }
    } else if (qName.equals("tracks")) {
        BoneTrack[] trackList = tracks.toArray(new BoneTrack[tracks.size()]);
        animation.setTracks(trackList);
        tracks.clear();
    } else if (qName.equals("keyframe")) {
        assert time >= 0;
        assert position != null;
        assert rotation != null;
        times.add(time);
        translations.add(position);
        rotations.add(rotation);
        if (scale != null) {
            scales.add(scale);
        } else {
            scales.add(new Vector3f(1, 1, 1));
        }
        time = -1;
        position = null;
        rotation = null;
        scale = null;
    } else if (qName.equals("keyframes")) {
        if (times.size() > 0) {
            float[] timesArray = new float[times.size()];
            for (int i = 0; i < timesArray.length; i++) {
                timesArray[i] = times.get(i);
            }
            Vector3f[] transArray = translations.toArray(new Vector3f[translations.size()]);
            Quaternion[] rotArray = rotations.toArray(new Quaternion[rotations.size()]);
            Vector3f[] scalesArray = scales.toArray(new Vector3f[scales.size()]);
            track.setKeyframes(timesArray, transArray, rotArray, scalesArray);
        //track.setKeyframes(timesArray, transArray, rotArray);
        } else {
            track = null;
        }
        times.clear();
        translations.clear();
        rotations.clear();
        scales.clear();
    } else if (qName.equals("skeleton")) {
        nameToBone.clear();
    }
    assert elementStack.peek().equals(qName);
    elementStack.pop();
}
Also used : BoneTrack(com.jme3.animation.BoneTrack) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) Skeleton(com.jme3.animation.Skeleton) Bone(com.jme3.animation.Bone) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with Entry

use of com.jme3.util.IntMap.Entry in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method writeIntSavableMap.

@Override
public void writeIntSavableMap(IntMap<? extends Savable> map, String name, IntMap<? extends Savable> defVal) throws IOException {
    if (map == null) {
        return;
    }
    if (map.equals(defVal)) {
        return;
    }
    Element stringMap = appendElement(name);
    for (Entry<? extends Savable> entry : map) {
        int key = entry.getKey();
        Element mapEntry = appendElement("MapEntry");
        mapEntry.setAttribute("key", Integer.toString(key));
        Savable s = entry.getValue();
        write(s, "Savable", null);
        currentElement = stringMap;
    }
    currentElement = (Element) stringMap.getParentNode();
}
Also used : Savable(com.jme3.export.Savable) Element(org.w3c.dom.Element)

Aggregations

HashMap (java.util.HashMap)17 Map (java.util.Map)13 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Vector2f (com.jme3.math.Vector2f)8 Vector3f (com.jme3.math.Vector3f)7 Node (com.jme3.scene.Node)6 Spatial (com.jme3.scene.Spatial)6 VertexBuffer (com.jme3.scene.VertexBuffer)5 Material (com.jme3.material.Material)4 FloatBuffer (java.nio.FloatBuffer)4 Bone (com.jme3.animation.Bone)3 Geometry (com.jme3.scene.Geometry)3 Mesh (com.jme3.scene.Mesh)3 Pointer (com.jme3.scene.plugins.blender.file.Pointer)3 Structure (com.jme3.scene.plugins.blender.file.Structure)3 Face (com.jme3.scene.plugins.blender.meshes.Face)3 Image (com.jme3.texture.Image)3 IntMap (com.jme3.util.IntMap)3 ByteBuffer (java.nio.ByteBuffer)3