use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class GL2Viewer method drawArrow.
public void drawArrow(RenderProps props, float[] pnt0, float[] pnt1, boolean capped, boolean highlight) {
boolean savedHighlighting = getHighlighting();
Shading savedShading = setLineShading(props);
setLineColoring(props, highlight);
GL2 gl = getGL2();
maybeUpdateState(gl);
utmp.set(pnt1[0] - pnt0[0], pnt1[1] - pnt0[1], pnt1[2] - pnt0[2]);
double len = utmp.norm();
utmp.normalize();
vtmp.set(pnt0[0], pnt0[1], pnt0[2]);
double arrowRad = 3 * props.getLineRadius();
double arrowLen = 2 * arrowRad;
vtmp.scaledAdd(len - arrowLen, utmp);
ctmp[0] = (float) vtmp.x;
ctmp[1] = (float) vtmp.y;
ctmp[2] = (float) vtmp.z;
if (len > arrowLen) {
switch(props.getLineStyle()) {
case LINE:
{
setLineWidth(gl, props.getLineWidth());
gl.glBegin(GL2.GL_LINES);
gl.glVertex3fv(pnt0, 0);
gl.glVertex3fv(ctmp, 0);
gl.glEnd();
break;
}
case CYLINDER:
case SOLID_ARROW:
{
drawCylinder(pnt0, ctmp, props.getLineRadius(), capped);
break;
}
case SPINDLE:
{
drawSpindle(pnt0, pnt1, props.getLineRadius());
break;
}
default:
{
throw new InternalErrorException("Unimplemented line style " + props.getLineStyle());
}
}
}
if (props.getLineStyle() == LineStyle.LINE) {
// reset shading from NONE to props value
setShading(props.getShading());
}
if (len <= arrowLen) {
doDrawCylinder(pnt0, pnt1, capped, len / 2, 0.0);
} else {
doDrawCylinder(ctmp, pnt1, capped, arrowRad, 0.0);
}
setShading(savedShading);
setHighlighting(savedHighlighting);
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class GL2Viewer method drawLine.
public void drawLine(RenderProps props, float[] pnt0, float[] pnt1, float[] color, boolean capped, boolean highlight) {
boolean savedHighlighting = getHighlighting();
Shading savedShading = setLineShading(props);
if (color == null) {
color = props.getLineColorF();
}
setPropsColoring(props, color, highlight);
GL2 gl = getGL2();
maybeUpdateState(gl);
if (color == null) {
color = props.getLineColorF();
}
switch(props.getLineStyle()) {
case LINE:
{
// setLightingEnabled (false);
setLineWidth(gl, props.getLineWidth());
// if (color.length == 3 && props.getAlpha () < 1) {
// color = new float[]{color[0], color[1], color[2], (float)props.getAlpha ()};
// }
// setColor (color, selected);
gl.glBegin(GL2.GL_LINES);
gl.glVertex3fv(pnt0, 0);
gl.glVertex3fv(pnt1, 0);
gl.glEnd();
// setLightingEnabled (true);
break;
}
case CYLINDER:
{
// setShadeModel (props.getShading());
// setPropsMaterial (props, color, selected);
drawCylinder(pnt0, pnt1, props.getLineRadius(), capped);
// restoreShading (props);
break;
}
case SOLID_ARROW:
{
// setShadeModel (props.getShading());
// setPropsMaterial (props, color, selected);
drawArrow(pnt0, pnt1, props.getLineRadius(), capped);
// restoreShading (props);
break;
}
case SPINDLE:
{
// setShadeModel (props.getShading());
// setPropsMaterial (props, color, selected);
drawSpindle(pnt0, pnt1, props.getLineRadius());
// restoreShading (props);
break;
}
default:
{
throw new InternalErrorException("Unimplemented line style " + props.getLineStyle());
}
}
setShading(savedShading);
setHighlighting(savedHighlighting);
}
Aggregations