Java Code Examples for com.jme3.scene.Mesh#Mode

The following examples show how to use com.jme3.scene.Mesh#Mode . 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: GLRenderer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/*********************************************************************\
 |* Render Calls                                                      *|
 \*********************************************************************/
public int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return GL.GL_POINTS;
        case Lines:
            return GL.GL_LINES;
        case LineLoop:
            return GL.GL_LINE_LOOP;
        case LineStrip:
            return GL.GL_LINE_STRIP;
        case Triangles:
            return GL.GL_TRIANGLES;
        case TriangleFan:
            return GL.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GL.GL_TRIANGLE_STRIP;
        case Patch:
            return GL4.GL_PATCHES;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 2
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return gl.GL_POINTS;
        case Lines:
            return gl.GL_LINES;
        case LineLoop:
            return gl.GL_LINE_LOOP;
        case LineStrip:
            return gl.GL_LINE_STRIP;
        case Triangles:
            return gl.GL_TRIANGLES;
        case TriangleFan:
            return gl.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return gl.GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 3
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/*********************************************************************\
|* Render Calls                                                      *|
\*********************************************************************/
public int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return GLES20.GL_POINTS;
        case Lines:
            return GLES20.GL_LINES;
        case LineLoop:
            return GLES20.GL_LINE_LOOP;
        case LineStrip:
            return GLES20.GL_LINE_STRIP;
        case Triangles:
            return GLES20.GL_TRIANGLES;
        case TriangleFan:
            return GLES20.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GLES20.GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 4
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return GL.GL_POINTS;
        case Lines:
            return GL.GL_LINES;
        case LineLoop:
            return GL.GL_LINE_LOOP;
        case LineStrip:
            return GL.GL_LINE_STRIP;
        case Triangles:
            return GL.GL_TRIANGLES;
        case TriangleFan:
            return GL.GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GL.GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 5
Source File: LwjglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/*********************************************************************\
|* Render Calls                                                      *|
\*********************************************************************/
public int convertElementMode(Mesh.Mode mode) {
    switch (mode) {
        case Points:
            return GL_POINTS;
        case Lines:
            return GL_LINES;
        case LineLoop:
            return GL_LINE_LOOP;
        case LineStrip:
            return GL_LINE_STRIP;
        case Triangles:
            return GL_TRIANGLES;
        case TriangleFan:
            return GL_TRIANGLE_FAN;
        case TriangleStrip:
            return GL_TRIANGLE_STRIP;
        default:
            throw new UnsupportedOperationException("Unrecognized mesh mode: " + mode);
    }
}
 
Example 6
Source File: GLRenderer.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void drawTriangleArray(Mesh.Mode mode, int count, int vertCount) {
    boolean useInstancing = count > 1 && caps.contains(Caps.MeshInstancing);
    if (useInstancing) {
        glext.glDrawArraysInstancedARB(convertElementMode(mode), 0,
                vertCount, count);
    } else {
        gl.glDrawArrays(convertElementMode(mode), 0, vertCount);
    }
}
 
Example 7
Source File: JoglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) {
        Mesh.Mode mode = mesh.getMode();

        Buffer indexData = indexBuf.getData();
        indexData.clear();
        if (mesh.getMode() == Mode.Hybrid) {
            int[] modeStart = mesh.getModeStart();
            int[] elementLengths = mesh.getElementLengths();

            int elMode = convertElementMode(Mode.Triangles);
            int fmt = convertVertexFormat(indexBuf.getFormat());
//            int elSize = indexBuf.getFormat().getComponentSize();
//            int listStart = modeStart[0];
            int stripStart = modeStart[1];
            int fanStart = modeStart[2];
            int curOffset = 0;
            for (int i = 0; i < elementLengths.length; i++) {
                if (i == stripStart) {
                    elMode = convertElementMode(Mode.TriangleStrip);
                } else if (i == fanStart) {
                    elMode = convertElementMode(Mode.TriangleStrip);
                }
                int elementLength = elementLengths[i];
                indexData.position(curOffset);
                gl.glDrawElements(elMode,
                        elementLength,
                        fmt,
                        indexData);
                curOffset += elementLength;
            }
        } else {
            gl.glDrawElements(convertElementMode(mode),
                    indexData.capacity(),
                    convertVertexFormat(indexBuf.getFormat()),
                    indexData);
        }
    }
 
Example 8
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void drawTriangleArray(Mesh.Mode mode, int count, int vertCount) {
    /*        if (count > 1){
    ARBDrawInstanced.glDrawArraysInstancedARB(convertElementMode(mode), 0,
    vertCount, count);
    }else{*/
    if (verboseLogging) {
        logger.info("GLES20.glDrawArrays(" + vertCount + ")");
    }

    GLES20.glDrawArrays(convertElementMode(mode), 0, vertCount);
    /*
    }*/
}
 
Example 9
Source File: AbstractRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) {
    Mesh.Mode mode = mesh.getMode();
    Buffer indexData = indexBuf.getData();
    indexData.clear();
    if (mesh.getMode() == Mode.Hybrid) {
        int[] modeStart = mesh.getModeStart();
        int[] elementLengths = mesh.getElementLengths();

        Mode elMode = Mode.Triangles;
        // int elSize = indexBuf.getFormat().getComponentSize();
        // int listStart = modeStart[0];
        int stripStart = modeStart[1];
        int fanStart = modeStart[2];
        int curOffset = 0;
        for (int i = 0; i < elementLengths.length; i++) {
            if (i == stripStart) {
                elMode = Mode.TriangleStrip;
            }
            else if (i == fanStart) {
                elMode = Mode.TriangleStrip;
            }
            int elementLength = elementLengths[i];
            indexData.position(curOffset);
            drawElements(elMode, elementLength, indexBuf.getFormat(), indexData);
            curOffset += elementLength;
        }
    }
    else {
        drawElements(mode, indexData.capacity(), indexBuf.getFormat(), indexData);
    }
}
 
Example 10
Source File: LwjglRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void drawTriangleArray(Mesh.Mode mode, int count, int vertCount) {
    if (count > 1) {
        ARBDrawInstanced.glDrawArraysInstancedARB(convertElementMode(mode), 0,
                vertCount, count);
    } else {
        glDrawArrays(convertElementMode(mode), 0, vertCount);
    }
}
 
Example 11
Source File: MeshPropertyBuilder.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected void buildForImpl(@NotNull final Object object, @Nullable final Object parent, @NotNull final VBox container,
                            @NotNull final ModelChangeConsumer changeConsumer) {

    if (!(object instanceof Mesh)) return;

    final Mesh mesh = (Mesh) object;
    final Mesh.Mode mode = mesh.getMode();

    final int id = mesh.getId();
    final int instanceCount = mesh.getInstanceCount();
    final int vertexCount = mesh.getVertexCount();
    final int numLodLevels = mesh.getNumLodLevels();
    final int triangleCount = mesh.getTriangleCount();

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> idControl =
            new DefaultSinglePropertyControl<>(id, Messages.MODEL_PROPERTY_ID, changeConsumer);

    idControl.setSyncHandler(Mesh::getId);
    idControl.setToStringFunction(value -> Integer.toString(value));
    idControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> instanceCountControl =
            new DefaultSinglePropertyControl<>(instanceCount, Messages.MODEL_PROPERTY_INSTANCE_COUNT, changeConsumer);

    instanceCountControl.setSyncHandler(Mesh::getInstanceCount);
    instanceCountControl.setToStringFunction(value -> Integer.toString(value));
    instanceCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> vertexCountControl =
            new DefaultSinglePropertyControl<>(vertexCount, Messages.MODEL_PROPERTY_VERTEX_COUNT, changeConsumer);

    vertexCountControl.setSyncHandler(Mesh::getVertexCount);
    vertexCountControl.setToStringFunction(value -> Integer.toString(value));
    vertexCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> triangleCountControl =
            new DefaultSinglePropertyControl<>(triangleCount, Messages.MODEL_PROPERTY_TRIANGLE_COUNT, changeConsumer);

    triangleCountControl.setSyncHandler(Mesh::getTriangleCount);
    triangleCountControl.setToStringFunction(value -> Integer.toString(value));
    triangleCountControl.setEditObject(mesh);

    final DefaultSinglePropertyControl<ModelChangeConsumer, Mesh, Integer> numLodLevelsControl =
            new DefaultSinglePropertyControl<>(numLodLevels, Messages.MODEL_PROPERTY_NUM_LOD_LEVELS, changeConsumer);

    numLodLevelsControl.setSyncHandler(Mesh::getNumLodLevels);
    numLodLevelsControl.setToStringFunction(value -> Integer.toString(value));
    numLodLevelsControl.setEditObject(mesh);

    final EnumPropertyControl<ModelChangeConsumer, Mesh, Mesh.Mode> modeControl =
            new EnumPropertyControl<>(mode, Messages.MODEL_PROPERTY_MODE, changeConsumer, MODES);
    modeControl.setApplyHandler(Mesh::setMode);
    modeControl.setSyncHandler(Mesh::getMode);
    modeControl.setEditObject(mesh);

    FXUtils.addToPane(idControl, container);
    FXUtils.addToPane(instanceCountControl, container);
    FXUtils.addToPane(vertexCountControl, container);
    FXUtils.addToPane(triangleCountControl, container);
    FXUtils.addToPane(numLodLevelsControl, container);
    FXUtils.addToPane(modeControl, container);
}
 
Example 12
Source File: MeshLayer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Draws the list of triangles given in the index buffer.
 * Each triangle is composed of 3 indices to a vertex, the attribs of which
 * are supplied using <code>setVertexAttrib</code>.
 * The int variable gl_VertexID can be used to access the current
 * vertex index inside the vertex shader.
 *
 * @param count The number of instances to draw
 */
public void drawTriangleList(VertexBuffer indexBuf, Mesh.Mode mode, int count, int vertCount);
 
Example 13
Source File: AbstractRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License votes vote down vote up
protected abstract int convertElementMode(Mesh.Mode mode);