Search in sources :

Example 1 with MechModel

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

the class FemEmbeddedSphere method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    addModel(mech);
    fem = new FemModel3d("fem");
    mech.addModel(fem);
    // Build hex beam and set properties
    double[] size = { 0.4, 0.4, 0.4 };
    int[] res = { 4, 4, 4 };
    FemFactory.createHexGrid(fem, size[0], size[1], size[2], res[0], res[1], res[2]);
    fem.setParticleDamping(2);
    fem.setDensity(10);
    fem.setMaterial(new LinearMaterial(4000, 0.33));
    // Add an embedded sphere mesh
    PolygonalMesh sphereSurface = MeshFactory.createOctahedralSphere(0.15, 3);
    sphere = fem.addMesh("sphere", sphereSurface);
    sphere.setCollidable(Collidability.EXTERNAL);
    // Boundary condition: fixed LHS
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().x < -0.49) {
            node.setDynamic(false);
        }
    }
    // Set rendering properties
    setFemRenderProps(fem);
    setMeshRenderProps(sphere);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 2 with MechModel

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

the class FrameBodyAttachment method build.

public void build(String[] args) {
    // create MechModel and add to RootModel
    mech = new MechModel("mech");
    mech.setGravity(0, 0, -98);
    mech.setFrameDamping(1.0);
    mech.setRotaryDamping(4.0);
    addModel(mech);
    // bodies will be defined using a mesh
    PolygonalMesh mesh;
    // create bodyB and set its pose
    mesh = MeshFactory.createRoundedBox(lenx1, leny1, lenz1, /*nslices=*/
    8);
    RigidTransform3d TMB = new RigidTransform3d(0, 0, 0, /*axisAng=*/
    1, 1, 1, 2 * Math.PI / 3);
    mesh.transform(TMB);
    bodyB = RigidBody.createFromMesh("bodyB", mesh, /*density=*/
    0.2, 1.0);
    bodyB.setPose(new RigidTransform3d(0, 0, 1.5 * lenx1, 1, 0, 0, Math.PI / 2));
    // create bodyA and set its pose
    mesh = MeshFactory.createRoundedCylinder(leny2 / 2, lenx2, /*nslices=*/
    16, /*nsegs=*/
    1, /*flatBottom=*/
    false);
    mesh.transform(TMB);
    bodyA = RigidBody.createFromMesh("bodyA", mesh, 0.2, 1.0);
    bodyA.setPose(new RigidTransform3d((lenx1 + leny2) / 2, 0, 1.5 * lenx1, 0, Math.PI / 2, 0));
    // create the joint
    RigidTransform3d TDW = new RigidTransform3d(-lenx1 / 2, 0, 1.5 * lenx1, 1, 0, 0, Math.PI / 2);
    RevoluteJoint joint = new RevoluteJoint(bodyB, TDW);
    // add components to the mech model
    mech.addRigidBody(bodyB);
    mech.addRigidBody(bodyA);
    mech.addBodyConnector(joint);
    // set render properties for components
    RenderProps.setLineRadius(joint, 0.2);
    joint.setAxisLength(4);
    // now connect bodyA to bodyB using a FrameAttachment
    mech.attachFrame(bodyA, bodyB);
    // create an auxiliary frame and add it to the mech model
    Frame frame = new Frame();
    mech.addFrame(frame);
    // set the frames axis length > 0 so we can see it
    frame.setAxisLength(4.0);
    // set the attached frame's pose to that of bodyA ...
    RigidTransform3d TFW = new RigidTransform3d(bodyA.getPose());
    // ... plus a translation of lenx2/2 along the x axis:
    TFW.mulXyz(lenx2 / 2, 0, 0);
    // finally, attach the frame to bodyA
    mech.attachFrame(frame, bodyA, TFW);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) Frame(artisynth.core.mechmodels.Frame) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 3 with MechModel

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

the class MultiSpringTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // addSprings(mech);
    // addMixedUpSprings(mech);
    // addSeparatedSprings(mech);
    // addSpringMesh(mech);
    addVerticalSprings(mech);
    // clear render props
    for (AxialSpring s : mech.axialSprings()) {
        s.setRenderProps(null);
    }
    RenderProps.setLineStyle(mech, LineStyle.CYLINDER);
    RenderProps.setLineRadius(mech, 0.02);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 4 with MechModel

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

the class SpecularTest method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mech");
    addModel(mech);
    RenderProps.setShininess(mech, 128);
    RenderProps.setFaceStyle(mech, FaceStyle.FRONT_AND_BACK);
    RenderProps.setFaceColor(mech, Color.GRAY.darker().darker());
    RenderProps.setSpecular(mech, Color.WHITE);
    // mech.getRenderProps().setColorMap (createTextureProps());
    // mech.getRenderProps().setNormalMap (createNormalProps());
    // mech.getRenderProps().setBumpMap (createBumpProps());
    FixedMeshBody body0 = createMesh(mech, 0);
// FixedMeshBody body1 = createMesh (mech, 2);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FixedMeshBody(artisynth.core.mechmodels.FixedMeshBody)

Example 5 with MechModel

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

the class FemBeam method build.

public void build(String[] args) throws IOException {
    // Create and add MechModel
    mech = new MechModel("mech");
    addModel(mech);
    // Create and add FemModel
    fem = new FemModel3d("fem");
    mech.add(fem);
    // Build hex beam using factory method
    FemFactory.createHexGrid(fem, length, width, width, /*nx=*/
    6, /*ny=*/
    3, /*nz=*/
    3);
    // Set FEM properties
    fem.setDensity(density);
    fem.setParticleDamping(0.1);
    fem.setMaterial(new LinearMaterial(4000, 0.33));
    // Fix left-hand nodes for boundary condition
    for (FemNode3d n : fem.getNodes()) {
        if (n.getPosition().x <= -length / 2 + EPS) {
            n.setDynamic(false);
        }
    }
    // Set rendering properties
    setRenderProps(fem);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d) LinearMaterial(artisynth.core.materials.LinearMaterial)

Aggregations

MechModel (artisynth.core.mechmodels.MechModel)59 RigidBody (artisynth.core.mechmodels.RigidBody)25 RigidTransform3d (maspack.matrix.RigidTransform3d)19 FemModel3d (artisynth.core.femmodels.FemModel3d)14 FemNode3d (artisynth.core.femmodels.FemNode3d)8 Particle (artisynth.core.mechmodels.Particle)8 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Vector3d (maspack.matrix.Vector3d)8 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)7 LinearMaterial (artisynth.core.materials.LinearMaterial)6 FrameMarker (artisynth.core.mechmodels.FrameMarker)6 CollisionManager (artisynth.core.mechmodels.CollisionManager)5 Color (java.awt.Color)5 AxialSpring (artisynth.core.mechmodels.AxialSpring)4 BodyConnector (artisynth.core.mechmodels.BodyConnector)4 WayPoint (artisynth.core.probes.WayPoint)4 Point3d (maspack.matrix.Point3d)4 MultiPointSpring (artisynth.core.mechmodels.MultiPointSpring)3 PlanarConnector (artisynth.core.mechmodels.PlanarConnector)3 FemElement3d (artisynth.core.femmodels.FemElement3d)2