Search in sources :

Example 1 with FaceStyle

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

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

the class TextComponent3d method render.

@Override
public void render(Renderer renderer, int flags) {
    if (!isSelectable() && renderer.isSelecting()) {
        return;
    }
    // text orientation computation
    Rectangle2D box = renderer.getTextBounds(myFont, myText, myTextSize);
    double w = box.getWidth();
    double t = box.getY() + box.getHeight();
    double vc = box.getY() + box.getHeight() / 2;
    rEye.invert(renderer.getViewMatrix().R);
    if (followEye) {
        rEye.getColumn(0, xdir);
    } else {
        xdir[0] = 1;
        xdir[1] = 0;
        xdir[2] = 0;
    }
    renderPos.setZero();
    switch(hAlignment) {
        case CENTRE:
            renderPos.add(-xdir[0] * w / 2, -xdir[1] * w / 2, -xdir[2] * w / 2);
            break;
        case RIGHT:
            renderPos.add(-xdir[0] * w, -xdir[1] * w, -xdir[2] * w);
            break;
        default:
            break;
    }
    if (followEye) {
        rEye.getColumn(1, xdir);
    } else {
        xdir[0] = 0;
        xdir[1] = 1;
        xdir[2] = 0;
    }
    switch(vAlignment) {
        case CENTRE:
            renderPos.add(-xdir[0] * vc, -xdir[1] * vc, -xdir[2] * vc);
            break;
        case TOP:
            renderPos.add(-xdir[0] * t, -xdir[1] * t, -xdir[2] * t);
            break;
        default:
    }
    // account for non-zero orientation
    myTransform.setRotation(myOrientation);
    if (followEye) {
        myTransform.R.mul(rEye, myTransform.R);
        renderPos.inverseTransform(rEye);
    }
    renderPos.transform(myTransform.R);
    renderPos.add(myPos);
    myTransform.p.set(renderPos);
    renderer.pushModelMatrix();
    renderer.mulModelMatrix(myTransform);
    RenderProps rprops = getRenderProps();
    // Shading savedShading = renderer.setShading (rprops.getShading ());
    Shading savedShading = renderer.setShading(Shading.NONE);
    renderer.setFaceColoring(rprops, isSelected());
    FaceStyle savedFaceStyle = renderer.setFaceStyle(rprops.getFaceStyle());
    final float[] ZERO = { 0, 0, 0 };
    renderer.drawText(myFont, myText, ZERO, myTextSize);
    renderer.setFaceStyle(savedFaceStyle);
    renderer.setShading(savedShading);
    renderer.popModelMatrix();
}
Also used : FaceStyle(maspack.render.Renderer.FaceStyle) Rectangle2D(java.awt.geom.Rectangle2D) RenderProps(maspack.render.RenderProps) Shading(maspack.render.Renderer.Shading)

Example 3 with FaceStyle

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

the class DicomPlaneViewer method render.

@Override
public synchronized void render(Renderer renderer, int flags) {
    RenderProps rprops = getRenderProps();
    renderer.pushModelMatrix();
    // adjust for widths and location
    renderer.mulModelMatrix(location);
    AffineTransform3d scaling = new AffineTransform3d();
    scaling.applyScaling(widths.x, widths.y, 1);
    renderer.mulModelMatrix(scaling);
    ColorMapProps oldColorMap = renderer.setColorMap(rprops.getColorMap());
    FaceStyle oldFaceStyle = renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
    Shading oldShading = renderer.setShading(rprops.getShading());
    if (!renderer.isSelecting()) {
        renderer.setFaceColoring(rprops, isSelected());
    }
    renderer.drawTriangles(robj, 0);
    renderer.setShading(oldShading);
    renderer.setFaceStyle(oldFaceStyle);
    renderer.setColorMap(oldColorMap);
    renderer.popModelMatrix();
}
Also used : FaceStyle(maspack.render.Renderer.FaceStyle) ColorMapProps(maspack.render.ColorMapProps) LineRenderProps(maspack.render.LineRenderProps) RenderProps(maspack.render.RenderProps) Shading(maspack.render.Renderer.Shading) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 4 with FaceStyle

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

the class DicomViewer method render.

@Override
public synchronized void render(Renderer renderer, int flags) {
    RenderProps rprops = getRenderProps();
    renderer.pushModelMatrix();
    renderer.setModelMatrix(myRenderTransform);
    if (drawBox) {
        // draw box
        Shading savedShading = renderer.setShading(Shading.NONE);
        renderer.setLineColoring(rprops, isSelected());
        renderer.drawLines(robj, 0);
        renderer.setShading(savedShading);
    }
    ColorMapProps oldColorMap = renderer.setColorMap(rprops.getColorMap());
    FaceStyle oldFaceStyle = renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
    Shading oldShading = renderer.setShading(rprops.getShading());
    if (!renderer.isSelecting()) {
        renderer.setFaceColoring(rprops, isSelected());
    }
    for (int i = 0; i < 3; i++) {
        if (drawSlice[i]) {
            renderer.drawTriangles(robj, i);
        }
    }
    renderer.setShading(oldShading);
    renderer.setFaceStyle(oldFaceStyle);
    renderer.setColorMap(oldColorMap);
    renderer.popModelMatrix();
}
Also used : FaceStyle(maspack.render.Renderer.FaceStyle) ColorMapProps(maspack.render.ColorMapProps) LineRenderProps(maspack.render.LineRenderProps) RenderProps(maspack.render.RenderProps) Shading(maspack.render.Renderer.Shading)

Aggregations

FaceStyle (maspack.render.Renderer.FaceStyle)4 Shading (maspack.render.Renderer.Shading)4 RenderProps (maspack.render.RenderProps)3 ColorMapProps (maspack.render.ColorMapProps)2 LineRenderProps (maspack.render.LineRenderProps)2 Rectangle2D (java.awt.geom.Rectangle2D)1 IntersectionPoint (maspack.collision.IntersectionPoint)1 PenetratingPoint (maspack.collision.PenetratingPoint)1 AffineTransform3d (maspack.matrix.AffineTransform3d)1 RenderObject (maspack.render.RenderObject)1 PointStyle (maspack.render.Renderer.PointStyle)1