Search in sources :

Example 31 with RenderProps

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

the class SpongeModel method getNewMuscleProps.

public RenderProps getNewMuscleProps() {
    RenderProps props = createRenderProps();
    int idx = (getMuscleBundles().size() - 1) % NumericProbePanel.colorList.length;
    props.setLineColor(NumericProbePanel.colorList[idx]);
    props.setLineRadius(len / 20);
    props.setLineStyle(LineStyle.SPINDLE);
    return props;
}
Also used : RenderProps(maspack.render.RenderProps)

Example 32 with RenderProps

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

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

the class DoubleArmDemo method addEndPoint.

public void addEndPoint() {
    RigidBody thirdArm = model.rigidBodies().get("third");
    if (thirdArm == null) {
        return;
    }
    FrameMarker endPoint = new FrameMarker();
    endPoint.setName("endPoint");
    endPoint.setFrame(thirdArm);
    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 34 with RenderProps

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

the class DoubleArmDemo method addBody.

public void addBody(String name, RigidTransform3d pose, String meshName) {
    // add a simple rigid body to the simulation
    RigidBody rb = new RigidBody();
    rb.setName(name);
    rb.setPose(pose);
    model.addRigidBody(rb);
    PolygonalMesh mesh;
    try {
        String meshFilename = ArtisynthPath.getHomeRelativePath("src/artisynth/demos/mech/geometry/", ".") + meshName;
        mesh = new PolygonalMesh();
        mesh.read(new BufferedReader(new FileReader(new File(meshFilename))));
        rb.setMesh(mesh, meshFilename);
    } catch (IOException e) {
        System.out.println(e.getMessage());
        mesh = MeshFactory.createBox(size.x, size.y, size.z);
        rb.setMesh(mesh, null);
    }
    rb.setInertia(SpatialInertia.createBoxInertia(10.0, size.x, size.y, size.z));
    RenderProps rp = new RenderProps(model.getRenderProps());
    rp.setFaceColor(Color.GRAY);
    rp.setShading(Renderer.Shading.FLAT);
    rb.setRenderProps(rp);
    rb.setFrameDamping(10);
    rb.setRotaryDamping(1000.0);
}
Also used : BufferedReader(java.io.BufferedReader) RenderProps(maspack.render.RenderProps) FileReader(java.io.FileReader) RigidBody(artisynth.core.mechmodels.RigidBody) IOException(java.io.IOException) PolygonalMesh(maspack.geometry.PolygonalMesh) File(java.io.File)

Example 35 with RenderProps

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

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