Search in sources :

Example 11 with FrameMarker

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

the class SkinDemo method addAntagonist.

public void addAntagonist() {
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (lowerArm == null) {
        return;
    }
    Point3d markerBodyPos = new Point3d(-size.x / 2, 0, 0);
    // Point3d markerBodyPos = new Point3d(-size.x,0,-(size.z/2.0)/1.2);
    FrameMarker marker = new FrameMarker();
    model.addFrameMarker(marker, lowerArm, markerBodyPos);
    Particle fixed = new Particle(1.0, new Point3d(-size.z / 4, 0, -size.z / 2.0));
    // Particle fixed = new Particle(1.0,new Point3d(size.z/4,0,size.z));
    fixed.setDynamic(false);
    model.addParticle(fixed);
    AxialSpring spring = new AxialSpring(100.0, 2.0, 0.0);
    spring.setFirstPoint(marker);
    spring.setSecondPoint(fixed);
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setLineStyle(Renderer.LineStyle.SPINDLE);
    rp.setShading(Renderer.Shading.FLAT);
    rp.setLineColor(Color.WHITE);
    spring.setRenderProps(rp);
    model.addAxialSpring(spring);
}
Also used : Particle(artisynth.core.mechmodels.Particle) FrameMarker(artisynth.core.mechmodels.FrameMarker) Point3d(maspack.matrix.Point3d) RenderProps(maspack.render.RenderProps) RigidBody(artisynth.core.mechmodels.RigidBody) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 12 with FrameMarker

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

the class SkinDemo method addMuscle.

public void addMuscle() {
    RigidBody upperArm = model.rigidBodies().get("upper");
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (upperArm == null || lowerArm == null) {
        return;
    }
    Point3d markerBodyPos = new Point3d(-size.x / 2, 0, (size.z / 2.0) / 1.2);
    FrameMarker u = new FrameMarker();
    model.addFrameMarker(u, upperArm, markerBodyPos);
    u.setName("upperAttachment");
    markerBodyPos = new Point3d(size.x / 2, 0, -(size.z / 2.0) / 2);
    FrameMarker l = new FrameMarker();
    model.addFrameMarker(l, lowerArm, markerBodyPos);
    l.setName("lowerAttachment");
    Muscle muscle = new Muscle("muscle");
    muscle.setPeckMuscleMaterial(20.0, 22.0, 30, 0.2, 0.5, 0.1);
    muscle.setFirstPoint(u);
    muscle.setSecondPoint(l);
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setLineStyle(Renderer.LineStyle.SPINDLE);
    rp.setLineRadius(len / 20);
    // rp.setLineSlices(10);
    rp.setShading(Renderer.Shading.SMOOTH);
    rp.setLineColor(Color.RED);
    muscle.setRenderProps(rp);
    model.addAxialSpring(muscle);
    if (addCompression) {
        markerBodyPos = new Point3d(size.x / 2, 0, +size.z / 2.0);
        FrameMarker l2 = new FrameMarker();
        model.addFrameMarker(l2, lowerArm, markerBodyPos);
        l2.setName("lowerAttachmentCompressor");
        double len = u.getPosition().distance(l2.getPosition());
        AxialSpring s = new AxialSpring(10, 0, 50);
        s.setFirstPoint(u);
        s.setSecondPoint(l2);
        model.addAxialSpring(s);
        RenderProps props = new RenderProps();
        props.setLineStyle(Renderer.LineStyle.CYLINDER);
        props.setLineRadius(0.0);
        s.setRenderProps(props);
    }
}
Also used : FrameMarker(artisynth.core.mechmodels.FrameMarker) Point3d(maspack.matrix.Point3d) RenderProps(maspack.render.RenderProps) Muscle(artisynth.core.mechmodels.Muscle) RigidBody(artisynth.core.mechmodels.RigidBody) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 13 with FrameMarker

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

the class SkinDemo method addEndPoint.

public void addEndPoint() {
    RigidBody lowerArm = model.rigidBodies().get("lower");
    if (lowerArm == null) {
        return;
    }
    FrameMarker endPoint = new FrameMarker();
    endPoint.setName("endPoint");
    endPoint.setFrame(lowerArm);
    endPoint.setLocation(new Point3d(0, 0, len / 2));
    model.addFrameMarker(endPoint);
    // lowerArm.addMarker(endPoint);
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setShading(Renderer.Shading.SMOOTH);
    rp.setPointColor(Color.ORANGE);
    rp.setPointRadius(len / 20);
    endPoint.setRenderProps(rp);
}
Also used : FrameMarker(artisynth.core.mechmodels.FrameMarker) Point3d(maspack.matrix.Point3d) RenderProps(maspack.render.RenderProps) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 14 with FrameMarker

use of artisynth.core.mechmodels.FrameMarker 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)

Aggregations

FrameMarker (artisynth.core.mechmodels.FrameMarker)14 RigidBody (artisynth.core.mechmodels.RigidBody)11 Point3d (maspack.matrix.Point3d)9 MechModel (artisynth.core.mechmodels.MechModel)6 RenderProps (maspack.render.RenderProps)6 AxialSpring (artisynth.core.mechmodels.AxialSpring)4 Particle (artisynth.core.mechmodels.Particle)4 RigidTransform3d (maspack.matrix.RigidTransform3d)4 Muscle (artisynth.core.mechmodels.Muscle)3 PlanarConnector (artisynth.core.mechmodels.PlanarConnector)3 ConnectorForceRenderer (artisynth.core.inverse.ConnectorForceRenderer)2 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)2 WayPoint (artisynth.core.probes.WayPoint)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 Vector3d (maspack.matrix.Vector3d)2 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)1 SimpleAxialMuscle (artisynth.core.materials.SimpleAxialMuscle)1 BodyConnector (artisynth.core.mechmodels.BodyConnector)1 Frame (artisynth.core.mechmodels.Frame)1 MultiPointMuscle (artisynth.core.mechmodels.MultiPointMuscle)1