com.jme3.util.IntMap Java Examples

The following examples show how to use com.jme3.util.IntMap. 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: BitmapCharacterSet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void write(JmeExporter ex) throws IOException {
    OutputCapsule oc = ex.getCapsule(this);
    oc.write(lineHeight, "lineHeight", 0);
    oc.write(base, "base", 0);
    oc.write(renderedSize, "renderedSize", 0);
    oc.write(width, "width", 0);
    oc.write(height, "height", 0);
    oc.write(pageSize, "pageSize", 0);

    int[] styles = new int[characters.size()];
    int index = 0;
    for (Entry<IntMap<BitmapCharacter>> entry : characters) {
        int style = entry.getKey();
        styles[index] = style;
        index++;
        IntMap<BitmapCharacter> charset = entry.getValue();
        writeCharset(oc, style, charset);
    }
    oc.write(styles, "styles", null);
}
 
Example #2
Source File: BinaryInputCapsule.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal)
        throws IOException {
    BinaryClassField field = cObj.nameFields.get(name);
    if (field == null || !fieldData.containsKey(field.alias))
        return defVal;
    Object value = fieldData.get(field.alias);
    if (value instanceof IntIDMap) {
        // read Savable array and convert to Map values
        IntIDMap in = (IntIDMap) value;
        Savable[] values = resolveIDs(in.values);
        value = intSavableMapFromKV(in.keys, values);
        fieldData.put(field.alias, value);
    }
    return (IntMap<Savable>) value;
}
 
Example #3
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 #4
Source File: BitmapCharacterSet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Merge two fonts.
 * If two font have the same style, merge will fail.
 * @param styleSet Style must be assigned to this.
 * author: Yonghoon
 */
public void merge(BitmapCharacterSet styleSet) {
    if (this.renderedSize != styleSet.renderedSize) {
        throw new RuntimeException("Only support same font size");
    }
    for (Entry<IntMap<BitmapCharacter>> entry : styleSet.characters) {
        int style = entry.getKey();
        if (style == 0) {
            throw new RuntimeException("Style must be set first. use setStyle(int)");
        }
        IntMap<BitmapCharacter> charset = entry.getValue();
        this.lineHeight = Math.max(this.lineHeight, styleSet.lineHeight);
        IntMap<BitmapCharacter> old = this.characters.put(style, charset);
        if (old != null) {
            throw new RuntimeException("Can't override old style");
        }
        
        for (Entry<BitmapCharacter> charEntry : charset) {
            BitmapCharacter ch = charEntry.getValue();
            ch.setPage(ch.getPage() + this.pageSize);
        }
    }
    this.pageSize += styleSet.pageSize;
}
 
Example #5
Source File: BinaryInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal)
        throws IOException {
    BinaryClassField field = cObj.nameFields.get(name);
    if (field == null || !fieldData.containsKey(field.alias))
        return defVal;
    Object value = fieldData.get(field.alias);
    if (value instanceof IntIDMap) {
        // read Savable array and convert to Map values
        IntIDMap in = (IntIDMap) value;
        Savable[] values = resolveIDs(in.values);
        value = intSavableMapFromKV(in.keys, values);
        fieldData.put(field.alias, value);
    }
    return (IntMap<Savable>) value;
}
 
Example #6
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 #7
Source File: BitmapCharacterSet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Merge two fonts.
 * If two font have the same style, merge will fail.
 * @param styleSet Style must be assigned to this.
 * @author Yonghoon
 */
public void merge(BitmapCharacterSet styleSet) {
    if (this.renderedSize != styleSet.renderedSize) {
        throw new RuntimeException("Only support same font size");
    }
    for (Entry<IntMap<BitmapCharacter>> entry : styleSet.characters) {
        int style = entry.getKey();
        if (style == 0) {
            throw new RuntimeException("Style must be set first. use setStyle(int)");
        }
        IntMap<BitmapCharacter> charset = entry.getValue();
        this.lineHeight = Math.max(this.lineHeight, styleSet.lineHeight);
        IntMap<BitmapCharacter> old = this.characters.put(style, charset);
        if (old != null) {
            throw new RuntimeException("Can't override old style");
        }
        
        for (Entry<BitmapCharacter> charEntry : charset) {
            BitmapCharacter ch = charEntry.getValue();
            ch.setPage(ch.getPage() + this.pageSize);
        }
    }
    this.pageSize += styleSet.pageSize;
}
 
Example #8
Source File: BitmapCharacterSet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void write(JmeExporter ex) throws IOException {
    OutputCapsule oc = ex.getCapsule(this);
    oc.write(lineHeight, "lineHeight", 0);
    oc.write(base, "base", 0);
    oc.write(renderedSize, "renderedSize", 0);
    oc.write(width, "width", 0);
    oc.write(height, "height", 0);
    oc.write(pageSize, "pageSize", 0);

    int[] styles = new int[characters.size()];
    int index = 0;
    for (Entry<IntMap<BitmapCharacter>> entry : characters) {
        int style = entry.getKey();
        styles[index] = style;
        index++;
        IntMap<BitmapCharacter> charset = entry.getValue();
        writeCharset(oc, style, charset);
    }
    oc.write(styles, "styles", null);
}
 
Example #9
Source File: ModelConverter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void optimize(Mesh mesh, boolean toFixed){
        // update any data that need updating
        mesh.updateBound();
        mesh.updateCounts();

        // set all buffers into STATIC_DRAW mode
        mesh.setStatic();

        if (mesh.getBuffer(Type.Index) != null){
            // compress index buffer from UShort to UByte (if possible)
            FloatToFixed.compressIndexBuffer(mesh);

            // generate triangle strips stitched with degenerate tris
            generateStrips(mesh, false, false, 16, 0);
        }

        IntMap<VertexBuffer> bufs = mesh.getBuffers();
        for (Entry<VertexBuffer> entry : bufs){
            VertexBuffer vb = entry.getValue();
            if (vb == null || vb.getBufferType() == Type.Index)
                continue;

             if (vb.getFormat() == Format.Float){
                if (vb.getBufferType() == Type.Color){
                    // convert the color buffer to UByte
                    vb = FloatToFixed.convertToUByte(vb);
                    vb.setNormalized(true);
                }else if (toFixed){
                    // convert normals, positions, and texcoords
                    // to fixed-point (16.16)
                    vb = FloatToFixed.convertToFixed(vb);
//                    vb = FloatToFixed.convertToFloat(vb);
                }
                mesh.clearBuffer(vb.getBufferType());
                mesh.setBuffer(vb);
            }
        }
        mesh.setInterleaved();
    }
 
Example #10
Source File: BitmapCharacterSet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setStyle(int style) {
    if (characters.size() > 1) {
        throw new RuntimeException("Applicable only for single style font");
    }
    Entry<IntMap<BitmapCharacter>> entry = characters.iterator().next();
    IntMap<BitmapCharacter> charset = entry.getValue();
    characters.remove(entry.getKey());
    characters.put(style, charset);
}
 
Example #11
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void renderMeshDefault(Mesh mesh, int lod, int count) {
    VertexBuffer indices = null;
    VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
    IntMap<VertexBuffer> buffers = mesh.getBuffers();
    if (mesh.getNumLodLevels() > 0) {
        indices = mesh.getLodLevel(lod);
    } else {
        indices = buffers.get(Type.Index.ordinal());
    }
    for (Entry<VertexBuffer> entry : buffers) {
        VertexBuffer vb = entry.getValue();

        if (vb.getBufferType() == Type.InterleavedData
                || vb.getUsage() == Usage.CpuOnly) // ignore cpu-only buffers
        {
            continue;
        }

        if (vb.getBufferType() == Type.Index) {
            indices = vb;
        } else {
            if (vb.getStride() == 0) {
                // not interleaved
                setVertexAttrib(vb);
            } else {
                // interleaved
                setVertexAttrib(vb, interleavedData);
            }
        }
    }

    if (indices != null) {
        drawTriangleList(indices, mesh, count);
    } else {
        gl.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
    }
    clearVertexAttribs();
    clearTextureUnits();
}
 
Example #12
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void renderMeshVBO(Mesh mesh, int lod, int count) {
    VertexBuffer indices = null;
    VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
    if (interleavedData != null && interleavedData.isUpdateNeeded()) {
        updateBufferData(interleavedData);
    }
    IntMap<VertexBuffer> buffers = mesh.getBuffers();
    if (mesh.getNumLodLevels() > 0) {
        indices = mesh.getLodLevel(lod);
    } else {
        indices = buffers.get(Type.Index.ordinal());
    }
    for (Entry<VertexBuffer> entry : buffers) {
        VertexBuffer vb = entry.getValue();

        if (vb.getBufferType() == Type.InterleavedData
                || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
                || vb.getBufferType() == Type.Index) {
            continue;
        }

        if (vb.getStride() == 0) {
            // not interleaved
            setVertexAttribVBO(vb, null);
        } else {
            // interleaved
            setVertexAttribVBO(vb, interleavedData);
        }
    }

    if (indices != null) {
        drawTriangleListVBO(indices, mesh, count);
    } else {
        gl.glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
    }
    clearVertexAttribs();
    clearTextureUnits();
}
 
Example #13
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void renderMesh(Mesh mesh, int lod, int count) {
	if (mesh.getVertexCount() == 0)
        return;
    if (context.pointSize != mesh.getPointSize()) {
        gl.glPointSize(mesh.getPointSize());
        context.pointSize = mesh.getPointSize();
    }
    if (context.lineWidth != mesh.getLineWidth()) {
        gl.glLineWidth(mesh.getLineWidth());
        context.lineWidth = mesh.getLineWidth();
    }

    checkTexturingUsed();

    if (vbo) {
        renderMeshVBO(mesh, lod, count);
    } else {
        boolean dynamic = false;
        if (mesh.getNumLodLevels() == 0) {
            IntMap<VertexBuffer> bufs = mesh.getBuffers();
            for (Entry<VertexBuffer> entry : bufs) {
                if (entry.getValue().getUsage() != VertexBuffer.Usage.Static) {
                    dynamic = true;
                    break;
                }
            }
        } else {
            dynamic = true;
        }

        if (!dynamic) {
            // dealing with a static object, generate display list
            renderMeshDisplayList(mesh);
        } else {
            renderMeshDefault(mesh, lod, count);
        }
    }
}
 
Example #14
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 #15
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void renderMesh(Mesh mesh, int lod, int count) {
    GL gl = GLContext.getCurrentGL();
    if (context.pointSize != mesh.getPointSize()) {
        gl.getGL2().glPointSize(mesh.getPointSize());
        context.pointSize = mesh.getPointSize();
    }
    if (context.lineWidth != mesh.getLineWidth()) {
        gl.glLineWidth(mesh.getLineWidth());
        context.lineWidth = mesh.getLineWidth();
    }

    checkTexturingUsed();

    if (vbo) {
        renderMeshVBO(mesh, lod, count);
    }
    else {
        boolean dynamic = false;
        if (mesh.getNumLodLevels() == 0) {
            IntMap<VertexBuffer> bufs = mesh.getBuffers();
            for (Entry<VertexBuffer> entry : bufs) {
                if (entry.getValue().getUsage() != VertexBuffer.Usage.Static) {
                    dynamic = true;
                    break;
                }
            }
        }
        else {
            dynamic = true;
        }

        if (!dynamic) {
            // dealing with a static object, generate display list
            renderMeshDisplayList(mesh);
        }
        else {
            renderMeshDefault(mesh, lod, count);
        }
    }
}
 
Example #16
Source File: LwjglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void updateVertexArray(Mesh mesh) {
    int id = mesh.getId();
    if (id == -1) {
        IntBuffer temp = intBuf1;
        ARBVertexArrayObject.glGenVertexArrays(temp);
        id = temp.get(0);
        mesh.setId(id);
    }

    if (context.boundVertexArray != id) {
        ARBVertexArrayObject.glBindVertexArray(id);
        context.boundVertexArray = id;
    }

    VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
    if (interleavedData != null && interleavedData.isUpdateNeeded()) {
        updateBufferData(interleavedData);
    }

    IntMap<VertexBuffer> buffers = mesh.getBuffers();
    for (Entry<VertexBuffer> entry : buffers) {
        VertexBuffer vb = entry.getValue();

        if (vb.getBufferType() == Type.InterleavedData
                || vb.getUsage() == Usage.CpuOnly // ignore cpu-only buffers
                || vb.getBufferType() == Type.Index) {
            continue;
        }

        if (vb.getStride() == 0) {
            // not interleaved
            setVertexAttrib(vb);
        } else {
            // interleaved
            setVertexAttrib(vb, interleavedData);
        }
    }
}
 
Example #17
Source File: Mesh.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException {
        InputCapsule in = im.getCapsule(this);
        meshBound = (BoundingVolume) in.readSavable("modelBound", null);
        vertCount = in.readInt("vertCount", -1);
        elementCount = in.readInt("elementCount", -1);
        maxNumWeights = in.readInt("max_num_weights", -1);
        mode = in.readEnum("mode", Mode.class, Mode.Triangles);
        elementLengths = in.readIntArray("elementLengths", null);
        modeStart = in.readIntArray("modeStart", null);
        collisionTree = (BIHTree) in.readSavable("collisionTree", null);
        elementLengths = in.readIntArray("elementLengths", null);
        modeStart = in.readIntArray("modeStart", null);
        pointSize = in.readFloat("pointSize", 1f);

//        in.readStringSavableMap("buffers", null);
        buffers = (IntMap<VertexBuffer>) in.readIntSavableMap("buffers", null);
        for (Entry<VertexBuffer> entry : buffers){
            buffersList.add(entry.getValue());
        }
        
        //creating hw animation buffers empty so that they are put in the cache
        if(isAnimated()){
            VertexBuffer hwBoneIndex = new VertexBuffer(Type.HWBoneIndex);
            hwBoneIndex.setUsage(Usage.CpuOnly);
            setBuffer(hwBoneIndex);
            VertexBuffer hwBoneWeight = new VertexBuffer(Type.HWBoneWeight);
            hwBoneWeight.setUsage(Usage.CpuOnly);
            setBuffer(hwBoneWeight);
        }
        
        Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
        if (lodLevelsSavable != null) {
            lodLevels = new VertexBuffer[lodLevelsSavable.length];
            System.arraycopy( lodLevelsSavable, 0, lodLevels, 0, lodLevels.length);
        }
    }
 
Example #18
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 #19
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 #20
Source File: CachedOggStream.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public LogicalOggStream reloadLogicalOggStream() {
    logicalStreams.clear();
    LogicalOggStreamImpl los = new LogicalOggStreamImpl(this, serialno);
    logicalStreams.put(serialno, los);

    for (IntMap.Entry<OggPage> entry : oggPages) {
        los.addPageNumberMapping(entry.getKey());
        los.addGranulePosition(entry.getValue().getAbsoluteGranulePosition());
    }

    return los;
}
 
Example #21
Source File: BinaryOutputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void writeIntSavableMap(IntMap<? extends Savable> map,
        String name, IntMap<? extends Savable> defVal)
        throws IOException {
    if (map == defVal)
        return;
    writeAlias(name, BinaryClassField.INT_SAVABLE_MAP);
    writeIntSavableMap(map);
}
 
Example #22
Source File: Shader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
     * Create an empty shader.
     */
    public Shader(String language){
        super(Shader.class);
        this.language = language;
        shaderList = new ArrayList<ShaderSource>();
//        uniforms = new HashMap<String, Uniform>();
        uniforms = new ListMap<String, Uniform>();
        attribs = new IntMap<Attribute>();
    }
 
Example #23
Source File: Shader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void read(JmeImporter im) throws IOException{
    InputCapsule ic = im.getCapsule(this);
    language = ic.readString("language", null);
    shaderList = ic.readSavableArrayList("shaderList", null);
    attribs = (IntMap<Attribute>) ic.readIntSavableMap("attribs", null);

    HashMap<String, Uniform> uniMap = (HashMap<String, Uniform>) ic.readStringSavableMap("uniforms", null);
    uniforms = new ListMap<String, Uniform>(uniMap);
}
 
Example #24
Source File: Mesh.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a deep clone of this mesh. 
 * The {@link VertexBuffer vertex buffers} and the data inside them
 * is cloned.
 * 
 * @return a deep clone of this mesh.
 */
public Mesh deepClone(){
    try{
        Mesh clone = (Mesh) super.clone();
        clone.meshBound = meshBound != null ? meshBound.clone() : null;

        // TODO: Collision tree cloning
        //clone.collisionTree = collisionTree != null ? collisionTree : null;
        clone.collisionTree = null; // it will get re-generated in any case

        clone.buffers = new IntMap<VertexBuffer>();
        clone.buffersList = new SafeArrayList<VertexBuffer>(VertexBuffer.class);
        for (VertexBuffer vb : buffersList.getArray()){
            VertexBuffer bufClone = vb.clone();
            clone.buffers.put(vb.getBufferType().ordinal(), bufClone);
            clone.buffersList.add(bufClone);
        }
        
        clone.vertexArrayID = -1;
        clone.vertCount = -1;
        clone.elementCount = -1;
        
        // although this could change
        // if the bone weight/index buffers are modified
        clone.maxNumWeights = maxNumWeights; 
        
        clone.elementLengths = elementLengths != null ? elementLengths.clone() : null;
        clone.modeStart = modeStart != null ? modeStart.clone() : null;
        return clone;
    }catch (CloneNotSupportedException ex){
        throw new AssertionError();
    }
}
 
Example #25
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 #26
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 #27
Source File: TestAndroidSensors.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    if (!initialCalibrationComplete) {
        // Calibrate the axis (set new zero position) if the axis
        // is a sensor joystick axis
        for (IntMap.Entry<Joystick> entry : joystickMap) {
            for (JoystickAxis axis : entry.getValue().getAxes()) {
                if (axis instanceof SensorJoystickAxis) {
                    logger.log(Level.INFO, "Calibrating Axis: {0}", axis.toString());
                    ((SensorJoystickAxis) axis).calibrateCenter();
                }
            }
        }
        initialCalibrationComplete = true;
    }

    if (enableGeometryRotation) {
        rotationQuat.fromAngles(anglesCurrent);
        rotationQuat.normalizeLocal();

        if (useAbsolute) {
            geomZero.setLocalRotation(rotationQuat);
        } else {
            geomZero.rotate(rotationQuat);
        }

        anglesCurrent[0] = anglesCurrent[1] = anglesCurrent[2] = 0f;
    }
}
 
Example #28
Source File: Shader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a new shader, initialize() must be called
 * after this constructor for the shader to be usable.
 */
public Shader(){
    super();
    shaderSourceList = new ArrayList<>();
    uniforms = new ListMap<>();
    bufferBlocks = new ListMap<>();
    attribs = new IntMap<>();
    boundUniforms = new ArrayList<>();
}
 
Example #29
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 #30
Source File: GLTracer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates a tracer implementation that wraps OpenGL ES 2.
 *
 * @param glInterface OGL object to wrap
 * @param glInterfaceClasses The interface(s) to implement
 * @return A tracer that implements the given interface
 */
public static Object createGlesTracer(Object glInterface, Class<?>... glInterfaceClasses) {
    IntMap<String> constMap = generateConstantMap(GL.class, GL2.class, GL3.class, GLFbo.class, GLExt.class);
    return Proxy.newProxyInstance(
            glInterface.getClass().getClassLoader(),
            glInterfaceClasses,
            new GLTracer(glInterface, constMap));
}