Java Code Examples for com.jme3.util.IntMap#put()

The following examples show how to use com.jme3.util.IntMap#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DOMInputCapsule.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal) throws IOException {
    IntMap<Savable> ret = null;
    Element tempEl;

    if (name != null) {
            tempEl = findChildElement(currentElem, name);
    } else {
            tempEl = currentElem;
    }
    if (tempEl != null) {
            ret = new IntMap<Savable>();

            NodeList nodes = tempEl.getChildNodes();
                for (int i = 0; i < nodes.getLength(); i++) {
                            Node n = nodes.item(i);
                            if (n instanceof Element && n.getNodeName().equals("MapEntry")) {
                                    Element elem = (Element) n;
                                    currentElem = elem;
                                    int key = Integer.parseInt(currentElem.getAttribute("key"));
                                    Savable val = readSavable("Savable", null);
                                    ret.put(key, val);
                            }
                    }
    } else {
            return defVal;
        }
    currentElem = (Element) tempEl.getParentNode();
    return ret;
}
 
Example 2
Source File: GLTracer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void noEnumArgs(String method, int... argSlots) {
    IntMap<Void> argSlotsMap = new IntMap<Void>();
    for (int argSlot : argSlots) {
        argSlotsMap.put(argSlot, null);
    }
    nonEnumArgMap.put(method, argSlotsMap);
}
 
Example 3
Source File: BitmapCharacterSet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private IntMap<BitmapCharacter> readCharset(InputCapsule ic, int style) throws IOException {
    IntMap<BitmapCharacter> charset = new IntMap<BitmapCharacter>();
    short[] indexes = ic.readShortArray("indexes"+style, null);
    Savable[] chars = ic.readSavableArray("chars"+style, null);

    for (int i = 0; i < indexes.length; i++){
        int index = indexes[i] & 0xFFFF;
        BitmapCharacter chr = (BitmapCharacter) chars[i];
        charset.put(index, chr);
    }
    return charset;
}
 
Example 4
Source File: BinaryInputCapsule.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private IntMap<Savable> intSavableMapFromKV(int[] keys, Savable[] values) {
    if(keys == null || values == null) {
        return null;
    }

    IntMap<Savable> map = new IntMap<Savable>(keys.length);
    for (int x = 0; x < keys.length; x++)
        map.put(keys[x], values[x]);

    return map;
}
 
Example 5
Source File: BinaryInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private IntMap<Savable> intSavableMapFromKV(int[] keys, Savable[] values) {
    if(keys == null || values == null) {
        return null;
    }

    IntMap<Savable> map = new IntMap<Savable>(keys.length);
    for (int x = 0; x < keys.length; x++)
        map.put(keys[x], values[x]);

    return map;
}
 
Example 6
Source File: BitmapCharacterSet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private IntMap<BitmapCharacter> readCharset(InputCapsule ic, int style) throws IOException {
    IntMap<BitmapCharacter> charset = new IntMap<BitmapCharacter>();
    short[] indexes = ic.readShortArray("indexes"+style, null);
    Savable[] chars = ic.readSavableArray("chars"+style, null);

    for (int i = 0; i < indexes.length; i++){
        int index = indexes[i] & 0xFFFF;
        BitmapCharacter chr = (BitmapCharacter) chars[i];
        charset.put(index, chr);
    }
    return charset;
}
 
Example 7
Source File: FbxMesh.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected IntMap<Mesh> toJmeObject() {
    // Load clusters from SkinDeformer
    if (skinDeformer != null) {
        for (FbxCluster cluster : skinDeformer.getJmeObject()) {
            applyCluster(cluster);
        }
    }
    
    IrMesh irMesh = toIRMesh();
    
    // Trim bone weights to 4 weights per vertex.
    IrUtils.trimBoneWeights(irMesh);
    
    // Convert tangents / binormals to tangents with parity.
    IrUtils.toTangentsWithParity(irMesh);
    
    // Triangulate quads.
    IrUtils.triangulate(irMesh);
    
    // Split meshes by material indices.
    IntMap<IrMesh> irMeshes = IrUtils.splitByMaterial(irMesh);
    
    // Create a jME3 Mesh for each material index.
    IntMap<Mesh> jmeMeshes = new IntMap<Mesh>();
    for (IntMap.Entry<IrMesh> irMeshEntry : irMeshes) {
        Mesh jmeMesh = IrUtils.convertIrMeshToJmeMesh(irMeshEntry.getValue());
        jmeMeshes.put(irMeshEntry.getKey(), jmeMesh);
    }
   
    if (jmeMeshes.size() == 0) {
        // When will this actually happen? Not sure.
        logger.log(Level.WARNING, "Empty FBX mesh found (unusual).");
    }
    
    // IMPORTANT: If we have a -1 entry, those are triangles
    // with no material indices. 
    // It makes sense only if the mesh uses a single material!
    if (jmeMeshes.containsKey(-1) && jmeMeshes.size() > 1) {
        logger.log(Level.WARNING, "Mesh has polygons with no material "
                                + "indices (unusual) - they will use material index 0.");
    }
    
    return jmeMeshes;
}