Search in sources :

Example 66 with RenderProps

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

Example 67 with RenderProps

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

the class FemDisplayProbe method computeClippedVertexColors.

// if we are clipped to the FEM, then the shape function values are fixed
private void computeClippedVertexColors() {
    RenderProps rprops = getRenderProps();
    float alpha = (float) rprops.getAlpha();
    Color faceColor = rprops.getFaceColor();
    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()) {
        switch(mySurfaceRendering) {
            case None:
                setColor(vtx, faceColor, alpha);
                break;
            case Strain:
                stressVal = getStrainValue(clippedVtxMap.get(vtx));
                myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                setColor(vtx, carray[0], carray[1], carray[2], alpha);
                break;
            case Stress:
                stressVal = getStressValue(clippedVtxMap.get(vtx));
                myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
                setColor(vtx, carray[0], carray[1], carray[2], alpha);
                break;
            default:
                setColor(vtx, femFaceColor, alpha);
        }
    }
}
Also used : Vertex3d(maspack.geometry.Vertex3d) Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 68 with RenderProps

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

the class MeshCollisionViewer method createRenderProps.

private RenderProps createRenderProps(PolygonalMesh mesh) {
    RenderProps props = mesh.createRenderProps();
    props.setShading(smooth.value ? Shading.SMOOTH : Shading.FLAT);
    if (noDrawFaces.value) {
        props.setFaceStyle(FaceStyle.NONE);
    } else if (oneSided.value) {
        props.setFaceStyle(FaceStyle.FRONT);
    } else {
        props.setFaceStyle(FaceStyle.FRONT_AND_BACK);
    }
    props.setDrawEdges(drawEdges.value);
    if (edgeColor[0] != -1) {
        props.setLineColor(new Color(edgeColor[0], edgeColor[1], edgeColor[2]));
    }
    Color gold = new Color(0.93f, 0.8f, 0.063f);
    Color gray = new Color(0.5f, 0.5f, 0.5f);
    props.setFaceColor(gray);
    props.setAlpha(0.5);
    // props.setBackColor (gray);
    return props;
}
Also used : Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 69 with RenderProps

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

the class MeshViewer method createRenderProps.

private RenderProps createRenderProps(MeshBase mesh) {
    RenderProps props = mesh.createRenderProps();
    props.setShading(smooth.value ? Shading.SMOOTH : Shading.FLAT);
    if (noDrawFaces.value) {
        props.setFaceStyle(FaceStyle.NONE);
    } else if (oneSided.value) {
        props.setFaceStyle(FaceStyle.FRONT);
    } else {
        props.setFaceStyle(FaceStyle.FRONT_AND_BACK);
    }
    props.setDrawEdges(drawEdges.value);
    if (edgeColor[0] != -1) {
        props.setLineColor(new Color(edgeColor[0], edgeColor[1], edgeColor[2]));
    }
    Color gold = new Color(0.93f, 0.8f, 0.063f);
    Color gray = new Color(0.5f, 0.5f, 0.5f);
    props.setFaceColor(gray);
    props.setBackColor(gray);
    return props;
}
Also used : Color(java.awt.Color) RenderProps(maspack.render.RenderProps)

Example 70 with RenderProps

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

the class FemMeshComp method updateVertexColors.

protected void updateVertexColors() {
    if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
        return;
    }
    if (myStressPlotRanging == Ranging.Auto) {
        myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
    }
    RenderProps rprops = getRenderProps();
    float alpha = (float) rprops.getAlpha();
    MeshBase mesh = getMesh();
    double sval = 0;
    for (int i = 0; i < myVertexAttachments.size(); i++) {
        PointAttachment attacher = myVertexAttachments.get(i);
        sval = 0;
        if (attacher instanceof PointFem3dAttachment) {
            PointFem3dAttachment pfa = (PointFem3dAttachment) attacher;
            FemNode[] nodes = pfa.getNodes();
            VectorNd weights = pfa.getCoordinates();
            for (int j = 0; j < nodes.length; j++) {
                if (nodes[j] instanceof FemNode3d) {
                    // paranoid!
                    FemNode3d node = (FemNode3d) nodes[j];
                    double w = weights.get(j);
                    if (mySurfaceRendering == SurfaceRender.Strain) {
                        sval += w * node.getVonMisesStrain();
                    } else if (mySurfaceRendering == SurfaceRender.Stress) {
                        sval += w * node.getVonMisesStress();
                    }
                }
            }
        } else if (attacher instanceof PointParticleAttachment) {
            PointParticleAttachment ppa = (PointParticleAttachment) attacher;
            FemNode3d node = (FemNode3d) ppa.getParticle();
            if (mySurfaceRendering == SurfaceRender.Strain) {
                sval = node.getVonMisesStrain();
            } else if (mySurfaceRendering == SurfaceRender.Stress) {
                sval = node.getVonMisesStress();
            }
        }
        double smin = myStressPlotRange.getLowerBound();
        double srng = myStressPlotRange.getRange();
        double c = (sval - smin) / srng;
        c = Math.max(0, Math.min(c, 1.0));
        myColorMap.getRGB(c, colorArray);
        mesh.setColor(i, colorArray[0], colorArray[1], colorArray[2], alpha);
    }
}
Also used : RenderProps(maspack.render.RenderProps) MeshBase(maspack.geometry.MeshBase) VectorNd(maspack.matrix.VectorNd) PointAttachment(artisynth.core.mechmodels.PointAttachment) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

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