Search in sources :

Example 36 with MeshBase

use of maspack.geometry.MeshBase in project artisynth_core by artisynth.

the class RigidCompositeBody method updatePosState.

protected void updatePosState() {
    super.updatePosState();
    for (RigidMeshComp mc : myMeshList) {
        MeshBase mesh = mc.getMesh();
        mesh.setMeshToWorld(myState.XFrameToWorld);
    }
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 37 with MeshBase

use of maspack.geometry.MeshBase in project artisynth_core by artisynth.

the class RigidCompositeBody method setInertiaFromDensity.

/**
 * Causes the inertia to be automatically computed from the mesh volume
 * and a given density. If the mesh is currently <code>null</code> then
 * the inertia remains unchanged. Subsequent (non-<code>null</code>) changes
 * to the mesh will cause the inertia to be recomputed.
 * The inertia method is set to
 * {@link RigidBody.InertiaMethod#Density Density}.
 *
 * @param density desired uniform density
 */
public void setInertiaFromDensity(double density) {
    if (density < 0) {
        throw new IllegalArgumentException("density must be non-negative");
    }
    myDensity = density;
    myInertiaMethod = InertiaMethod.Density;
    mySpatialInertia.setZero();
    double mass = 0;
    for (RigidMeshComp mc : myMeshList) {
        MeshBase mesh = mc.getMesh();
        if (mesh != null && mc.isPhysical()) {
            mass += getMeshMass(mesh, myDensity);
            addMeshInertia(mesh, myDensity);
        }
    }
    mySpatialInertia.setMass(mass);
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 38 with MeshBase

use of maspack.geometry.MeshBase in project artisynth_core by artisynth.

the class RigidCompositeBody method setMass.

/**
 * Sets the mass for the mesh. If the mesh is currently non-null, then the
 * density (defined as the mass divided by the mesh volume) will be updated
 * accordingly. If the current InertiaMethod is either {@link
 * RigidBody.InertiaMethod#Density Density} or
 * {@link RigidBody.InertiaMethod#Mass Mass}, the
 * other components of the spatial inertia will also be updated.
 *
 * @param mass
 * new mass value
 */
public void setMass(double mass) {
    if (mass < 0) {
        throw new IllegalArgumentException("Mass must be non-negative");
    }
    double volume = 0;
    for (RigidMeshComp mc : myMeshList) {
        MeshBase mesh = mc.getMesh();
        if (mesh != null && mc.isPhysical()) {
            volume += getMeshVolume(mesh);
        }
    }
    if (volume > 0) {
        myDensity = getMass() / volume;
    } else {
        myDensity = 0;
    }
    if (myInertiaMethod == InertiaMethod.Mass) {
        setInertiaFromMass(mass);
    } else if (myInertiaMethod == InertiaMethod.Density) {
        setInertiaFromDensity(myDensity);
    }
    mySpatialInertia.setMass(mass);
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 39 with MeshBase

use of maspack.geometry.MeshBase in project artisynth_core by artisynth.

the class EmbeddedSurface method build.

public void build(String[] args) {
    // NORMAL:
    build("hex", 1.0, 0.5, 4, 2, /*options=*/
    0);
    myMechMod.setGravity(0, 0, -9.8);
    myFemMod.setElementWidgetSize(0);
    myFemMod.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setVisible(myFemMod.getMeshComp("surface"), false);
    RenderProps.setFaceColor(myFemMod, new Color(1f, 153 / 255f, 153 / 255f));
    MeshBase mesh;
    mesh = MeshFactory.createSphere(0.2, 24, 24);
    mesh.scale(2, 1, 1);
    // PolylineMesh lineMesh = new PolylineMesh();
    // lineMesh.addVertex (0.1, 0, 0.3);
    // lineMesh.addVertex (0.2, 0, 0);
    // lineMesh.addVertex (0.1, 0, -0.3);
    // lineMesh.addVertex (-0.1, 0, 0.3);
    // lineMesh.addVertex (-0.2, 0, 0);
    // lineMesh.addVertex (-0.1, 0, -0.3);
    // lineMesh.addLine (new int[] {0, 1, 2});
    // lineMesh.addLine (new int[] {3, 4, 5});
    // mesh = lineMesh;
    myFemMod.addMesh(mesh);
// myFemMod.setMaterial (
// new MooneyRivlinMaterial (50000.0, 0, 0, 0, 0, 5000000.0));
// myFemMod.setIncompressible (FemModel.IncompMethod.AUTO);
}
Also used : Color(java.awt.Color) MeshBase(maspack.geometry.MeshBase)

Aggregations

MeshBase (maspack.geometry.MeshBase)39 PolygonalMesh (maspack.geometry.PolygonalMesh)10 ContactPoint (artisynth.core.mechmodels.ContactPoint)5 Point (artisynth.core.mechmodels.Point)5 SkinMeshBase (artisynth.core.mechmodels.SkinMeshBase)5 FemMeshBase (artisynth.core.femmodels.FemMeshBase)3 Point (java.awt.Point)3 SurfaceRender (artisynth.core.femmodels.FemModel.SurfaceRender)2 PointAttachment (artisynth.core.mechmodels.PointAttachment)2 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)2 Color (java.awt.Color)2 File (java.io.File)2 PointMesh (maspack.geometry.PointMesh)2 Vertex3d (maspack.geometry.Vertex3d)2 XyzbReader (maspack.geometry.io.XyzbReader)2 VectorNd (maspack.matrix.VectorNd)2 RenderProps (maspack.render.RenderProps)2 ArgParser (argparser.ArgParser)1 FemNode (artisynth.core.femmodels.FemNode)1 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)1