use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class TextureEgyptianTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
JFrame frame = new JFrame();
JPanel controls = new JPanel();
frame.add(controls);
PolygonalMesh plane = MeshFactory.createRectangle(4000, 400, 32, 8, /*texture=*/
true);
RenderProps rprops = plane.getRenderProps();
if (rprops == null) {
rprops = new RenderProps();
}
rprops.setShading(Shading.SMOOTH);
rprops.setShininess(20);
rprops.setFaceColor(new Color(155, 196, 30));
rprops.setSpecular(new Color(255, 113, 0));
rprops.setFaceStyle(FaceStyle.FRONT_AND_BACK);
plane.transform(new RigidTransform3d(Vector3d.ZERO, AxisAngle.ROT_X_90));
String srcDir = PathFinder.findSourceDir(this);
ColorMapProps dprops = new ColorMapProps();
dprops.setFileName(srcDir + "/data/specular_map.jpg");
dprops.setColorMixing(ColorMixing.MODULATE);
dprops.setEnabled(true);
NormalMapProps normalProps = new NormalMapProps();
normalProps.setFileName(srcDir + "/data/foil_normal_map2.png");
normalProps.setScaling(0.3f);
normalProps.setEnabled(true);
BumpMapProps bumpProps = new BumpMapProps();
bumpProps.setFileName(srcDir + "/data/egyptian_friz_2.png");
bumpProps.setScaling(2.5f);
bumpProps.setEnabled(true);
rprops.setColorMap(dprops);
rprops.setNormalMap(normalProps);
rprops.setBumpMap(bumpProps);
// FixedMeshBody fm = new FixedMeshBody(plane);
// fm.setRenderProps(rprops);
mv.addRenderable(plane);
if (false) {
mv.addRenderable(new IsRenderable() {
@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) {
renderer.setColor(Color.CYAN);
renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
renderer.drawSphere(Point3d.ZERO, 1);
}
@Override
public void prerender(RenderList list) {
// TODO Auto-generated method stub
}
@Override
public int getRenderHints() {
// TODO Auto-generated method stub
return 0;
}
});
}
mv.autoFitViewers();
LabeledComponentBase base = PropertyWidget.create("Color texture", rprops.getColorMap(), "enabled");
controls.add(base);
base = PropertyWidget.create("Normal map", rprops.getNormalMap(), "enabled");
controls.add(base);
base = PropertyWidget.create("Bump map", rprops.getBumpMap(), "enabled");
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);
base = PropertyWidget.create("Normal map scale", rprops.getNormalMap(), "scaling");
controls.add(base);
frame.pack();
frame.setVisible(true);
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemMuscleModel method render.
// public void setDrawFibers(boolean enable) {
// myDrawFibers = enable;
// }
public void render(Renderer renderer, int flags) {
super.render(renderer, flags);
// if (myFiberMesh != null) {
// myFiberMesh.render(renderer, myRenderProps, /* flags= */0);
// }
// if (myDrawFibers) {
RenderProps fiberRenderProps = myFiberRenderProps;
if (fiberRenderProps == null) {
fiberRenderProps = DEFAULT_FIBER_RENDER_PROPS;
}
double dirLen = getDirectionRenderLen();
if (dirLen > 0) {
Matrix3d F = new Matrix3d();
Vector3d dir = new Vector3d();
float[] coords0 = new float[3];
float[] coords1 = new float[3];
for (FemElement3d e : getElements()) {
renderDirection(renderer, fiberRenderProps, e, coords0, coords1, F, dir, dirLen);
}
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemMuscleModel method createDefaultFiberRenderProps.
private static RenderProps createDefaultFiberRenderProps() {
if (DEFAULT_FIBER_RENDER_PROPS == null) {
RenderProps props = new RenderProps();
props.setLineColor(new Color(0f, 1f, 1f));
props.setLineStyle(LineStyle.LINE);
DEFAULT_FIBER_RENDER_PROPS = props;
}
return DEFAULT_FIBER_RENDER_PROPS;
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class MuscleElementDescList method render.
public void render(Renderer renderer, int flags) {
RenderProps props = myRenderProps;
if (renderer.isSelecting()) {
for (int i = 0; i < size(); i++) {
MuscleElementDesc desc = get(i);
if (desc.getRenderProps() == null && renderer.isSelectable(desc)) {
renderer.beginSelectionQuery(i);
desc.render(renderer, myRenderProps, flags);
renderer.endSelectionQuery();
}
}
} else {
dorender(renderer, flags, /*selected=*/
true);
dorender(renderer, flags, /*selected=*/
false);
RenderObject r = myWidgetRob;
if (r != null) {
drawWidgets(renderer, r, props, SEL_GRP);
drawWidgets(renderer, r, props, REG_GRP);
}
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class AuxMaterialElementDescList method render.
public void render(Renderer renderer, int flags) {
RenderProps props = myRenderProps;
if (renderer.isSelecting()) {
for (int i = 0; i < size(); i++) {
AuxMaterialElementDesc desc = get(i);
if (desc.getRenderProps() == null && renderer.isSelectable(desc)) {
renderer.beginSelectionQuery(i);
desc.render(renderer, myRenderProps, flags);
renderer.endSelectionQuery();
}
}
} else {
dorender(renderer, flags, /*selected=*/
true);
dorender(renderer, flags, /*selected=*/
false);
RenderObject r = myWidgetRob;
if (r != null) {
drawWidgets(renderer, r, props, SEL_GRP);
drawWidgets(renderer, r, props, REG_GRP);
}
}
}
Aggregations