Search in sources :

Example 1 with ColorBar

use of artisynth.core.renderables.ColorBar in project artisynth_core by artisynth.

the class FemBeamColored method prerender.

@Override
public void prerender(RenderList list) {
    // Synchronize color bar/values in case they are changed
    ColorBar cbar = (ColorBar) (renderables().get("colorBar"));
    cbar.setColorMap(fem.getColorMap());
    DoubleInterval range = fem.getStressPlotRange();
    cbar.updateLabels(range.getLowerBound(), range.getUpperBound());
    super.prerender(list);
}
Also used : DoubleInterval(maspack.util.DoubleInterval) ColorBar(artisynth.core.renderables.ColorBar)

Example 2 with ColorBar

use of artisynth.core.renderables.ColorBar in project artisynth_core by artisynth.

the class FemBeamColored method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    // Show stress on the surface
    fem.setSurfaceRendering(SurfaceRender.Stress);
    fem.setStressPlotRanging(Ranging.Auto);
    // Create a colorbar
    ColorBar cbar = new ColorBar();
    cbar.setName("colorBar");
    // 2 decimal places
    cbar.setNumberFormat("%.2f");
    // Start with range [0,1], 10 ticks
    cbar.populateLabels(0.0, 1.0, 10);
    cbar.setLocation(-100, 0.1, 20, 0.8);
    addRenderable(cbar);
}
Also used : ColorBar(artisynth.core.renderables.ColorBar)

Example 3 with ColorBar

use of artisynth.core.renderables.ColorBar in project artisynth_core by artisynth.

the class PenetrationRender method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // create first body and set its rendering properties
    RigidBody body0 = createHemiBody(mech, "body0", 2, -0.5, false);
    RenderProps.setFaceStyle(body0, FaceStyle.FRONT_AND_BACK);
    RenderProps.setFaceColor(body0, CREAM);
    // create second body and set its pose and rendering properties
    RigidBody body1 = createHemiBody(mech, "body1", 1, 2.0, true);
    body1.setPose(new RigidTransform3d(0, 0, 0.75));
    // set up
    RenderProps.setFaceStyle(body1, FaceStyle.NONE);
    // wireframe
    RenderProps.setShading(body1, Shading.NONE);
    // rendering
    RenderProps.setDrawEdges(body1, true);
    RenderProps.setEdgeColor(body1, GOLD);
    // create and set a collision behavior between body0 and body1, and make
    // collisions INACTIVE since we only care about graphical display
    CollisionBehavior behav = new CollisionBehavior(true, 0);
    behav.setMethod(CollisionBehavior.Method.INACTIVE);
    // show penetration of mesh 0
    behav.setDrawPenetrationDepth(0);
    behav.getPenetrationDepthRange().setUpdating(ScalarRange.Updating.AUTO_FIT);
    mech.setCollisionBehavior(body0, body1, behav);
    CollisionManager cm = mech.getCollisionManager();
    // penetration rendering only works with contour-based collisions
    cm.setColliderType(ColliderType.AJL_CONTOUR);
    // set other rendering properities in the collision manager:
    // enable collision rendering
    RenderProps.setVisible(cm, true);
    // draw contours ...
    cm.setDrawIntersectionContours(true);
    // with a line width of 3
    RenderProps.setEdgeWidth(cm, 3);
    // and a blue color
    RenderProps.setEdgeColor(cm, Color.BLUE);
    // create a custom color map for rendering the penetration depth
    JetColorMap map = new JetColorMap();
    map.setColorArray(new Color[] { // no penetration
    CREAM, createColor(255, 204, 153), createColor(255, 153, 102), createColor(255, 102, 51), createColor(255, 51, 0), // most penetration
    createColor(204, 0, 0) });
    cm.setColorMap(map);
    // create a separate color bar to show depth values associated with the
    // color map
    ColorBar cbar = createColorBar();
    cbar.setColorMap(map);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) JetColorMap(maspack.render.color.JetColorMap) ColorBar(artisynth.core.renderables.ColorBar)

Example 4 with ColorBar

use of artisynth.core.renderables.ColorBar in project artisynth_core by artisynth.

the class PenetrationRender method prerender.

public void prerender(RenderList list) {
    // In prerender, we update the color bar labels based on the updated
    // penetration range stored in the collision behavior.
    // 
    // Object references are obtained by name using 'findComponent'. This is
    // more robust than using class member variables, since the latter will
    // be lost if we save and restore this model from a file.
    ColorBar cbar = (ColorBar) (renderables().get("colorBar"));
    MechModel mech = (MechModel) findComponent("models/mech");
    RigidBody body0 = (RigidBody) mech.findComponent("rigidBodies/body0");
    RigidBody body1 = (RigidBody) mech.findComponent("rigidBodies/body1");
    CollisionBehavior behav = mech.getCollisionBehavior(body0, body1);
    ScalarRange range = behav.getPenetrationDepthRange();
    cbar.updateLabels(0, 1000 * range.getUpperBound());
    // call the regular prerender method
    super.prerender(list);
}
Also used : ColorBar(artisynth.core.renderables.ColorBar) ScalarRange(artisynth.core.util.ScalarRange)

Example 5 with ColorBar

use of artisynth.core.renderables.ColorBar in project artisynth_core by artisynth.

the class PenetrationRender method createColorBar.

// Creates and returns a ColorBar renderable object
public ColorBar createColorBar() {
    ColorBar cbar = new ColorBar();
    cbar.setName("colorBar");
    // 2 decimal places
    cbar.setNumberFormat("%.2f");
    // Start with range [0,1], 10 ticks
    cbar.populateLabels(0.0, 1.0, 10);
    cbar.setLocation(-100, 0.1, 20, 0.8);
    cbar.setTextColor(Color.WHITE);
    // add to root model's renderables
    addRenderable(cbar);
    return cbar;
}
Also used : ColorBar(artisynth.core.renderables.ColorBar)

Aggregations

ColorBar (artisynth.core.renderables.ColorBar)5 ScalarRange (artisynth.core.util.ScalarRange)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1 JetColorMap (maspack.render.color.JetColorMap)1 DoubleInterval (maspack.util.DoubleInterval)1