Search in sources :

Example 41 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class PenetrationRendererDemo method build.

public void build(String[] args) {
    // create MechModel and add to RootModel
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // create and add the ball and plate
    RigidBody ball = RigidBody.createIcosahedralSphere("ball", 0.8, 0.1, 1);
    // ball.setPose (new RigidTransform3d (0, 0, 2, 0.4, 0.1, 0.1));
    ball.setPose(new RigidTransform3d(0, 0, 0, 0.4, 0.1, 0.1));
    ball.setDynamic(false);
    mech.addRigidBody(ball);
    RigidBody plate = RigidBody.createBox("plate", 5, 5, 5, 1);
    plate.setPose(new RigidTransform3d(0, 0, 2.94, 1, 0, 0, 0));
    plate.setDynamic(false);
    mech.addRigidBody(plate);
    // turn on collisions
    mech.setDefaultCollisionBehavior(true, 0.20);
    // make ball transparent so that contacts can be seen more clearly
    RenderProps.setFaceStyle(ball, Renderer.FaceStyle.NONE);
    RenderProps.setDrawEdges(ball, true);
    RenderProps.setEdgeColor(ball, Color.WHITE);
    RenderProps.setVisible(plate, false);
    RenderProps.setAlpha(plate, 0.5);
    // enable rendering of contacts normals and contours
    CollisionManager cm = mech.getCollisionManager();
    RenderProps.setVisible(cm, true);
    RenderProps.setLineWidth(cm, 3);
    RenderProps.setLineColor(cm, Color.RED);
    RenderProps.setEdgeWidth(cm, 3);
    RenderProps.setEdgeColor(cm, Color.BLUE);
    cm.setContactNormalLen(0.5);
    cm.setDrawContactNormals(true);
    cm.setDrawIntersectionContours(true);
    cm.setDrawIntersectionFaces(true);
    cm.setDrawIntersectionPoints(true);
    CollisionResponse resp = mech.setCollisionResponse(ball, plate);
    addMonitor(new PenetrationRenderer(resp));
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) CollisionManager(artisynth.core.mechmodels.CollisionManager) RigidBody(artisynth.core.mechmodels.RigidBody) CollisionResponse(artisynth.core.mechmodels.CollisionResponse)

Example 42 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class FrameMarkerEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsSingleSelection(selection, FrameMarker.class)) {
        if (actionCommand == "Add PlanarConnector") {
            FrameMarker mkr = (FrameMarker) selection.get(0);
            RigidTransform3d XPW = new RigidTransform3d();
            XPW.p.set(mkr.getPosition());
            if (mkr.getFrame() instanceof RigidBody && mkr.getGrandParent() instanceof MechModel) {
                PlanarConnector pc = new PlanarConnector();
                pc.set((RigidBody) mkr.getFrame(), mkr.getLocation(), Vector3d.Z_UNIT);
                pc.setPlaneSize(getDefaultPlaneSize());
                ((MechModel) mkr.getGrandParent()).addBodyConnector(pc);
            } else {
                System.out.println("Unable to create PlanarConnector from selected FrameMarker");
            }
        }
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) MechModel(artisynth.core.mechmodels.MechModel) FrameMarker(artisynth.core.mechmodels.FrameMarker) PlanarConnector(artisynth.core.mechmodels.PlanarConnector) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 43 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class RigidBodyEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsMultipleSelection(selection, RigidBody.class)) {
        actions.add(this, "Select markers");
        if (containsSingleSelection(selection, RigidBody.class)) {
            RigidBody body = (RigidBody) selection.get(0);
            actions.add(this, "Edit geometry and inertia ...", EXCLUSIVE);
            actions.add(this, "Save mesh as ...");
            if (body.getGrandParent() instanceof MechModel) {
                actions.add(this, "Attach particles ...", EXCLUSIVE);
            }
            if (body.getSurfaceMesh() != null) {
                actions.add(this, "Add mesh inspector");
            }
        }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 44 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class TransverseIsotropy method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    double h = 0.1;
    double r = 0.005;
    RigidBody rb = RigidBody.createBox("box", 2 * r, 2 * r, 2 * r, 100, true);
    mech.addRigidBody(rb);
    rb.transformGeometry(new RigidTransform3d(new Vector3d(0, 0, -h / 2 - r), AxisAngle.IDENTITY));
    FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
    fem.setDensity(1000);
    mech.addModel(fem);
    TransverseLinearMaterial mat = new TransverseLinearMaterial();
    mat.setYoungsModulus(50000, 50000);
    mat.setPoissonsRatio(0.45, 0.45);
    double G = 50000 / (2 * (1 + 0.45));
    mat.setShearModulus(G);
    fem.setMaterial(mat);
    fem.setName("fem");
    fem.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setFaceColor(fem, Color.ORANGE);
    RenderProps.setVisible(fem.getElements(), false);
    double eps = 1e-10;
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().z > h / 2 - eps) {
            node.setDynamic(false);
        } else if (node.getPosition().z < -h / 2 + eps) {
            PointAttachment pa = rb.createPointAttachment(node);
            mech.addAttachment(pa);
        }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) Vector3d(maspack.matrix.Vector3d) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody) PointAttachment(artisynth.core.mechmodels.PointAttachment) TransverseLinearMaterial(artisynth.core.materials.TransverseLinearMaterial)

Example 45 with RigidBody

use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.

the class FemSurfaceTargetDemo method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    mech.setGravity(Vector3d.ZERO);
    addModel(mech);
    fem = new FemMuscleModel("fem");
    fem.setStiffnessDamping(0.1);
    mech.addModel(fem);
    // boundary conditions
    FemFactory.createHexGrid(fem, l, w, w, nl, nw, nw);
    for (FemNode n : fem.getNodes()) {
        if (n.getPosition().x > l / 2 - eps) {
            n.setDynamic(false);
        }
    }
    // muscles
    addMuscle("vert", Color.RED, Vector3d.Z_UNIT);
    addMuscle("trans", Color.BLUE, Vector3d.Y_UNIT);
    body = new RigidBody("plate");
    body.setMesh(MeshFactory.createBox(l, l, l / 10));
    body.setPose(new RigidTransform3d(-1.2 * w - l / 20, 0, 0, 0, 1, 0, Math.PI / 2));
    body.setDynamic(false);
    mech.addRigidBody(body);
    mech.setCollisionBehavior(body, fem, true);
    addTrackingController();
    setupRenderProps();
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemNode(artisynth.core.femmodels.FemNode) RigidTransform3d(maspack.matrix.RigidTransform3d) FemMuscleModel(artisynth.core.femmodels.FemMuscleModel) RigidBody(artisynth.core.mechmodels.RigidBody)

Aggregations

RigidBody (artisynth.core.mechmodels.RigidBody)55 MechModel (artisynth.core.mechmodels.MechModel)25 RigidTransform3d (maspack.matrix.RigidTransform3d)18 FrameMarker (artisynth.core.mechmodels.FrameMarker)11 RenderProps (maspack.render.RenderProps)11 Point3d (maspack.matrix.Point3d)10 PolygonalMesh (maspack.geometry.PolygonalMesh)9 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)8 Vector3d (maspack.matrix.Vector3d)8 FemModel3d (artisynth.core.femmodels.FemModel3d)7 FemNode3d (artisynth.core.femmodels.FemNode3d)7 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)7 WayPoint (artisynth.core.probes.WayPoint)6 AxialSpring (artisynth.core.mechmodels.AxialSpring)5 Particle (artisynth.core.mechmodels.Particle)5 Color (java.awt.Color)5 CollisionManager (artisynth.core.mechmodels.CollisionManager)4 File (java.io.File)4 IOException (java.io.IOException)4 AxisAngle (maspack.matrix.AxisAngle)4