use of artisynth.core.mechmodels.MechModel in project artisynth_core by artisynth.
the class FemEmbeddedSphere method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
mech = new MechModel("mech");
addModel(mech);
fem = new FemModel3d("fem");
mech.addModel(fem);
// Build hex beam and set properties
double[] size = { 0.4, 0.4, 0.4 };
int[] res = { 4, 4, 4 };
FemFactory.createHexGrid(fem, size[0], size[1], size[2], res[0], res[1], res[2]);
fem.setParticleDamping(2);
fem.setDensity(10);
fem.setMaterial(new LinearMaterial(4000, 0.33));
// Add an embedded sphere mesh
PolygonalMesh sphereSurface = MeshFactory.createOctahedralSphere(0.15, 3);
sphere = fem.addMesh("sphere", sphereSurface);
sphere.setCollidable(Collidability.EXTERNAL);
// Boundary condition: fixed LHS
for (FemNode3d node : fem.getNodes()) {
if (node.getPosition().x < -0.49) {
node.setDynamic(false);
}
}
// Set rendering properties
setFemRenderProps(fem);
setMeshRenderProps(sphere);
}
use of artisynth.core.mechmodels.MechModel in project artisynth_core by artisynth.
the class FrameBodyAttachment method build.
public void build(String[] args) {
// create MechModel and add to RootModel
mech = new MechModel("mech");
mech.setGravity(0, 0, -98);
mech.setFrameDamping(1.0);
mech.setRotaryDamping(4.0);
addModel(mech);
// bodies will be defined using a mesh
PolygonalMesh mesh;
// create bodyB and set its pose
mesh = MeshFactory.createRoundedBox(lenx1, leny1, lenz1, /*nslices=*/
8);
RigidTransform3d TMB = new RigidTransform3d(0, 0, 0, /*axisAng=*/
1, 1, 1, 2 * Math.PI / 3);
mesh.transform(TMB);
bodyB = RigidBody.createFromMesh("bodyB", mesh, /*density=*/
0.2, 1.0);
bodyB.setPose(new RigidTransform3d(0, 0, 1.5 * lenx1, 1, 0, 0, Math.PI / 2));
// create bodyA and set its pose
mesh = MeshFactory.createRoundedCylinder(leny2 / 2, lenx2, /*nslices=*/
16, /*nsegs=*/
1, /*flatBottom=*/
false);
mesh.transform(TMB);
bodyA = RigidBody.createFromMesh("bodyA", mesh, 0.2, 1.0);
bodyA.setPose(new RigidTransform3d((lenx1 + leny2) / 2, 0, 1.5 * lenx1, 0, Math.PI / 2, 0));
// create the joint
RigidTransform3d TDW = new RigidTransform3d(-lenx1 / 2, 0, 1.5 * lenx1, 1, 0, 0, Math.PI / 2);
RevoluteJoint joint = new RevoluteJoint(bodyB, TDW);
// add components to the mech model
mech.addRigidBody(bodyB);
mech.addRigidBody(bodyA);
mech.addBodyConnector(joint);
// set render properties for components
RenderProps.setLineRadius(joint, 0.2);
joint.setAxisLength(4);
// now connect bodyA to bodyB using a FrameAttachment
mech.attachFrame(bodyA, bodyB);
// create an auxiliary frame and add it to the mech model
Frame frame = new Frame();
mech.addFrame(frame);
// set the frames axis length > 0 so we can see it
frame.setAxisLength(4.0);
// set the attached frame's pose to that of bodyA ...
RigidTransform3d TFW = new RigidTransform3d(bodyA.getPose());
// ... plus a translation of lenx2/2 along the x axis:
TFW.mulXyz(lenx2 / 2, 0, 0);
// finally, attach the frame to bodyA
mech.attachFrame(frame, bodyA, TFW);
}
use of artisynth.core.mechmodels.MechModel in project artisynth_core by artisynth.
the class MultiSpringTest method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
MechModel mech = new MechModel("mech");
addModel(mech);
// addSprings(mech);
// addMixedUpSprings(mech);
// addSeparatedSprings(mech);
// addSpringMesh(mech);
addVerticalSprings(mech);
// clear render props
for (AxialSpring s : mech.axialSprings()) {
s.setRenderProps(null);
}
RenderProps.setLineStyle(mech, LineStyle.CYLINDER);
RenderProps.setLineRadius(mech, 0.02);
}
use of artisynth.core.mechmodels.MechModel in project artisynth_core by artisynth.
the class SpecularTest method build.
public void build(String[] args) {
MechModel mech = new MechModel("mech");
addModel(mech);
RenderProps.setShininess(mech, 128);
RenderProps.setFaceStyle(mech, FaceStyle.FRONT_AND_BACK);
RenderProps.setFaceColor(mech, Color.GRAY.darker().darker());
RenderProps.setSpecular(mech, Color.WHITE);
// mech.getRenderProps().setColorMap (createTextureProps());
// mech.getRenderProps().setNormalMap (createNormalProps());
// mech.getRenderProps().setBumpMap (createBumpProps());
FixedMeshBody body0 = createMesh(mech, 0);
// FixedMeshBody body1 = createMesh (mech, 2);
}
use of artisynth.core.mechmodels.MechModel in project artisynth_core by artisynth.
the class FemBeam method build.
public void build(String[] args) throws IOException {
// Create and add MechModel
mech = new MechModel("mech");
addModel(mech);
// Create and add FemModel
fem = new FemModel3d("fem");
mech.add(fem);
// Build hex beam using factory method
FemFactory.createHexGrid(fem, length, width, width, /*nx=*/
6, /*ny=*/
3, /*nz=*/
3);
// Set FEM properties
fem.setDensity(density);
fem.setParticleDamping(0.1);
fem.setMaterial(new LinearMaterial(4000, 0.33));
// Fix left-hand nodes for boundary condition
for (FemNode3d n : fem.getNodes()) {
if (n.getPosition().x <= -length / 2 + EPS) {
n.setDynamic(false);
}
}
// Set rendering properties
setRenderProps(fem);
}
Aggregations