use of maspack.render.RenderList in project artisynth_core by artisynth.
the class GL3Viewer method doDisplay.
private void doDisplay(GLAutoDrawable drawable, int flags) {
// updates projection matrix
if (resetViewVolume && autoResizeEnabled) {
resetViewVolume(gl);
resetViewVolume = false;
}
if (resetViewport && autoViewportEnabled) {
setViewport(gl, 0, 0, width, height);
resetViewport = false;
}
int nclips = Math.min(2 * myClipPlanes.size(), maxClipPlanes);
myProgramInfo.setNumClipPlanes(nclips);
myProgManager.reconfigure(gl, lightManager.numLights(), nclips);
myProgManager.setLights(gl, lightManager.getLights(), 1.0f / lightManager.getMaxIntensity(), viewMatrix);
// update matrices
maybeUpdateState(gl);
// clear background/depth
gl.glClearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], backgroundColor[3]);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
if (!isSelecting()) {
if (gridVisible) {
myGrid.render(this, flags);
}
if (axisLength > 0) {
if (solidAxes) {
drawSolidAxes(null, axisLength, axisLength / 50.0, false);
} else {
drawAxes(gl, axisLength);
}
}
// not clipped by the clipping plane
for (Dragger3d dragger : myDraggers) {
dragger.render(this, 0);
}
if (myDrawTool != null) {
myDrawTool.render(this, 0);
}
for (GLClipPlane cp : myClipPlanes) {
cp.render(this, flags);
}
}
for (int i = 0; i < myProgManager.numClipPlanes(); ++i) {
boolean enabled = gl.glIsEnabled(GL3.GL_CLIP_DISTANCE0 + i);
if (enabled) {
Logger.getSystemLogger().debug("Why is this enabled?");
}
}
// enable clip planes
int iclips = 0;
if (nclips > 0) {
iclips = myProgManager.setClipPlanes(gl, myClipPlanes);
for (int i = 0; i < iclips; ++i) {
gl.glEnable(GL3.GL_CLIP_DISTANCE0 + i);
}
}
if (!isSelecting()) {
setFrontColor(DEFAULT_MATERIAL_COLOR);
}
int qid = 0;
synchronized (myInternalRenderList) {
qid = myInternalRenderList.renderOpaque(this, qid, flags);
}
RenderList elist = myExternalRenderList;
if (elist != null) {
synchronized (elist) {
qid = elist.renderOpaque(this, qid, flags);
}
}
if (hasTransparent3d()) {
if (!isSelecting()) {
enableTransparency();
}
synchronized (myInternalRenderList) {
qid = myInternalRenderList.renderTransparent(this, qid, flags);
}
if (elist != null) {
synchronized (elist) {
qid = elist.renderTransparent(this, qid, flags);
}
}
if (!isSelecting()) {
disableTransparency();
}
}
// disable clip planes
for (int i = 0; i < nclips; ++i) {
gl.glDisable(GL3.GL_CLIP_DISTANCE0 + i);
}
// Draw 2D objects
if (has2d()) {
begin2DRendering(width, height);
try {
synchronized (myInternalRenderList) {
qid = myInternalRenderList.renderOpaque2d(this, qid, 0);
}
if (elist != null) {
synchronized (elist) {
qid = elist.renderOpaque2d(this, qid, 0);
}
}
if (hasTransparent2d()) {
if (!isSelecting()) {
enableTransparency();
}
synchronized (myInternalRenderList) {
qid = myInternalRenderList.renderTransparent2d(this, qid, 0);
}
if (elist != null) {
synchronized (elist) {
qid = elist.renderTransparent2d(this, qid, 0);
}
}
if (!isSelecting()) {
disableTransparency();
}
}
} finally {
// methods throws and exception
if (isTransparencyEnabled()) {
disableTransparency();
}
end2DRendering();
}
}
if (!isSelecting()) {
if (myDragBox != null) {
drawDragBox(gl);
}
if (myEllipticCursorActive) {
Point cursor = myMouseHandler.getCurrentCursor();
if (cursor != null) {
drawEllipticCursor(gl, cursor);
}
}
} else {
// revert clear color
gl.glClearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], backgroundColor[3]);
}
// trigger update of state (required for GLJPanel, which relies on
// transparency to be off)
maybeUpdateState(gl);
gl.glFlush();
}
use of maspack.render.RenderList 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.RenderList in project artisynth_core by artisynth.
the class TriangleLightingTest 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.WHITE);
props.setBackColor(Color.WHITE);
renderer.setFaceColoring(props, /*highlight=*/
false);
renderer.setShading(Shading.SMOOTH);
renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
renderer.setColor(props.getFaceColorF());
renderer.setBackColor(props.getBackColorF());
renderer.drawTriangle(new float[] { 1, 1, 0 }, new float[] { -1, 1, 0 }, new float[] { -1, -1, 0 });
renderer.drawTriangle(new float[] { -1, -1, 0 }, new float[] { 1, -1, 0 }, new float[] { 1, 1, 0 });
renderer.setDepthOffset(1);
renderer.drawAxes(RigidTransform3d.IDENTITY, 1, 1, false);
renderer.setDepthOffset(0);
}
@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);
mv.setAxialView(AxisAlignedRotation.X_Y);
}
use of maspack.render.RenderList in project artisynth_core by artisynth.
the class VolumePrimitivesTest 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);
props.setBackColor(Color.MAGENTA);
renderer.setFaceColoring(props, /*highlight=*/
false);
renderer.setColor(props.getFaceColorF());
renderer.setBackColor(props.getBackColorF());
renderer.setFaceStyle(FaceStyle.FRONT_AND_BACK);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.3f}, 0.05);
// renderer.drawSpindle (new float[]{-0.1f,-0.2f,-0.3f}, new float[]{-0.3f,-0.2f,-0.1f}, 0.05);
// renderer.drawSpindle (new float[]{0.1f,-0.2f,0.3f}, new float[]{0.3f,-0.2f,0.1f}, 0.25);
// renderer.drawCylinder (new float[]{-0.1f,0.2f,-0.3f}, new float[]{-0.3f,0.2f,-0.1f}, 0.3, true);
// renderer.drawCylinder (new float[]{0.1f,0.2f,-0.3f}, new float[]{-0.3f,-0.2f,-0.3f}, 0.2, true);
// renderer.drawCone (new float[]{-0.1f,0.2f,0.3f}, new float[]{0.3f,0.2f,-0.1f}, 0.1, 0, false);
// renderer.drawCone (new float[]{-0.3f,0.2f,0.3f}, new float[]{0.5f,0.2f,-0.1f}, 0, 0.2, true);
// renderer.drawSphere (new float[]{-0.1f,-0.2f,-0.3f}, 0.2);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.3f}, 0.02);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.6f}, 0.03);
// renderer.drawSphere (new float[] {0.1f,0.2f,0.8f}, 0.04);
// renderer.drawSphere (new float[] {0.1f,0.2f,1f}, 0.05);
// renderer.drawCone (new float[]{0.1f,0.1f,-0.1f}, new float[]{0.3f,0.1f,-0.1f}, 0.05, 0.02, true);
renderer.drawCube(new float[] { -0.2f, -0.2f, -0.2f }, 0.5);
}
@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.RenderList in project artisynth_core by artisynth.
the class GLViewer method getBounds.
public boolean getBounds(Point3d pmin, Point3d pmax) {
for (int i = 0; i < 3; i++) {
pmin.set(i, Double.POSITIVE_INFINITY);
pmax.set(i, Double.NEGATIVE_INFINITY);
}
boolean boundsSet = false;
for (IsRenderable renderable : myRenderables) {
renderable.updateBounds(pmin, pmax);
boundsSet = true;
}
RenderList elist = myExternalRenderList;
if (elist != null) {
elist.updateBounds(pmin, pmax);
boundsSet = true;
}
if (!boundsSet) {
for (IsRenderable renderable : myDraggers) {
renderable.updateBounds(pmin, pmax);
}
}
// System.out.println (pmax);
if (pmin.x == Double.POSITIVE_INFINITY) {
// then no bounds were set, so
// use a default
pmin.set(-1, -1, -1);
pmax.set(1, 1, 1);
return false;
} else {
return true;
}
}
Aggregations