use of maspack.render.RenderProps 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.render.RenderProps in project artisynth_core by artisynth.
the class TriangleLightingTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
SimpleSelectable renderable = new SimpleSelectable() {
RenderProps props = new RenderProps();
@Override
public void updateBounds(Vector3d pmin, Vector3d pmax) {
Point3d.X_UNIT.updateBounds(pmin, pmax);
Point3d.Y_UNIT.updateBounds(pmin, pmax);
Point3d.Z_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_X_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_Y_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_Z_UNIT.updateBounds(pmin, pmax);
}
@Override
public void render(Renderer renderer, int flags) {
props.setFaceColor(Color.WHITE);
props.setBackColor(Color.WHITE);
renderer.setFaceColoring(props, /*highlight=*/
false);
renderer.setShading(Shading.SMOOTH);
renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
renderer.setColor(props.getFaceColorF());
renderer.setBackColor(props.getBackColorF());
renderer.drawTriangle(new float[] { 1, 1, 0 }, new float[] { -1, 1, 0 }, new float[] { -1, -1, 0 });
renderer.drawTriangle(new float[] { -1, -1, 0 }, new float[] { 1, -1, 0 }, new float[] { 1, 1, 0 });
renderer.setDepthOffset(1);
renderer.drawAxes(RigidTransform3d.IDENTITY, 1, 1, false);
renderer.setDepthOffset(0);
}
@Override
public void prerender(RenderList list) {
}
@Override
public int getRenderHints() {
return 0;
}
@Override
public int numSelectionQueriesNeeded() {
return 0;
}
@Override
public boolean isSelectable() {
return false;
}
@Override
public void getSelection(LinkedList<Object> list, int qid) {
}
@Override
public void setSelected(boolean set) {
}
@Override
public boolean isSelected() {
// TODO Auto-generated method stub
return false;
}
};
mv.addRenderable(renderable);
mv.setAxialView(AxisAlignedRotation.X_Y);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class VolumePrimitivesTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
SimpleSelectable renderable = new SimpleSelectable() {
RenderProps props = new RenderProps();
@Override
public void updateBounds(Vector3d pmin, Vector3d pmax) {
Point3d.X_UNIT.updateBounds(pmin, pmax);
Point3d.Y_UNIT.updateBounds(pmin, pmax);
Point3d.Z_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_X_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_Y_UNIT.updateBounds(pmin, pmax);
Point3d.NEG_Z_UNIT.updateBounds(pmin, pmax);
}
@Override
public void render(Renderer renderer, int flags) {
props.setFaceColor(Color.CYAN);
props.setBackColor(Color.MAGENTA);
renderer.setFaceColoring(props, /*highlight=*/
false);
renderer.setColor(props.getFaceColorF());
renderer.setBackColor(props.getBackColorF());
renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.3f}, 0.05);
// renderer.drawSpindle (new float[]{-0.1f,-0.2f,-0.3f}, new float[]{-0.3f,-0.2f,-0.1f}, 0.05);
// renderer.drawSpindle (new float[]{0.1f,-0.2f,0.3f}, new float[]{0.3f,-0.2f,0.1f}, 0.25);
// renderer.drawCylinder (new float[]{-0.1f,0.2f,-0.3f}, new float[]{-0.3f,0.2f,-0.1f}, 0.3, true);
// renderer.drawCylinder (new float[]{0.1f,0.2f,-0.3f}, new float[]{-0.3f,-0.2f,-0.3f}, 0.2, true);
// renderer.drawCone (new float[]{-0.1f,0.2f,0.3f}, new float[]{0.3f,0.2f,-0.1f}, 0.1, 0, false);
// renderer.drawCone (new float[]{-0.3f,0.2f,0.3f}, new float[]{0.5f,0.2f,-0.1f}, 0, 0.2, true);
// renderer.drawSphere (new float[]{-0.1f,-0.2f,-0.3f}, 0.2);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.3f}, 0.02);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.6f}, 0.03);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.8f}, 0.04);
// renderer.drawSphere (new float[] {0.1f,0.2f,1f}, 0.05);
// renderer.drawCone (new float[]{0.1f,0.1f,-0.1f}, new float[]{0.3f,0.1f,-0.1f}, 0.05, 0.02, true);
renderer.drawCube(new float[] { -0.2f, -0.2f, -0.2f }, 0.5);
}
@Override
public void prerender(RenderList list) {
}
@Override
public int getRenderHints() {
return 0;
}
@Override
public int numSelectionQueriesNeeded() {
return 0;
}
@Override
public boolean isSelectable() {
return false;
}
@Override
public void getSelection(LinkedList<Object> list, int qid) {
}
@Override
public void setSelected(boolean set) {
}
@Override
public boolean isSelected() {
// TODO Auto-generated method stub
return false;
}
};
mv.addRenderable(renderable);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class ColouredSphereTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
PolygonalMesh mesh = MeshFactory.createOctahedralSphere(1, 4);
HueColorMap map = new HueColorMap();
mesh.setVertexColoringEnabled();
for (int i = 0; i < mesh.numVertices(); ++i) {
// hsv interpolation of colors based on height (-1 to 1)
Vertex3d vtx = mesh.getVertex(i);
double pos = vtx.getPosition().z;
Color c = map.getColor((pos + 1) / 2);
mesh.setColor(i, c);
}
RenderProps rprops = new RenderProps();
rprops.setShading(Shading.SMOOTH);
rprops.setShininess(128);
rprops.setSpecular(Color.WHITE);
mesh.setRenderProps(rprops);
// FixedMeshBody fm = new FixedMeshBody (mesh);
mv.addRenderable(mesh);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class CollisionManager method createRenderProps.
// ===== RenderableComponent methods ======
public RenderProps createRenderProps() {
RenderProps props = RenderProps.createRenderProps(this);
props.setVisible(false);
return props;
}
Aggregations