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);
}
}
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);
}
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);
}
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);
}
Aggregations