use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class AuxMaterialElementDesc method render.
public void render(Renderer renderer, RenderProps props, int flags) {
double widgetSize = 0;
double rad = 0;
FractionRenderType renderType = AuxMaterialBundle.DEFAULT_FRACTION_RENDER_TYPE;
ModelComponent gparent = getGrandParent();
if (gparent instanceof AuxMaterialBundle) {
AuxMaterialBundle bundle = (AuxMaterialBundle) gparent;
widgetSize = bundle.getElementWidgetSize();
rad = bundle.getFractionRenderRadius();
renderType = bundle.getFractionRenderType();
}
if (widgetSize != 0 || rad > 0) {
Shading savedShading = renderer.setPropsShading(props);
renderer.setFaceColoring(props, myWidgetColor, isSelected());
if (widgetSize != 0) {
myElement.renderWidget(renderer, widgetSize, props);
}
if (rad > 0) {
renderFraction(renderer, props, rad, renderType);
}
renderer.setShading(savedShading);
}
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class FemElement3dList method drawEdges.
protected void drawEdges(Renderer renderer, RenderObject r, FeatureIndexArray lines, RenderProps props, boolean selected) {
if (lines.numFeatures() > 0) {
int width = props.getLineWidth();
if (width > 0) {
float savedWidth = renderer.getLineWidth();
if (renderer.isSelecting()) {
// feature-by-feature
for (int i = 0; i < lines.numFeatures(); ++i) {
renderer.beginSelectionQuery(lines.getFeature(i));
renderer.drawVertices(r, lines.getVertices(), lines.getFeatureOffset(i), lines.getFeatureLength(i), DrawMode.LINES);
renderer.endSelectionQuery();
}
} else {
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setLineColoring(props, selected);
renderer.setLineWidth(width);
renderer.drawVertices(r, lines.getVertices(), DrawMode.LINES);
renderer.setShading(savedShading);
}
renderer.setLineWidth(savedWidth);
}
}
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class ConnectorBoundsRenderer method drawTriangle.
public void drawTriangle(Renderer renderer, TriInfo tri) {
RenderProps props = tri.props;
Shading savedShading = renderer.setPropsShading(props);
renderer.setFaceColoring(props, isSelected());
renderer.setFaceStyle(props.getFaceStyle());
renderer.beginDraw(DrawMode.TRIANGLES);
renderer.setNormal(tri.nrm);
for (int i = 0; i < tri.pts.length; i++) {
renderer.addVertex(tri.pts[i]);
}
renderer.endDraw();
renderer.setShading(savedShading);
renderer.setFaceStyle(FaceStyle.FRONT);
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class CollisionRenderer method render.
public void render(Renderer renderer, CollisionHandler handler, RenderProps props, int flags) {
RenderObject ro = myRob;
if (ro == null) {
// XXX paranoid
return;
}
if (ro.numLines(CONSTRAINT_GRP) > 0) {
ro.lineGroup(CONSTRAINT_GRP);
drawLines(renderer, ro, props);
}
if (ro.numLines(SEGMENT_GRP) > 0) {
ro.lineGroup(SEGMENT_GRP);
drawLines(renderer, ro, props);
}
if (ro.numLines(CONTOUR_GRP) > 0) {
int width = props.getEdgeWidth();
if (width > 0) {
ro.lineGroup(CONTOUR_GRP);
float[] rgb = props.getEdgeColorF();
if (rgb == null) {
rgb = props.getLineColorF();
}
renderer.setColor(rgb, /*highlight=*/
false);
Shading save = renderer.getShading();
renderer.setShading(Shading.NONE);
renderer.drawLines(ro, LineStyle.LINE, width);
renderer.setShading(save);
}
}
if (ro.numPoints() > 0) {
PointStyle style = props.getPointStyle();
double width = 0;
Shading savedShading = null;
renderer.setPointColoring(props, /*highlight=*/
false);
if (style == PointStyle.POINT) {
width = props.getPointSize();
savedShading = renderer.setShading(Shading.NONE);
} else {
width = props.getPointRadius();
}
renderer.drawPoints(ro, style, width);
if (style == PointStyle.POINT) {
renderer.setShading(savedShading);
}
}
if (ro.numTriangles() > 0) {
Shading savedShadeModel = renderer.getShading();
FaceStyle savedFaceStyle = renderer.getFaceStyle();
renderer.setFaceColoring(props, /*highlight=*/
false);
renderer.setFaceStyle(props.getFaceStyle());
renderer.setShading(props.getShading());
renderer.drawTriangles(ro);
renderer.setFaceStyle(savedFaceStyle);
renderer.setShading(savedShadeModel);
}
RenderObject rd = myDepthRob;
if (rd != null && rd.numTriangles() > 0) {
Shading savedShadeModel = renderer.getShading();
FaceStyle savedFaceStyle = renderer.getFaceStyle();
renderer.setFaceStyle(props.getFaceStyle());
// props.getShading());
renderer.setShading(Shading.SMOOTH);
renderer.setDepthOffset(2);
renderer.drawTriangles(rd);
renderer.setFaceStyle(savedFaceStyle);
renderer.setShading(savedShadeModel);
}
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class CollisionRenderer method drawLines.
private void drawLines(Renderer renderer, RenderObject ro, RenderProps props) {
LineStyle style = props.getLineStyle();
Shading savedShading = renderer.setLineShading(props);
renderer.setLineColoring(props, /*highlight=*/
false);
switch(style) {
case LINE:
{
int width = props.getLineWidth();
if (width > 0) {
// renderer.setLightingEnabled (false);
// renderer.setColor (props.getLineColorArray(), /*highlight=*/false);
renderer.drawLines(ro, LineStyle.LINE, width);
// renderer.setLightingEnabled (true);
}
break;
}
// do we need to handle the solid line case?
case SPINDLE:
case SOLID_ARROW:
case CYLINDER:
{
double rad = props.getLineRadius();
if (rad > 0) {
// Shading savedShading = renderer.getShadeModel();
// renderer.setLineLighting (props, /*highlight=*/false);
renderer.drawLines(ro, style, rad);
// renderer.setShadeModel(savedShading);
}
break;
}
}
renderer.setShading(savedShading);
}
Aggregations