Search in sources :

Example 6 with ColorInterpolation

use of maspack.render.Renderer.ColorInterpolation in project artisynth_core by artisynth.

the class PointMeshRenderer method render.

@Override
public void render(Renderer renderer, RenderProps props, int flags) {
    PointMesh mesh = getMesh();
    RenderObject rob = getRenderObject();
    if (mesh.numVertices() == 0) {
        return;
    }
    boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    float savedLineWidth = renderer.getLineWidth();
    Shading savedShadeModel = renderer.getShading();
    // if (renderer.isSelecting()) {
    // shading = Shading.NONE;
    // }
    PointStyle pointStyle = props.getPointStyle();
    if (pointStyle == PointStyle.POINT && !mesh.hasNormals()) {
        renderer.setShading(Shading.NONE);
    } else {
        renderer.setShading(props.getShading());
    }
    ColorInterpolation savedColorInterp = null;
    if (usingHSV(mesh)) {
        savedColorInterp = renderer.setColorInterpolation(ColorInterpolation.HSV);
    }
    renderer.setPointColoring(props, highlight);
    switch(pointStyle) {
        case POINT:
            {
                int size = props.getPointSize();
                if (size > 0) {
                    renderer.drawPoints(rob, PointStyle.POINT, size);
                }
                break;
            }
        case CUBE:
        case SPHERE:
            {
                double rad = props.getPointRadius();
                if (rad > 0) {
                    renderer.drawPoints(rob, pointStyle, rad);
                }
                break;
            }
    }
    if (savedColorInterp != null) {
        renderer.setColorInterpolation(savedColorInterp);
    }
    if (mesh.getNormalRenderLen() > 0) {
        renderer.setLineWidth(props.getLineWidth());
        renderer.setLineColoring(props, highlight);
        renderer.drawLines(rob);
    }
    renderer.setLineWidth(savedLineWidth);
    renderer.setShading(savedShadeModel);
    renderer.popModelMatrix();
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) Shading(maspack.render.Renderer.Shading) ColorInterpolation(maspack.render.Renderer.ColorInterpolation) RenderObject(maspack.render.RenderObject)

Example 7 with ColorInterpolation

use of maspack.render.Renderer.ColorInterpolation in project artisynth_core by artisynth.

the class PolylineMeshRenderer method render.

@Override
public void render(Renderer renderer, RenderProps props, int flags) {
    PolylineMesh mesh = getMesh();
    RenderObject rob = getRenderObject();
    if (mesh.numVertices() == 0) {
        return;
    }
    boolean highlight = ((flags & Renderer.HIGHLIGHT) != 0);
    renderer.pushModelMatrix();
    if (mesh.isRenderBuffered()) {
        renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
    } else {
        renderer.mulModelMatrix(mesh.XMeshToWorld);
    }
    float savedLineWidth = renderer.getLineWidth();
    Shading savedShadeModel = renderer.getShading();
    // Shading shading = props.getShading();
    // if (renderer.isSelecting()) {
    // shading = Shading.NONE;
    // }
    LineStyle lineStyle = props.getLineStyle();
    Shading savedShading = renderer.getShading();
    if (lineStyle == LineStyle.LINE && !mesh.hasNormals()) {
        renderer.setShading(Shading.NONE);
    } else {
        renderer.setShading(props.getShading());
    }
    ColorInterpolation savedColorInterp = null;
    if (usingHSV(mesh)) {
        savedColorInterp = renderer.setColorInterpolation(ColorInterpolation.HSV);
    }
    renderer.setLineColoring(props, highlight);
    switch(lineStyle) {
        case LINE:
            {
                int width = props.getLineWidth();
                if (width > 0) {
                    renderer.drawLines(rob, LineStyle.LINE, width);
                }
                break;
            }
        case SPINDLE:
        case SOLID_ARROW:
        case CYLINDER:
            {
                double rad = props.getLineRadius();
                if (rad > 0) {
                    renderer.drawLines(rob, props.getLineStyle(), rad);
                }
                break;
            }
    }
    if (savedColorInterp != null) {
        renderer.setColorInterpolation(savedColorInterp);
    }
    renderer.setShading(savedShading);
    renderer.setLineWidth(savedLineWidth);
    renderer.setShading(savedShadeModel);
    renderer.popModelMatrix();
}
Also used : LineStyle(maspack.render.Renderer.LineStyle) Shading(maspack.render.Renderer.Shading) ColorInterpolation(maspack.render.Renderer.ColorInterpolation) RenderObject(maspack.render.RenderObject)

Aggregations

ColorInterpolation (maspack.render.Renderer.ColorInterpolation)7 Shading (maspack.render.Renderer.Shading)4 RenderingMode (maspack.render.GL.GLProgramInfo.RenderingMode)2 RenderObject (maspack.render.RenderObject)2 ColorMixing (maspack.render.Renderer.ColorMixing)2 BumpMapProps (maspack.render.BumpMapProps)1 ColorMapProps (maspack.render.ColorMapProps)1 NormalMapProps (maspack.render.NormalMapProps)1 Renderer (maspack.render.Renderer)1 FaceStyle (maspack.render.Renderer.FaceStyle)1 LineStyle (maspack.render.Renderer.LineStyle)1 PointStyle (maspack.render.Renderer.PointStyle)1