use of artisynth.core.mechmodels.CollisionManager 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));
}
Aggregations