use of artisynth.core.femmodels.SkinMeshBody in project artisynth_core by artisynth.
the class FemSkinDemo method build.
public void build(String[] args) {
myMech = new MechModel("mech");
RenderProps.setPointStyle(myMech, Renderer.PointStyle.SPHERE);
double midw = 0.6;
FemModel3d femMod1 = createFem("fem1", midw, 0.2, 0.2);
FemModel3d femMod2 = createFem("fem2", midw, 0.2, 0.2);
// fix the leftmost nodes
LinkedList<FemNode3d> leftNodes1 = getLeftNodes(femMod1);
LinkedList<FemNode3d> rightNodes1 = getRightNodes(femMod1);
LinkedList<FemNode3d> leftNodes2 = getLeftNodes(femMod2);
LinkedList<FemNode3d> rightNodes2 = getRightNodes(femMod2);
RigidTransform3d X = new RigidTransform3d();
double wx = 0.1;
double wy = 0.3;
double wz = 0.3;
double transx = wx / 2 + 1.5 * midw;
RigidBody leftBody = createBlock("leftBlock", wx, wy, wz);
leftBody.setPose(new RigidTransform3d(-transx, 0, 0));
RigidTransform3d TCW = new RigidTransform3d();
TCW.p.set(-transx - wx / 2, 0, wz / 2);
TCW.R.mulAxisAngle(1, 0, 0, Math.PI / 2);
RevoluteJoint joint = new RevoluteJoint(leftBody, TCW);
RenderProps.setLineRadius(joint, 0.01);
joint.setAxisLength(0.4);
myMech.addBodyConnector(joint);
RigidBody middleBody = createBlock("middleBlock", midw, 0.21, 0.21);
RigidBody rightBody = createBlock("rightBlock", wx, wy, wz);
rightBody.setPose(new RigidTransform3d(transx, 0, 0));
TCW.p.set(transx + wx / 2, 0, wz / 2);
TCW.R.setAxisAngle(1, 0, 0, Math.PI / 2);
joint = new RevoluteJoint(rightBody, TCW);
RenderProps.setLineRadius(joint, 0.01);
joint.setAxisLength(0.4);
myMech.addBodyConnector(joint);
femMod1.transformGeometry(new RigidTransform3d(-midw, 0, 0));
femMod2.transformGeometry(new RigidTransform3d(midw, 0, 0));
for (FemNode3d n : leftNodes1) {
myMech.attachPoint(n, leftBody);
}
for (FemNode3d n : rightNodes1) {
myMech.attachPoint(n, middleBody);
}
for (FemNode3d n : leftNodes2) {
myMech.attachPoint(n, middleBody);
}
for (FemNode3d n : rightNodes2) {
myMech.attachPoint(n, rightBody);
}
PolygonalMesh mesh = MeshFactory.createRoundedCylinder(/*r=*/
0.3, /*h=*/
1.8, /*nsclices=*/
12, /*nsegs=*/
10, /*flatbotton=*/
false);
// flip aout y axis
mesh.transform(new RigidTransform3d(0, 0, 0, 0, Math.PI / 2, 0));
SkinMeshBody skinBody = new SkinMeshBody(mesh);
skinBody.addFrame(rightBody);
skinBody.addFrame(middleBody);
skinBody.addFrame(leftBody);
skinBody.addFemModel(femMod1);
skinBody.addFemModel(femMod2);
skinBody.computeWeights();
skinBody.setName("skin");
RenderProps.setDrawEdges(skinBody, true);
RenderProps.setFaceStyle(skinBody, Renderer.FaceStyle.NONE);
myMech.addMeshBody(skinBody);
addModel(myMech);
}
use of artisynth.core.femmodels.SkinMeshBody in project artisynth_core by artisynth.
the class SkinDemo method addFiberMesh.
public void addFiberMesh() {
PolylineMesh mesh = MeshFactory.createSphericalPolyline(8.0, 12, 12);
mesh.scale(1, 1, 2.5);
mesh.transform(new RigidTransform3d(-6, 0, 0, 0, Math.toRadians(22.5), 0));
SkinMeshBody fiberMesh = new SkinMeshBody(mesh);
fiberMesh.addFrame(model.rigidBodies().get(0));
fiberMesh.addFrame(model.rigidBodies().get(1));
fiberMesh.computeWeights();
model.addMeshBody(fiberMesh);
RenderProps.setLineColor(fiberMesh, Color.CYAN);
myFiberMesh = fiberMesh;
}
use of artisynth.core.femmodels.SkinMeshBody in project artisynth_core by artisynth.
the class SkinDemo method addSkinMesh.
public void addSkinMesh() {
PolygonalMesh mesh;
mesh = MeshFactory.createSphere(10.0, 12, 12);
mesh.scale(1, 1, 2.5);
mesh.transform(new RigidTransform3d(-6, 0, 0, 0, Math.toRadians(22.5), 0));
SkinMeshBody skinMesh = new SkinMeshBody(mesh);
skinMesh.addFrame(model.rigidBodies().get(0));
skinMesh.addFrame(model.rigidBodies().get(1));
skinMesh.computeWeights();
model.addMeshBody(skinMesh);
RenderProps.setFaceStyle(skinMesh, Renderer.FaceStyle.NONE);
RenderProps.setDrawEdges(skinMesh, true);
RenderProps.setLineColor(skinMesh, Color.GRAY);
mySkinMesh = skinMesh;
}
Aggregations