Search in sources :

Example 11 with RenderProps

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

the class RigidBodyAgent method createPreviewBody.

private void createPreviewBody() {
    resetScaling();
    body = new RigidBody();
    setProperties(body, getPrototypeComponent(myComponentType));
    setProperties(myPrototype, myPrototype);
    body.setMesh(myGeometryPanel.getMesh(), myGeometryPanel.getMeshFileName(), myGeometryPanel.getMeshTransform());
    RigidTransform3d X = new RigidTransform3d();
    X.p.set(positionField.getVectorValue());
    X.R.setAxisAngle(orientationField.getAxisAngleValue());
    body.setPose(X);
    RenderProps props = body.createRenderProps();
    props.setFaceStyle(Renderer.FaceStyle.NONE);
    props.setDrawEdges(true);
    props.setLineColor(Color.LIGHT_GRAY);
    body.setRenderProps(props);
    myMain.getWorkspace().getViewerManager().addRenderable(body);
    rotator = new Transrotator3d();
    GLViewer viewer = myMain.getMain().getViewer();
    rotator.setDraggerToWorld(X);
    rotator.setSize(viewer.distancePerPixel(viewer.getCenter()) * viewer.getScreenWidth() / 6);
    rotator.addListener(new RigidBodyDraggerListener());
    myMain.getWorkspace().getViewerManager().addDragger(rotator);
    myGeometryPanel.setAttachedBody(body);
    myMain.rerender();
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) GLViewer(maspack.render.GL.GLViewer) RenderProps(maspack.render.RenderProps) Transrotator3d(maspack.render.Transrotator3d) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 12 with RenderProps

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

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

the class SelectionPopup method isVisible.

private boolean isVisible(RenderableComponent rcomp) {
    RenderProps props = rcomp.getRenderProps();
    if (props != null) {
        return props.isVisible();
    }
    CompositeComponent parent = rcomp.getParent();
    if (parent instanceof RenderableComponentList) {
        return ((RenderableComponentList<?>) parent).rendersSubComponents();
    }
    return false;
}
Also used : RenderableComponentList(artisynth.core.modelbase.RenderableComponentList) RenderProps(maspack.render.RenderProps) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) CompositeComponent(artisynth.core.modelbase.CompositeComponent)

Example 14 with RenderProps

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

the class MeshComponent method setMesh.

public void setMesh(MeshBase mesh, String fileName, AffineTransform3dBase X) {
    doSetMesh(mesh, fileName, X);
    RenderProps meshProps = mesh.getRenderProps();
    if (meshProps != null) {
        setRenderProps(meshProps);
    }
}
Also used : RenderProps(maspack.render.RenderProps)

Example 15 with RenderProps

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

the class MFreeMeshComp method updateVertexColors.

protected void updateVertexColors() {
    if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
        return;
    }
    if (myStressPlotRanging == Ranging.Auto) {
        myStressPlotRange.merge(myModel.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 MFreeNode3d) {
                    // paranoid!
                    MFreeNode3d node = (MFreeNode3d) 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;
            MFreeNode3d node = (MFreeNode3d) 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 : FemNode(artisynth.core.femmodels.FemNode) RenderProps(maspack.render.RenderProps) MeshBase(maspack.geometry.MeshBase) FemMeshBase(artisynth.core.femmodels.FemMeshBase) VectorNd(maspack.matrix.VectorNd) PointFem3dAttachment(artisynth.core.femmodels.PointFem3dAttachment) 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