use of maspack.render.color.HueColorMap in project artisynth_core by artisynth.
the class ColoredSphereTest method build.
@Override
public void build(String[] args) throws IOException {
super.build(args);
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);
addRenderable(fm);
}
use of maspack.render.color.HueColorMap 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);
}
Aggregations