use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class Jack3d method render.
public void render(Renderer renderer, int flags) {
if (!myVisibleP) {
return;
}
renderer.pushModelMatrix();
renderer.mulModelMatrix(myXDraggerToWorld);
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setLineWidth(myLineWidth);
renderer.setPointSize(3);
float[] coords = new float[3];
renderer.setColor(1, 1, 0);
myPnt0.get(coords);
renderer.drawPoint(coords);
renderer.scaleModelMatrix(mySize);
if (renderObject == null) {
renderObject = createJackRenderable();
}
// draw selected component first
if (mySelectedComponent != 0) {
renderer.drawLines(renderObject, mySelectedComponent);
}
renderer.drawLines(renderObject, 0);
renderer.setLineWidth(1);
renderer.setShading(savedShading);
renderer.popModelMatrix();
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class PrimitivesTest method addContent.
@Override
protected void addContent(MultiViewer mv) {
SimpleSelectable renderable = new SimpleSelectable() {
RenderProps props = new RenderProps();
@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) {
props.setFaceColor(Color.CYAN);
renderer.setFaceColoring(props, false);
renderer.setColor(props.getFaceColorF());
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setPointSize(20f);
renderer.drawPoint(new float[] { 0.1f, 0.2f, 0.3f });
renderer.setLineWidth(20f);
renderer.drawLine(new float[] { -0.1f, -0.2f, -0.3f }, new float[] { -0.3f, -0.2f, -0.1f });
renderer.setShading(savedShading);
renderer.drawTriangle(new float[] { 0.1f, 0.1f, -0.1f }, new float[] { 0.3f, 0.1f, -0.1f }, new float[] { 0.1f, 0.3f, -0.1f });
}
@Override
public void prerender(RenderList list) {
}
@Override
public int getRenderHints() {
return 0;
}
@Override
public int numSelectionQueriesNeeded() {
return 0;
}
@Override
public boolean isSelectable() {
return false;
}
@Override
public void getSelection(LinkedList<Object> list, int qid) {
}
@Override
public void setSelected(boolean set) {
}
@Override
public boolean isSelected() {
// TODO Auto-generated method stub
return false;
}
};
mv.addRenderable(renderable);
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class Transrotator3d method render.
public void render(Renderer renderer, int flags) {
if (!myVisibleP) {
return;
}
Shading savedShading = renderer.setShading(Shading.NONE);
renderer.setLineWidth(myLineWidth);
ColorMixing savedMixing = renderer.setVertexColorMixing(ColorMixing.REPLACE);
renderer.pushModelMatrix();
renderer.mulModelMatrix(myXDraggerToWorld);
float[] coords = new float[3];
if (myDragMode != DragMode.OFF && mySelectedComponent != NONE) {
renderer.setColor(1, 1, 0);
renderer.setPointSize(3);
myPnt0.get(coords);
renderer.drawPoint(coords);
renderer.setPointSize(1);
}
renderer.scaleModelMatrix(mySize);
if (renderObject == null) {
renderObject = createTransrotatorRenderable();
}
// select appropriate color buffer
if (mySelectedComponent != 0) {
renderer.drawLines(renderObject, mySelectedComponent);
}
renderer.drawLines(renderObject, 0);
renderer.popModelMatrix();
if (myDragMode != DragMode.OFF && (mySelectedComponent == X_ROTATE || mySelectedComponent == Y_ROTATE || mySelectedComponent == Z_ROTATE)) {
// Draw rotation lines using the orientation at the time the drag was
// started
RigidTransform3d X = new RigidTransform3d(myXDraggerToWorld0);
X.p.set(myXDraggerToWorld.p);
renderer.pushModelMatrix();
renderer.mulModelMatrix(X);
final float[] coords0 = new float[] { 0, 0, 0 };
renderer.setColor(0.5f, 0.5f, 0.5f);
myPnt0.get(coords);
renderer.drawLine(coords0, coords);
renderer.setColor(1, 1, 0);
myRotPnt.get(coords);
renderer.drawLine(coords0, coords);
renderer.popModelMatrix();
}
renderer.setLineWidth(1);
renderer.setShading(savedShading);
renderer.setVertexColorMixing(savedMixing);
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class AuxMaterialElementDescList method dorender.
private void dorender(Renderer renderer, int flags, boolean selected) {
// This code is taken mostly verbatim from FemElement3dList.
// Should find a way to avoid duplicate code ...
double fractionRenderRadius = 0;
FractionRenderType fractionRenderType = AuxMaterialBundle.DEFAULT_FRACTION_RENDER_TYPE;
ModelComponent parent = getParent();
if (parent instanceof AuxMaterialBundle) {
fractionRenderRadius = ((AuxMaterialBundle) parent).getFractionRenderRadius();
fractionRenderType = ((AuxMaterialBundle) parent).getFractionRenderType();
}
if (fractionRenderRadius > 0) {
Shading savedShading = renderer.getShading();
renderer.setShading(myRenderProps.getShading());
renderer.setPointColoring(myRenderProps, /*highlight=*/
false);
renderFractions(renderer, fractionRenderRadius, fractionRenderType, false);
renderer.setShading(savedShading);
}
}
use of maspack.render.Renderer.Shading in project artisynth_core by artisynth.
the class SDGridTest method render.
@Override
public void render(Renderer renderer, int flags) {
if (sdgrid != null) {
Shading savedShading = renderer.getShading();
renderer.setShading(Shading.NONE);
renderer.setPointSize(5);
VectorTransformer3d TGL = sdgrid.getGridToLocalTransformer();
Vector3i res = sdgrid.getResolution();
// Draw 4 vertical lines.
renderer.beginDraw(DrawMode.LINES);
renderer.addVertex(gridToLocal(TGL, res.x, res.y, res.z));
renderer.addVertex(gridToLocal(TGL, res.x, res.y, 0));
renderer.addVertex(gridToLocal(TGL, 0, res.y, res.z));
renderer.addVertex(gridToLocal(TGL, 0, res.y, 0));
renderer.addVertex(gridToLocal(TGL, 0, 0, res.z));
renderer.addVertex(gridToLocal(TGL, 0, 0, 0));
renderer.addVertex(gridToLocal(TGL, res.x, 0, res.z));
renderer.addVertex(gridToLocal(TGL, res.x, 0, 0));
// Draw a diagonal line from max to min.
renderer.addVertex(gridToLocal(TGL, 0, 0, 0));
renderer.addVertex(gridToLocal(TGL, res.x, res.y, res.z));
renderer.endDraw();
double[] phi = sdgrid.getDistances();
// Draw the vertices on the grid.
Vector3d coords = new Vector3d();
for (int i = 0; i < phi.length; i++) {
Vector3i vxyz = new Vector3i();
sdgrid.vertexToXyzIndices(vxyz, i);
sdgrid.getLocalVertexCoords(coords, vxyz);
if (phi[i] <= 0) {
renderer.setColor(Color.BLUE);
renderer.drawPoint(coords);
} else {
renderer.setColor(Color.RED);
renderer.drawPoint(coords);
}
}
renderer.setPointSize(1);
renderer.setShading(savedShading);
}
}
Aggregations