Search in sources :

Example 1 with PointStyle

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

the class CollisionRenderer method render.

public void render(Renderer renderer, CollisionHandler handler, RenderProps props, int flags) {
    RenderObject ro = myRob;
    if (ro == null) {
        // XXX paranoid
        return;
    }
    if (ro.numLines(CONSTRAINT_GRP) > 0) {
        ro.lineGroup(CONSTRAINT_GRP);
        drawLines(renderer, ro, props);
    }
    if (ro.numLines(SEGMENT_GRP) > 0) {
        ro.lineGroup(SEGMENT_GRP);
        drawLines(renderer, ro, props);
    }
    if (ro.numLines(CONTOUR_GRP) > 0) {
        int width = props.getEdgeWidth();
        if (width > 0) {
            ro.lineGroup(CONTOUR_GRP);
            float[] rgb = props.getEdgeColorF();
            if (rgb == null) {
                rgb = props.getLineColorF();
            }
            renderer.setColor(rgb, /*highlight=*/
            false);
            Shading save = renderer.getShading();
            renderer.setShading(Shading.NONE);
            renderer.drawLines(ro, LineStyle.LINE, width);
            renderer.setShading(save);
        }
    }
    if (ro.numPoints() > 0) {
        PointStyle style = props.getPointStyle();
        double width = 0;
        Shading savedShading = null;
        renderer.setPointColoring(props, /*highlight=*/
        false);
        if (style == PointStyle.POINT) {
            width = props.getPointSize();
            savedShading = renderer.setShading(Shading.NONE);
        } else {
            width = props.getPointRadius();
        }
        renderer.drawPoints(ro, style, width);
        if (style == PointStyle.POINT) {
            renderer.setShading(savedShading);
        }
    }
    if (ro.numTriangles() > 0) {
        Shading savedShadeModel = renderer.getShading();
        FaceStyle savedFaceStyle = renderer.getFaceStyle();
        renderer.setFaceColoring(props, /*highlight=*/
        false);
        renderer.setFaceStyle(props.getFaceStyle());
        renderer.setShading(props.getShading());
        renderer.drawTriangles(ro);
        renderer.setFaceStyle(savedFaceStyle);
        renderer.setShading(savedShadeModel);
    }
    RenderObject rd = myDepthRob;
    if (rd != null && rd.numTriangles() > 0) {
        Shading savedShadeModel = renderer.getShading();
        FaceStyle savedFaceStyle = renderer.getFaceStyle();
        renderer.setFaceStyle(props.getFaceStyle());
        // props.getShading());
        renderer.setShading(Shading.SMOOTH);
        renderer.setDepthOffset(2);
        renderer.drawTriangles(rd);
        renderer.setFaceStyle(savedFaceStyle);
        renderer.setShading(savedShadeModel);
    }
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) FaceStyle(maspack.render.Renderer.FaceStyle) Shading(maspack.render.Renderer.Shading) RenderObject(maspack.render.RenderObject) IntersectionPoint(maspack.collision.IntersectionPoint) PenetratingPoint(maspack.collision.PenetratingPoint)

Example 2 with PointStyle

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

the class PointList method drawPointsSelecting.

private void drawPointsSelecting(Renderer renderer, int gidx, RenderProps props) {
    PointStyle style = props.getPointStyle();
    double size = 0;
    switch(style) {
        case POINT:
            {
                size = props.getPointSize();
                break;
            }
        case CUBE:
        case SPHERE:
        default:
            {
                size = props.getPointRadius();
                break;
            }
    }
    if (size > 0) {
        int[] points = myRob.getPoints(gidx);
        for (int i = 0; i < points.length; ++i) {
            renderer.beginSelectionQuery(points[i]);
            renderer.drawPoints(myRob, gidx, i, 1, style, size);
            renderer.endSelectionQuery();
        }
    }
}
Also used : PointStyle(maspack.render.Renderer.PointStyle)

Example 3 with PointStyle

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

the class PointList method drawPoints.

private void drawPoints(Renderer renderer, int gidx, RenderProps props, boolean selected) {
    Shading savedShading = renderer.setPointShading(props);
    renderer.setPointColoring(props, selected);
    PointStyle style = props.getPointStyle();
    switch(style) {
        case POINT:
            {
                int size = props.getPointSize();
                if (size > 0) {
                    // renderer.setLightingEnabled (false);
                    // renderer.setColor (props.getPointColorArray(), selected);
                    renderer.drawPoints(myRob, gidx, PointStyle.POINT, size);
                // renderer.setLightingEnabled (true);
                }
                break;
            }
        case CUBE:
        case SPHERE:
            {
                double rad = props.getPointRadius();
                if (rad > 0) {
                    // Shading savedShading = renderer.getShadeModel();
                    // renderer.setPointLighting (props, selected);
                    renderer.drawPoints(myRob, gidx, style, rad);
                // renderer.setShadeModel(savedShading);
                }
                break;
            }
    }
    renderer.setShading(savedShading);
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) Shading(maspack.render.Renderer.Shading)

Example 4 with PointStyle

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

the class MultiPointSpring method dorender.

void dorender(Renderer renderer, RenderProps props) {
    RenderObject robj = myRenderObj;
    if (myDrawABPointsP) {
        // draw AB points
        for (int i = 0; i < numSegments(); i++) {
            Segment seg = mySegments.get(i);
            if (seg instanceof WrapSegment) {
                WrapSegment wrapSeg = (WrapSegment) seg;
                ArrayList<float[]> renderPoints = wrapSeg.myRenderABPoints;
                if (renderPoints != null) {
                    for (int k = 0; k < renderPoints.size(); k++) {
                        renderer.drawPoint(myABRenderProps, renderPoints.get(k), isSelected());
                    }
                }
            }
        }
    }
    if (robj != null) {
        double size;
        // draw the strands
        LineStyle lineStyle = props.getLineStyle();
        if (lineStyle == LineStyle.LINE) {
            size = props.getLineWidth();
        } else {
            size = props.getLineRadius();
        }
        if (getRenderColor() != null) {
            renderer.setColor(getRenderColor(), isSelected());
        } else {
            renderer.setLineColoring(props, isSelected());
        }
        renderer.drawLines(robj, lineStyle, size);
        if (myDrawKnotsP) {
            // draw the knots, if any
            PointStyle pointStyle = props.getPointStyle();
            if (pointStyle == PointStyle.POINT) {
                size = props.getPointSize();
            } else {
                size = props.getPointRadius();
            }
            renderer.setPointColoring(props, isSelected());
            robj.pointGroup(FREE_KNOTS);
            renderer.drawPoints(robj, pointStyle, size);
            robj.pointGroup(CONTACTING_KNOTS);
            if (myContactingKnotsColor != null) {
                renderer.setColor(myContactingKnotsColor);
            }
            renderer.drawPoints(robj, pointStyle, size);
        }
    }
}
Also used : PointStyle(maspack.render.Renderer.PointStyle) LineStyle(maspack.render.Renderer.LineStyle) RenderObject(maspack.render.RenderObject) LineSegment(maspack.geometry.LineSegment)

Example 5 with PointStyle

use of maspack.render.Renderer.PointStyle 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)

Aggregations

PointStyle (maspack.render.Renderer.PointStyle)7 Shading (maspack.render.Renderer.Shading)4 RenderObject (maspack.render.RenderObject)3 IntersectionPoint (maspack.collision.IntersectionPoint)1 PenetratingPoint (maspack.collision.PenetratingPoint)1 LineSegment (maspack.geometry.LineSegment)1 PointRenderProps (maspack.render.PointRenderProps)1 RenderProps (maspack.render.RenderProps)1 ColorInterpolation (maspack.render.Renderer.ColorInterpolation)1 FaceStyle (maspack.render.Renderer.FaceStyle)1 LineStyle (maspack.render.Renderer.LineStyle)1