use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class PlanarConnector method defaultRenderProps.
protected static RenderProps defaultRenderProps(HasProperties host) {
RenderProps props = RenderProps.createFaceProps(null);
props.setFaceStyle(Renderer.FaceStyle.FRONT_AND_BACK);
return props;
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class Muscle method prerender.
@Override
public void prerender(RenderList list) {
RenderProps props = myRenderProps;
if (props == null) {
if (getParent() instanceof Renderable) {
props = ((Renderable) getParent()).getRenderProps();
}
}
if (props != null && myExcitationColor != null) {
if (myRenderColor == null) {
myRenderColor = new float[3];
}
float[] baseColor = props.getLineColorF();
double s = Math.min(getNetExcitation() / getMaxColoredExcitation(), 1);
ColorUtils.interpolateColor(myRenderColor, baseColor, myExcitationColor, s);
} else {
myRenderColor = null;
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemDisplayProbe method updateVertexColoringRest.
/**
* Updates vertex colors
*/
protected void updateVertexColoringRest() {
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
Color faceColor = rprops.getFaceColor();
float backAlpha = (float) myBackgroundAlpha * alpha;
Color femFaceColor = null;
double stressVal = 0;
if (mySurfaceRendering == SurfaceRender.Stress || mySurfaceRendering == SurfaceRender.Strain) {
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
}
} else {
femFaceColor = myFem.getRenderProps().getFaceColor();
}
float[] carray = new float[3];
// use our stored map of values
for (Vertex3d vtx : myPlaneSurface.getVertices()) {
if (!vtxIndicatorMap.containsKey(vtx) || !vtxIndicatorMap.get(vtx)) {
setColor(vtx, faceColor, backAlpha);
} else {
VtxInfo vtxInfo;
switch(mySurfaceRendering) {
case None:
setColor(vtx, faceColor, alpha);
break;
case Strain:
vtxInfo = clippedVtxMap.get(vtx);
if (vtxInfo != null) {
stressVal = getStrainValue(vtxInfo);
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
} else {
setColor(vtx, femFaceColor, backAlpha);
}
break;
case Stress:
vtxInfo = clippedVtxMap.get(vtx);
if (vtxInfo != null) {
stressVal = getStressValue(clippedVtxMap.get(vtx));
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
} else {
setColor(vtx, femFaceColor, backAlpha);
}
break;
default:
setColor(vtx, femFaceColor, alpha);
}
}
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemDisplayProbe method updateVertexColoringDynamic.
/**
* Updates vertex colors
*/
protected void updateVertexColoringDynamic() {
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
float backAlpha = (float) myBackgroundAlpha * alpha;
Color faceColor = rprops.getFaceColor();
Color femFaceColor = null;
double stressVal = 0;
float[] carray = new float[3];
if (myFem != null) {
if (mySurfaceRendering == SurfaceRender.Stress || mySurfaceRendering == SurfaceRender.Strain) {
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
}
} else {
femFaceColor = myFem.getRenderProps().getFaceColor();
}
} else {
// arbitrary, shouldn't be used
femFaceColor = Color.BLACK;
}
// do with some kind of synchronization
try {
for (Vertex3d vtx : myPlaneSurface.getVertices()) {
if (!vtxIndicatorMap.containsKey(vtx) || !vtxIndicatorMap.get(vtx)) {
setColor(vtx, faceColor, backAlpha);
} else {
switch(mySurfaceRendering) {
case None:
setColor(vtx, faceColor, alpha);
break;
case Strain:
stressVal = getStrainValue(vtx.getWorldPoint(), myFem);
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
break;
case Stress:
stressVal = getStressValue(vtx.getWorldPoint(), myFem);
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
break;
default:
setColor(vtx, femFaceColor, alpha);
}
}
}
} catch (Exception e) {
System.err.println("Error in display probe: " + e.getMessage());
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class PointTracingProbe method initRenderProps.
private void initRenderProps(ModelComponent comp) {
RenderProps newProps = createRenderProps();
if (comp instanceof HasRenderProps) {
HasRenderProps rcomp = (HasRenderProps) comp;
RenderProps compProps = rcomp.getRenderProps();
if (compProps == null) {
compProps = rcomp.createRenderProps();
}
newProps.set(compProps);
// line and point colors of render props to match
if (compProps.getPointColorMode() == PropertyMode.Explicit) {
float[] pointColor = compProps.getPointColorF();
newProps.setPointColor(pointColor);
newProps.setLineColor(pointColor);
}
}
newProps.setLineWidth(3);
setRenderProps(newProps);
}
Aggregations