use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.
the class PenetrationRendererDemo method build.
public void build(String[] args) {
// create MechModel and add to RootModel
MechModel mech = new MechModel("mech");
addModel(mech);
// create and add the ball and plate
RigidBody ball = RigidBody.createIcosahedralSphere("ball", 0.8, 0.1, 1);
// ball.setPose (new RigidTransform3d (0, 0, 2, 0.4, 0.1, 0.1));
ball.setPose(new RigidTransform3d(0, 0, 0, 0.4, 0.1, 0.1));
ball.setDynamic(false);
mech.addRigidBody(ball);
RigidBody plate = RigidBody.createBox("plate", 5, 5, 5, 1);
plate.setPose(new RigidTransform3d(0, 0, 2.94, 1, 0, 0, 0));
plate.setDynamic(false);
mech.addRigidBody(plate);
// turn on collisions
mech.setDefaultCollisionBehavior(true, 0.20);
// make ball transparent so that contacts can be seen more clearly
RenderProps.setFaceStyle(ball, Renderer.FaceStyle.NONE);
RenderProps.setDrawEdges(ball, true);
RenderProps.setEdgeColor(ball, Color.WHITE);
RenderProps.setVisible(plate, false);
RenderProps.setAlpha(plate, 0.5);
// enable rendering of contacts normals and contours
CollisionManager cm = mech.getCollisionManager();
RenderProps.setVisible(cm, true);
RenderProps.setLineWidth(cm, 3);
RenderProps.setLineColor(cm, Color.RED);
RenderProps.setEdgeWidth(cm, 3);
RenderProps.setEdgeColor(cm, Color.BLUE);
cm.setContactNormalLen(0.5);
cm.setDrawContactNormals(true);
cm.setDrawIntersectionContours(true);
cm.setDrawIntersectionFaces(true);
cm.setDrawIntersectionPoints(true);
CollisionResponse resp = mech.setCollisionResponse(ball, plate);
addMonitor(new PenetrationRenderer(resp));
}
use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.
the class FrameMarkerEditor method applyAction.
public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
if (containsSingleSelection(selection, FrameMarker.class)) {
if (actionCommand == "Add PlanarConnector") {
FrameMarker mkr = (FrameMarker) selection.get(0);
RigidTransform3d XPW = new RigidTransform3d();
XPW.p.set(mkr.getPosition());
if (mkr.getFrame() instanceof RigidBody && mkr.getGrandParent() instanceof MechModel) {
PlanarConnector pc = new PlanarConnector();
pc.set((RigidBody) mkr.getFrame(), mkr.getLocation(), Vector3d.Z_UNIT);
pc.setPlaneSize(getDefaultPlaneSize());
((MechModel) mkr.getGrandParent()).addBodyConnector(pc);
} else {
System.out.println("Unable to create PlanarConnector from selected FrameMarker");
}
}
}
}
use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.
the class RigidBodyEditor method addActions.
public void addActions(EditActionMap actions, SelectionManager selManager) {
LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
if (containsMultipleSelection(selection, RigidBody.class)) {
actions.add(this, "Select markers");
if (containsSingleSelection(selection, RigidBody.class)) {
RigidBody body = (RigidBody) selection.get(0);
actions.add(this, "Edit geometry and inertia ...", EXCLUSIVE);
actions.add(this, "Save mesh as ...");
if (body.getGrandParent() instanceof MechModel) {
actions.add(this, "Attach particles ...", EXCLUSIVE);
}
if (body.getSurfaceMesh() != null) {
actions.add(this, "Add mesh inspector");
}
}
}
}
use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.
the class TransverseIsotropy method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
MechModel mech = new MechModel("mech");
addModel(mech);
double h = 0.1;
double r = 0.005;
RigidBody rb = RigidBody.createBox("box", 2 * r, 2 * r, 2 * r, 100, true);
mech.addRigidBody(rb);
rb.transformGeometry(new RigidTransform3d(new Vector3d(0, 0, -h / 2 - r), AxisAngle.IDENTITY));
FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
fem.setDensity(1000);
mech.addModel(fem);
TransverseLinearMaterial mat = new TransverseLinearMaterial();
mat.setYoungsModulus(50000, 50000);
mat.setPoissonsRatio(0.45, 0.45);
double G = 50000 / (2 * (1 + 0.45));
mat.setShearModulus(G);
fem.setMaterial(mat);
fem.setName("fem");
fem.setSurfaceRendering(SurfaceRender.Shaded);
RenderProps.setFaceColor(fem, Color.ORANGE);
RenderProps.setVisible(fem.getElements(), false);
double eps = 1e-10;
for (FemNode3d node : fem.getNodes()) {
if (node.getPosition().z > h / 2 - eps) {
node.setDynamic(false);
} else if (node.getPosition().z < -h / 2 + eps) {
PointAttachment pa = rb.createPointAttachment(node);
mech.addAttachment(pa);
}
}
}
use of artisynth.core.mechmodels.RigidBody in project artisynth_core by artisynth.
the class FemSurfaceTargetDemo method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
mech = new MechModel("mech");
mech.setGravity(Vector3d.ZERO);
addModel(mech);
fem = new FemMuscleModel("fem");
fem.setStiffnessDamping(0.1);
mech.addModel(fem);
// boundary conditions
FemFactory.createHexGrid(fem, l, w, w, nl, nw, nw);
for (FemNode n : fem.getNodes()) {
if (n.getPosition().x > l / 2 - eps) {
n.setDynamic(false);
}
}
// muscles
addMuscle("vert", Color.RED, Vector3d.Z_UNIT);
addMuscle("trans", Color.BLUE, Vector3d.Y_UNIT);
body = new RigidBody("plate");
body.setMesh(MeshFactory.createBox(l, l, l / 10));
body.setPose(new RigidTransform3d(-1.2 * w - l / 20, 0, 0, 0, 1, 0, Math.PI / 2));
body.setDynamic(false);
mech.addRigidBody(body);
mech.setCollisionBehavior(body, fem, true);
addTrackingController();
setupRenderProps();
}
Aggregations