Search in sources :

Example 16 with MeshBase

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

the class MFreeMeshComp method markSurfaceMesh.

protected void markSurfaceMesh(boolean set) {
    MeshBase mesh = getMesh();
    if (mesh != null && !(mesh instanceof PolygonalMesh)) {
        throw new IllegalArgumentException("Mesh must be a PolygonalMesh to be set as a surface");
    }
    isSurfaceMesh = set;
}
Also used : MeshBase(maspack.geometry.MeshBase) FemMeshBase(artisynth.core.femmodels.FemMeshBase) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 17 with MeshBase

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

the class RigidCompositeBody method setInertiaFromMass.

/**
 * Causes the inertia to be automatically computed from the mesh volume
 * and a given mass (with the density computed by dividing the mass
 * by the mesh volume). If the mesh is currently <code>null</code> the mass
 * of the inertia is updated but the otherwise the inertia and density
 * are left 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#Mass Mass}.
 *
 * @param mass desired body mass
 */
public void setInertiaFromMass(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;
    }
    for (RigidMeshComp mc : myMeshList) {
        MeshBase mesh = mc.getMesh();
        if (mesh != null && mc.isPhysical()) {
            addMeshInertia(mesh, myDensity);
        }
    }
    mySpatialInertia.setMass(mass);
    myInertiaMethod = InertiaMethod.Mass;
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 18 with MeshBase

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

the class RigidCompositeBody method setDensity.

/**
 * Sets the density for the mesh, which is defined at the mass divided
 * by the mesh volume. If the mesh is currently non-null, the mass
 * 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 density
 * new density value
 */
public void setDensity(double density) {
    if (density < 0) {
        throw new IllegalArgumentException("density must be non-negative");
    }
    double mass = 0;
    for (RigidMeshComp mc : myMeshList) {
        MeshBase mesh = mc.getMesh();
        if (mesh != null && mc.isPhysical()) {
            mass += getMeshMass(mesh, density);
        }
    }
    if (myInertiaMethod == InertiaMethod.Mass) {
        setInertiaFromMass(mass);
    } else if (myInertiaMethod == InertiaMethod.Density) {
        setInertiaFromDensity(density);
    }
    myDensity = density;
    mySpatialInertia.setMass(mass);
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 19 with MeshBase

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

the class RigidMeshComp method transformGeometry.

public void transformGeometry(GeometryTransformer gtr, TransformGeometryContext context, int flags) {
    if ((flags & TransformableGeometry.TG_SIMULATING) == 0) {
        myMeshInfo.transformGeometryAndPose(gtr, null);
    } else {
        MeshBase mesh = myMeshInfo.getMesh();
        mesh.setMeshToWorld(getRigidBody().getPose());
    }
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 20 with MeshBase

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

the class VertexComponent method setPosition.

public void setPosition(Point3d pnt) {
    MeshBase mesh = myVertex.getMesh();
    if (mesh == null || mesh.meshToWorldIsIdentity()) {
        myVertex.setPosition(pnt);
    } else {
        Point3d pos = new Point3d(pnt);
        pos.inverseTransform(mesh.XMeshToWorld);
        myVertex.setPosition(pos);
    }
    notifyVertexPositionModified();
}
Also used : Point3d(maspack.matrix.Point3d) 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