Search in sources :

Example 21 with RenderProps

use of maspack.render.RenderProps in project artisynth_core by artisynth.

the class PlanarConnector method defaultRenderProps.

protected static RenderProps defaultRenderProps(HasProperties host) {
    RenderProps props = RenderProps.createFaceProps(null);
    props.setFaceStyle(Renderer.FaceStyle.FRONT_AND_BACK);
    return props;
}
Also used : RenderProps(maspack.render.RenderProps)

Example 22 with RenderProps

use of maspack.render.RenderProps in project artisynth_core by artisynth.

the class Muscle method prerender.

@Override
public void prerender(RenderList list) {
    RenderProps props = myRenderProps;
    if (props == null) {
        if (getParent() instanceof Renderable) {
            props = ((Renderable) getParent()).getRenderProps();
        }
    }
    if (props != null && myExcitationColor != null) {
        if (myRenderColor == null) {
            myRenderColor = new float[3];
        }
        float[] baseColor = props.getLineColorF();
        double s = Math.min(getNetExcitation() / getMaxColoredExcitation(), 1);
        ColorUtils.interpolateColor(myRenderColor, baseColor, myExcitationColor, s);
    } else {
        myRenderColor = null;
    }
}
Also used : Renderable(maspack.render.Renderable) RenderProps(maspack.render.RenderProps)

Example 23 with RenderProps

use of maspack.render.RenderProps in project artisynth_core by artisynth.

the class FemDisplayProbe method updateVertexColoringRest.

/**
 * Updates vertex colors
 */
protected void updateVertexColoringRest() {
    RenderProps rprops = getRenderProps();
    float alpha = (float) rprops.getAlpha();
    Color faceColor = rprops.getFaceColor();
    float backAlpha = (float) myBackgroundAlpha * alpha;
    Color femFaceColor = null;
    double stressVal = 0;
    if (mySurfaceRendering == SurfaceRender.Stress || mySurfaceRendering == SurfaceRender.Strain) {
        if (myStressPlotRanging == Ranging.Auto) {
            myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
        }
    } else {
        femFaceColor = myFem.getRenderProps().getFaceColor();
    }
    float[] carray = new float[3];
    // use our stored map of values
    for (Vertex3d vtx : myPlaneSurface.getVertices()) {
        if (!vtxIndicatorMap.containsKey(vtx) || !vtxIndicatorMap.get(vtx)) {
            setColor(vtx, faceColor, backAlpha);
        } else {
            VtxInfo vtxInfo;
            switch(mySurfaceRendering) {
                case None:
                    setColor(vtx, faceColor, alpha);
                    break;
                case Strain:
                    vtxInfo = clippedVtxMap.get(vtx);
                    if (vtxInfo != null) {
                        stressVal = getStrainValue(vtxInfo);
                        myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                        setColor(vtx, carray[0], carray[1], carray[2], alpha);
                    } else {
                        setColor(vtx, femFaceColor, backAlpha);
                    }
                    break;
                case Stress:
                    vtxInfo = clippedVtxMap.get(vtx);
                    if (vtxInfo != null) {
                        stressVal = getStressValue(clippedVtxMap.get(vtx));
                        myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                        setColor(vtx, carray[0], carray[1], carray[2], alpha);
                    } else {
                        setColor(vtx, femFaceColor, backAlpha);
                    }
                    break;
                default:
                    setColor(vtx, femFaceColor, alpha);
            }
        }
    }
}
Also used : Vertex3d(maspack.geometry.Vertex3d) Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 24 with RenderProps

use of maspack.render.RenderProps in project artisynth_core by artisynth.

the class FemDisplayProbe method updateVertexColoringDynamic.

/**
 * Updates vertex colors
 */
protected void updateVertexColoringDynamic() {
    RenderProps rprops = getRenderProps();
    float alpha = (float) rprops.getAlpha();
    float backAlpha = (float) myBackgroundAlpha * alpha;
    Color faceColor = rprops.getFaceColor();
    Color femFaceColor = null;
    double stressVal = 0;
    float[] carray = new float[3];
    if (myFem != null) {
        if (mySurfaceRendering == SurfaceRender.Stress || mySurfaceRendering == SurfaceRender.Strain) {
            if (myStressPlotRanging == Ranging.Auto) {
                myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
            }
        } else {
            femFaceColor = myFem.getRenderProps().getFaceColor();
        }
    } else {
        // arbitrary, shouldn't be used
        femFaceColor = Color.BLACK;
    }
    // do with some kind of synchronization
    try {
        for (Vertex3d vtx : myPlaneSurface.getVertices()) {
            if (!vtxIndicatorMap.containsKey(vtx) || !vtxIndicatorMap.get(vtx)) {
                setColor(vtx, faceColor, backAlpha);
            } else {
                switch(mySurfaceRendering) {
                    case None:
                        setColor(vtx, faceColor, alpha);
                        break;
                    case Strain:
                        stressVal = getStrainValue(vtx.getWorldPoint(), myFem);
                        myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                        setColor(vtx, carray[0], carray[1], carray[2], alpha);
                        break;
                    case Stress:
                        stressVal = getStressValue(vtx.getWorldPoint(), myFem);
                        myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                        setColor(vtx, carray[0], carray[1], carray[2], alpha);
                        break;
                    default:
                        setColor(vtx, femFaceColor, alpha);
                }
            }
        }
    } catch (Exception e) {
        System.err.println("Error in display probe: " + e.getMessage());
    }
}
Also used : Vertex3d(maspack.geometry.Vertex3d) Color(java.awt.Color) RenderProps(maspack.render.RenderProps) IOException(java.io.IOException)

Example 25 with RenderProps

use of maspack.render.RenderProps in project artisynth_core by artisynth.

the class PointTracingProbe method initRenderProps.

private void initRenderProps(ModelComponent comp) {
    RenderProps newProps = createRenderProps();
    if (comp instanceof HasRenderProps) {
        HasRenderProps rcomp = (HasRenderProps) comp;
        RenderProps compProps = rcomp.getRenderProps();
        if (compProps == null) {
            compProps = rcomp.createRenderProps();
        }
        newProps.set(compProps);
        // line and point colors of render props to match
        if (compProps.getPointColorMode() == PropertyMode.Explicit) {
            float[] pointColor = compProps.getPointColorF();
            newProps.setPointColor(pointColor);
            newProps.setLineColor(pointColor);
        }
    }
    newProps.setLineWidth(3);
    setRenderProps(newProps);
}
Also used : HasRenderProps(maspack.render.HasRenderProps) HasRenderProps(maspack.render.HasRenderProps) RenderProps(maspack.render.RenderProps)

Aggregations

RenderProps (maspack.render.RenderProps)86 Color (java.awt.Color)17 Vector3d (maspack.matrix.Vector3d)17 RigidBody (artisynth.core.mechmodels.RigidBody)11 RigidTransform3d (maspack.matrix.RigidTransform3d)11 Shading (maspack.render.Renderer.Shading)10 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Point3d (maspack.matrix.Point3d)8 RenderObject (maspack.render.RenderObject)7 FrameMarker (artisynth.core.mechmodels.FrameMarker)6 File (java.io.File)6 IOException (java.io.IOException)6 Vertex3d (maspack.geometry.Vertex3d)6 AffineTransform3d (maspack.matrix.AffineTransform3d)4 ColorMapProps (maspack.render.ColorMapProps)4 HasRenderProps (maspack.render.HasRenderProps)4 LineRenderProps (maspack.render.LineRenderProps)4 AxialSpring (artisynth.core.mechmodels.AxialSpring)3 Muscle (artisynth.core.mechmodels.Muscle)3 LinkedList (java.util.LinkedList)3