use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class DoubleArmDemo method addBody.
public void addBody(String name, RigidTransform3d pose, String meshName) {
// add a simple rigid body to the simulation
RigidBody rb = new RigidBody();
rb.setName(name);
rb.setPose(pose);
model.addRigidBody(rb);
PolygonalMesh mesh;
try {
String meshFilename = ArtisynthPath.getHomeRelativePath("src/artisynth/demos/mech/geometry/", ".") + meshName;
mesh = new PolygonalMesh();
mesh.read(new BufferedReader(new FileReader(new File(meshFilename))));
rb.setMesh(mesh, meshFilename);
} catch (IOException e) {
System.out.println(e.getMessage());
mesh = MeshFactory.createBox(size.x, size.y, size.z);
rb.setMesh(mesh, null);
}
rb.setInertia(SpatialInertia.createBoxInertia(10.0, size.x, size.y, size.z));
RenderProps rp = new RenderProps(model.getRenderProps());
rp.setFaceColor(Color.GRAY);
rp.setShading(Renderer.Shading.FLAT);
rb.setRenderProps(rp);
rb.setFrameDamping(10);
rb.setRotaryDamping(1000.0);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class MuscleArm method addBody.
public void addBody(String name, RigidTransform3d pose, String meshName) {
// add a simple rigid body to the simulation
RigidBody rb = new RigidBody();
rb.setName(name);
rb.setPose(pose);
model.addRigidBody(rb);
PolygonalMesh mesh;
try {
String meshFilename = meshDir + meshName;
mesh = new PolygonalMesh();
mesh.read(new BufferedReader(new FileReader(new File(meshFilename))));
rb.setMesh(mesh, meshFilename);
} catch (IOException e) {
System.out.println(e.getMessage());
mesh = MeshFactory.createBox(size.x, size.y, size.z);
rb.setMesh(mesh, null);
}
rb.setInertia(SpatialInertia.createBoxInertia(10.0, size.x, size.y, size.z));
RenderProps rp = new RenderProps(model.getRenderProps());
rp.setFaceColor(Color.GRAY);
rp.setShading(Renderer.Shading.FLAT);
rb.setRenderProps(rp);
rb.setFrameDamping(10);
rb.setRotaryDamping(10000.0);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class MultiGL3Tester method addRenderObjects.
protected static void addRenderObjects(MultiViewer tester) {
addCube(tester);
addAxes(tester);
addTransRotator(tester);
addCylinder(tester);
PolygonalMesh bunny = loadStanfordBunny();
addStanfordBunnies(tester, bunny);
addSolidBunny(tester, bunny);
addHalfBunny(tester, bunny);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class TextureHeartTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
JFrame frame = new JFrame();
JPanel controls = new JPanel();
frame.add(controls);
String heartObjFilename = PathFinder.findSourceDir(this) + "/data/heart/HumanHeart.obj";
WavefrontReader reader = null;
try {
reader = new WavefrontReader(new File(heartObjFilename));
PolygonalMesh mesh = reader.readMesh();
RenderProps rprops = mesh.getRenderProps();
if (rprops == null) {
rprops = new RenderProps();
}
rprops.setShading(Shading.SMOOTH);
rprops.setFaceColor(new Color(0.8f, 0.8f, 0.8f));
rprops.getColorMap().setColorMixing(ColorMixing.MODULATE);
rprops.setSpecular(new Color(0.4f, 0.4f, 0.4f));
rprops.getBumpMap().setScaling(0.5f);
rprops.setShininess(128);
// mesh.setRenderProps(rprops);
// FixedMeshBody fm = new FixedMeshBody (mesh);
// fm.setRenderProps (mesh.getRenderProps ());
// RenderProps rprops = mesh.getRenderProps();
LabeledComponentBase base = PropertyWidget.create("Map", rprops.getColorMap(), "enabled");
controls.add(base);
base = PropertyWidget.create("Bump map", rprops.getBumpMap(), "enabled");
controls.add(base);
base = PropertyWidget.create("Lighting", rprops, "shading");
controls.add(base);
base = PropertyWidget.create("Specular", rprops.getColorMap(), "specularColoring");
controls.add(base);
base = PropertyWidget.create("Bump map scale", rprops.getBumpMap(), "scaling");
controls.add(base);
mv.addRenderable(mesh);
} catch (IOException e) {
e.printStackTrace();
}
if (reader != null) {
reader.close();
}
mv.autoFitViewers();
frame.pack();
frame.setVisible(true);
}
use of maspack.geometry.PolygonalMesh in project artisynth_core by artisynth.
the class GL2vsGL3Tester method addContent.
@Override
protected void addContent(MultiViewer mv) {
addCube(mv);
addAxes(mv);
addTransRotator(mv);
addCylinder(mv);
PolygonalMesh bunny = loadStanfordBunny();
addStanfordBunnies(mv, bunny);
addSolidBunny(mv, bunny);
addHalfBunny(mv, bunny);
mv.autoFitViewers();
}
Aggregations