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

The following examples show how to use com.jme3.util.IntMap#size() . 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: BinaryOutputCapsule.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void writeIntSavableMap(IntMap<? extends Savable> array)
        throws IOException {
    if (array == null) {
        write(NULL_OBJECT);
        return;
    }
    write(array.size());

    int[] keys = new int[array.size()];
    Savable[] values = new Savable[keys.length];
    int i = 0;
    for (Entry<? extends Savable> entry : array){
        keys[i] = entry.getKey();
        values[i] = entry.getValue();
        i++;
    }

    // write String array for keys
    write(keys);

    // write Savable array for values
    write(values);
}
 
Example 2
Source File: BinaryOutputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void writeIntSavableMap(IntMap<? extends Savable> array)
        throws IOException {
    if (array == null) {
        write(NULL_OBJECT);
        return;
    }
    write(array.size());

    int[] keys = new int[array.size()];
    Savable[] values = new Savable[keys.length];
    int i = 0;
    for (Entry<? extends Savable> entry : array){
        keys[i] = entry.getKey();
        values[i] = entry.getValue();
        i++;
    }

    // write String array for keys
    write(keys);

    // write Savable array for values
    write(values);
}
 
Example 3
Source File: BitmapCharacterSet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void writeCharset(OutputCapsule oc, int style, IntMap<BitmapCharacter> charset) throws IOException {
    int size = charset.size();
    short[] indexes = new short[size];
    BitmapCharacter[] chars = new BitmapCharacter[size];
    int i = 0;
    for (Entry<BitmapCharacter> chr : charset){
        indexes[i] = (short) chr.getKey();
        chars[i] = chr.getValue();
        i++;
    }

    oc.write(indexes, "indexes"+style, null);
    oc.write(chars,   "chars"+style,   null);
}
 
Example 4
Source File: BitmapCharacterSet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void writeCharset(OutputCapsule oc, int style, IntMap<BitmapCharacter> charset) throws IOException {
    int size = charset.size();
    short[] indexes = new short[size];
    BitmapCharacter[] chars = new BitmapCharacter[size];
    int i = 0;
    for (Entry<BitmapCharacter> chr : charset){
        indexes[i] = (short) chr.getKey();
        chars[i] = chr.getValue();
        i++;
    }

    oc.write(indexes, "indexes"+style, null);
    oc.write(chars,   "chars"+style,   null);
}
 
Example 5
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;
}