Search in sources :

Example 6 with Shading

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

the class AuxMaterialElementDesc method render.

public void render(Renderer renderer, RenderProps props, int flags) {
    double widgetSize = 0;
    double rad = 0;
    FractionRenderType renderType = AuxMaterialBundle.DEFAULT_FRACTION_RENDER_TYPE;
    ModelComponent gparent = getGrandParent();
    if (gparent instanceof AuxMaterialBundle) {
        AuxMaterialBundle bundle = (AuxMaterialBundle) gparent;
        widgetSize = bundle.getElementWidgetSize();
        rad = bundle.getFractionRenderRadius();
        renderType = bundle.getFractionRenderType();
    }
    if (widgetSize != 0 || rad > 0) {
        Shading savedShading = renderer.setPropsShading(props);
        renderer.setFaceColoring(props, myWidgetColor, isSelected());
        if (widgetSize != 0) {
            myElement.renderWidget(renderer, widgetSize, props);
        }
        if (rad > 0) {
            renderFraction(renderer, props, rad, renderType);
        }
        renderer.setShading(savedShading);
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) Shading(maspack.render.Renderer.Shading) FractionRenderType(artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)

Example 7 with Shading

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

the class FemElement3dList method drawEdges.

protected void drawEdges(Renderer renderer, RenderObject r, FeatureIndexArray lines, RenderProps props, boolean selected) {
    if (lines.numFeatures() > 0) {
        int width = props.getLineWidth();
        if (width > 0) {
            float savedWidth = renderer.getLineWidth();
            if (renderer.isSelecting()) {
                // feature-by-feature
                for (int i = 0; i < lines.numFeatures(); ++i) {
                    renderer.beginSelectionQuery(lines.getFeature(i));
                    renderer.drawVertices(r, lines.getVertices(), lines.getFeatureOffset(i), lines.getFeatureLength(i), DrawMode.LINES);
                    renderer.endSelectionQuery();
                }
            } else {
                Shading savedShading = renderer.setShading(Shading.NONE);
                renderer.setLineColoring(props, selected);
                renderer.setLineWidth(width);
                renderer.drawVertices(r, lines.getVertices(), DrawMode.LINES);
                renderer.setShading(savedShading);
            }
            renderer.setLineWidth(savedWidth);
        }
    }
}
Also used : Shading(maspack.render.Renderer.Shading)

Example 8 with Shading

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

the class ConnectorBoundsRenderer method drawTriangle.

public void drawTriangle(Renderer renderer, TriInfo tri) {
    RenderProps props = tri.props;
    Shading savedShading = renderer.setPropsShading(props);
    renderer.setFaceColoring(props, isSelected());
    renderer.setFaceStyle(props.getFaceStyle());
    renderer.beginDraw(DrawMode.TRIANGLES);
    renderer.setNormal(tri.nrm);
    for (int i = 0; i < tri.pts.length; i++) {
        renderer.addVertex(tri.pts[i]);
    }
    renderer.endDraw();
    renderer.setShading(savedShading);
    renderer.setFaceStyle(FaceStyle.FRONT);
}
Also used : LineRenderProps(maspack.render.LineRenderProps) FaceRenderProps(maspack.render.FaceRenderProps) RenderProps(maspack.render.RenderProps) Shading(maspack.render.Renderer.Shading)

Example 9 with Shading

use of maspack.render.Renderer.Shading 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 10 with Shading

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

the class CollisionRenderer method drawLines.

private void drawLines(Renderer renderer, RenderObject ro, RenderProps props) {
    LineStyle style = props.getLineStyle();
    Shading savedShading = renderer.setLineShading(props);
    renderer.setLineColoring(props, /*highlight=*/
    false);
    switch(style) {
        case LINE:
            {
                int width = props.getLineWidth();
                if (width > 0) {
                    // renderer.setLightingEnabled (false);
                    // renderer.setColor (props.getLineColorArray(), /*highlight=*/false);
                    renderer.drawLines(ro, LineStyle.LINE, width);
                // renderer.setLightingEnabled (true);
                }
                break;
            }
        // do we need to handle the solid line case?
        case SPINDLE:
        case SOLID_ARROW:
        case CYLINDER:
            {
                double rad = props.getLineRadius();
                if (rad > 0) {
                    // Shading savedShading = renderer.getShadeModel();
                    // renderer.setLineLighting (props, /*highlight=*/false);
                    renderer.drawLines(ro, style, rad);
                // renderer.setShadeModel(savedShading);
                }
                break;
            }
    }
    renderer.setShading(savedShading);
}
Also used : LineStyle(maspack.render.Renderer.LineStyle) Shading(maspack.render.Renderer.Shading)

Aggregations

Shading (maspack.render.Renderer.Shading)38 RenderProps (maspack.render.RenderProps)10 RigidTransform3d (maspack.matrix.RigidTransform3d)7 Vector3d (maspack.matrix.Vector3d)7 FaceStyle (maspack.render.Renderer.FaceStyle)5 RenderObject (maspack.render.RenderObject)4 ColorInterpolation (maspack.render.Renderer.ColorInterpolation)4 PointStyle (maspack.render.Renderer.PointStyle)4 ModelComponent (artisynth.core.modelbase.ModelComponent)3 Point3d (maspack.matrix.Point3d)3 ColorMapProps (maspack.render.ColorMapProps)3 LineRenderProps (maspack.render.LineRenderProps)3 LineStyle (maspack.render.Renderer.LineStyle)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 Rectangle2D (java.awt.geom.Rectangle2D)2 FaceRenderProps (maspack.render.FaceRenderProps)2 Renderer (maspack.render.Renderer)2 ColorMixing (maspack.render.Renderer.ColorMixing)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)1 LinkedList (java.util.LinkedList)1