use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class DicomViewer method render.
@Override
public synchronized void render(Renderer renderer, int flags) {
RenderProps rprops = getRenderProps();
renderer.pushModelMatrix();
renderer.setModelMatrix(myRenderTransform);
if (drawBox) {
// draw box
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setLineColoring(rprops, isSelected());
renderer.drawLines(robj, 0);
renderer.setShading(savedShading);
}
ColorMapProps oldColorMap = renderer.setColorMap(rprops.getColorMap());
FaceStyle oldFaceStyle = renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
Shading oldShading = renderer.setShading(rprops.getShading());
if (!renderer.isSelecting()) {
renderer.setFaceColoring(rprops, isSelected());
}
for (int i = 0; i < 3; i++) {
if (drawSlice[i]) {
renderer.drawTriangles(robj, i);
}
}
renderer.setShading(oldShading);
renderer.setFaceStyle(oldFaceStyle);
renderer.setColorMap(oldColorMap);
renderer.popModelMatrix();
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemDisplayProbe method computeClippedVertexColors.
// if we are clipped to the FEM, then the shape function values are fixed
private void computeClippedVertexColors() {
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
Color faceColor = rprops.getFaceColor();
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()) {
switch(mySurfaceRendering) {
case None:
setColor(vtx, faceColor, alpha);
break;
case Strain:
stressVal = getStrainValue(clippedVtxMap.get(vtx));
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
break;
case Stress:
stressVal = getStressValue(clippedVtxMap.get(vtx));
myColorMap.getRGB(stressVal / myStressPlotRange.getRange(), carray);
setColor(vtx, carray[0], carray[1], carray[2], alpha);
break;
default:
setColor(vtx, femFaceColor, alpha);
}
}
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class MeshCollisionViewer method createRenderProps.
private RenderProps createRenderProps(PolygonalMesh mesh) {
RenderProps props = mesh.createRenderProps();
props.setShading(smooth.value ? Shading.SMOOTH : Shading.FLAT);
if (noDrawFaces.value) {
props.setFaceStyle(FaceStyle.NONE);
} else if (oneSided.value) {
props.setFaceStyle(FaceStyle.FRONT);
} else {
props.setFaceStyle(FaceStyle.FRONT_AND_BACK);
}
props.setDrawEdges(drawEdges.value);
if (edgeColor[0] != -1) {
props.setLineColor(new Color(edgeColor[0], edgeColor[1], edgeColor[2]));
}
Color gold = new Color(0.93f, 0.8f, 0.063f);
Color gray = new Color(0.5f, 0.5f, 0.5f);
props.setFaceColor(gray);
props.setAlpha(0.5);
// props.setBackColor (gray);
return props;
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class MeshViewer method createRenderProps.
private RenderProps createRenderProps(MeshBase mesh) {
RenderProps props = mesh.createRenderProps();
props.setShading(smooth.value ? Shading.SMOOTH : Shading.FLAT);
if (noDrawFaces.value) {
props.setFaceStyle(FaceStyle.NONE);
} else if (oneSided.value) {
props.setFaceStyle(FaceStyle.FRONT);
} else {
props.setFaceStyle(FaceStyle.FRONT_AND_BACK);
}
props.setDrawEdges(drawEdges.value);
if (edgeColor[0] != -1) {
props.setLineColor(new Color(edgeColor[0], edgeColor[1], edgeColor[2]));
}
Color gold = new Color(0.93f, 0.8f, 0.063f);
Color gray = new Color(0.5f, 0.5f, 0.5f);
props.setFaceColor(gray);
props.setBackColor(gray);
return props;
}
use of maspack.render.RenderProps in project artisynth_core by artisynth.
the class FemMeshComp method updateVertexColors.
protected void updateVertexColors() {
if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
return;
}
if (myStressPlotRanging == Ranging.Auto) {
myStressPlotRange.merge(myFem.getNodalPlotRange(mySurfaceRendering));
}
RenderProps rprops = getRenderProps();
float alpha = (float) rprops.getAlpha();
MeshBase mesh = getMesh();
double sval = 0;
for (int i = 0; i < myVertexAttachments.size(); i++) {
PointAttachment attacher = myVertexAttachments.get(i);
sval = 0;
if (attacher instanceof PointFem3dAttachment) {
PointFem3dAttachment pfa = (PointFem3dAttachment) attacher;
FemNode[] nodes = pfa.getNodes();
VectorNd weights = pfa.getCoordinates();
for (int j = 0; j < nodes.length; j++) {
if (nodes[j] instanceof FemNode3d) {
// paranoid!
FemNode3d node = (FemNode3d) nodes[j];
double w = weights.get(j);
if (mySurfaceRendering == SurfaceRender.Strain) {
sval += w * node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval += w * node.getVonMisesStress();
}
}
}
} else if (attacher instanceof PointParticleAttachment) {
PointParticleAttachment ppa = (PointParticleAttachment) attacher;
FemNode3d node = (FemNode3d) ppa.getParticle();
if (mySurfaceRendering == SurfaceRender.Strain) {
sval = node.getVonMisesStrain();
} else if (mySurfaceRendering == SurfaceRender.Stress) {
sval = node.getVonMisesStress();
}
}
double smin = myStressPlotRange.getLowerBound();
double srng = myStressPlotRange.getRange();
double c = (sval - smin) / srng;
c = Math.max(0, Math.min(c, 1.0));
myColorMap.getRGB(c, colorArray);
mesh.setColor(i, colorArray[0], colorArray[1], colorArray[2], alpha);
}
}
Aggregations