Search in sources :

Example 16 with Muscle

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

the class HydrostatInvDemo method setupRenderProps.

public void setupRenderProps() {
    RenderProps.setFaceStyle(hydro, FaceStyle.FRONT);
    RenderProps.setFaceColor(hydro, new Color(0.8f, 0.8f, 1f));
    RenderProps.setVisible(hydro.getElements(), false);
    RenderProps.setPointSize(hydro.getNodes(), 0);
    ArrayList<Muscle> visibleMuscles = new ArrayList<Muscle>();
    for (MuscleBundle b : hydro.getMuscleBundles()) {
        String name = b.getName();
        RenderProps.setLineRadiusMode(b, PropertyMode.Inherited);
    // if (name.startsWith("horz") || name.startsWith("vert")) {
    // for (Muscle m : b)
    // visibleMuscles.add(m);
    // }
    // else
    // RenderProps.setVisible(b, false);
    }
    RenderProps.setLineRadius(hydro.getMuscleBundles(), s * 0.75);
// float h = 1f / (float)visibleMuscles.size();
// for (int i = 0; i < visibleMuscles.size(); i++) {
// System.out.println("h = "+i*h);
// RenderProps.setLineColor(visibleMuscles.get(i), Color.getHSBColor (i*h, 1f, 1f));
// }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Color(java.awt.Color) ArrayList(java.util.ArrayList) Muscle(artisynth.core.mechmodels.Muscle)

Example 17 with Muscle

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

the class PointModel method add3dMuscles.

public void add3dMuscles() {
    int[] x = new int[] { -1, 0, 1 };
    int[] y = new int[] { -1, 0, 1 };
    int[] z = new int[] { -1, 0, 1 };
    double eps = 1e-4;
    for (int i = 0; i < x.length; i++) {
        for (int j = 0; j < y.length; j++) {
            for (int k = 0; k < z.length; k++) {
                Point3d pnt = new Point3d(x[i], y[j], z[k]);
                if (pnt.x == 0 || pnt.y == 0 || pnt.z == 0)
                    continue;
                // if (pnt.norm() < 1e-4 || pnt.norm() > Math.sqrt(2))
                // continue;
                // if (pnt.norm() < 1e-4 || pnt.norm() > 1.0)
                // continue;
                pnt.normalize();
                pnt.scale(len);
                Particle endPt = new Particle(mass, pnt);
                endPt.setDynamic(false);
                model.addParticle(endPt);
                Muscle m = addMuscle(endPt);
                m.setName(String.format("x%dy%dz%d", x[i], y[j], z[k]));
                RenderProps.setLineColor(m, Color.RED);
            }
        }
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) LinearAxialMuscle(artisynth.core.materials.LinearAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) Point(artisynth.core.mechmodels.Point) SphericalJoint(artisynth.core.mechmodels.SphericalJoint)

Example 18 with Muscle

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

the class SpongeModel method addMuscle.

protected void addMuscle(MuscleBundle b, int i0, int i1) {
    Muscle m = new Muscle();
    m.setFirstPoint(getNode(i0));
    m.setSecondPoint(getNode(i1));
    m.setConstantMuscleMaterial(maxMuscleForce, 1);
    b.addFibre(m);
}
Also used : Muscle(artisynth.core.mechmodels.Muscle)

Example 19 with Muscle

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

the class SpongeModel method addSingleMuscle.

protected void addSingleMuscle() {
    Muscle m = new Muscle();
    m.setConstantMuscleMaterial(1, 1);
    m.setFirstPoint(getNode(r.nextInt(numNodes())));
    m.setSecondPoint(getNode(r.nextInt(numNodes())));
    MuscleBundle b = new MuscleBundle();
    b.addFibre(m);
    b.setFibresActive(true);
    addMuscleBundle(b);
    RenderProps props = createRenderProps();
    props.setLineColor(NumericProbePanel.colorList[getMuscleBundles().size()]);
    props.setLineRadius(len / 20);
    props.setLineStyle(LineStyle.SPINDLE);
    m.setRenderProps(props);
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) RenderProps(maspack.render.RenderProps) Muscle(artisynth.core.mechmodels.Muscle)

Example 20 with Muscle

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

the class DoubleArmDemo method addMuscles.

public void addMuscles() {
    RigidBody upperArm = model.rigidBodies().get("upper");
    RigidBody lowerArm = model.rigidBodies().get("lower");
    RigidBody thirdArm = model.rigidBodies().get("third");
    if (upperArm == null || lowerArm == null || thirdArm == 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) / 1.2);
    FrameMarker tu = new FrameMarker();
    model.addFrameMarker(tu, thirdArm, markerBodyPos);
    tu.setName("thirdUpperAttachment");
    markerBodyPos = new Point3d(size.x / 2, 0, -(size.z / 2.0) / 2);
    FrameMarker l = new FrameMarker();
    model.addFrameMarker(l, lowerArm, markerBodyPos);
    l.setName("lowerAttachment");
    markerBodyPos = new Point3d(size.x / 2, 0, (size.z / 2.0) / 2);
    FrameMarker tl = new FrameMarker();
    model.addFrameMarker(tl, lowerArm, markerBodyPos);
    tl.setName("thirdLowerAttachment");
    Muscle muscle = new Muscle("muscle");
    muscle.setPeckMuscleMaterial(20.0, 22.0, 30, 0.2, 0.5, 0.1);
    Muscle muscle2 = new Muscle("muscle2");
    muscle2.setPeckMuscleMaterial(8, 20, 30, 0.2, 0.5, 0.1);
    muscle.setFirstPoint(u);
    muscle2.setFirstPoint(tu);
    muscle.setSecondPoint(l);
    muscle2.setSecondPoint(tl);
    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);
    muscle2.setRenderProps(rp);
    model.addAxialSpring(muscle);
    model.addAxialSpring(muscle2);
    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);
        // restoring spring
        len = tu.getPosition().distance(tl.getPosition());
        s = new AxialSpring(10, 0, 2 * len);
        s.setFirstPoint(tu);
        s.setSecondPoint(tl);
        model.addAxialSpring(s);
        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)

Aggregations

Muscle (artisynth.core.mechmodels.Muscle)35 Point3d (maspack.matrix.Point3d)13 Point (artisynth.core.mechmodels.Point)10 ConstantAxialMuscle (artisynth.core.materials.ConstantAxialMuscle)9 AxialSpring (artisynth.core.mechmodels.AxialSpring)8 GenericMuscle (artisynth.core.materials.GenericMuscle)7 MuscleBundle (artisynth.core.femmodels.MuscleBundle)6 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)5 SimpleAxialMuscle (artisynth.core.materials.SimpleAxialMuscle)4 Particle (artisynth.core.mechmodels.Particle)4 RenderProps (maspack.render.RenderProps)4 FrameMarker (artisynth.core.mechmodels.FrameMarker)3 MuscleExciter (artisynth.core.mechmodels.MuscleExciter)3 Vector3d (maspack.matrix.Vector3d)3 FemMarker (artisynth.core.femmodels.FemMarker)2 ForceTarget (artisynth.core.inverse.ForceTarget)2 ForceTargetTerm (artisynth.core.inverse.ForceTargetTerm)2 TrackingController (artisynth.core.inverse.TrackingController)2 AxialMuscleMaterial (artisynth.core.materials.AxialMuscleMaterial)2 RigidBody (artisynth.core.mechmodels.RigidBody)2