use of maspack.render.GL.GLClipPlane in project artisynth_core by artisynth.
the class ClipPlanesUBO method updateClipPlanes.
/**
* Returns the number of enabled clip distances
*/
public int updateClipPlanes(GL3 gl, GLClipPlane[] clips) {
float[] clipbuff = new float[4];
int nclips = 0;
ByteBuffer buff = getBuffer();
for (GLClipPlane cp : clips) {
if (cp.isClippingEnabled()) {
buff.position(getByteOffset(nclips));
cp.getClipPlaneValues(clipbuff, 0, false);
for (int i = 0; i < 4; ++i) {
buff.putFloat(clipbuff[i]);
}
nclips++;
if (nclips >= numClipPlanes) {
break;
}
if (cp.isSlicingEnabled()) {
buff.position(getByteOffset(nclips));
cp.getClipPlaneValues(clipbuff, 0, true);
for (int i = 0; i < 4; ++i) {
buff.putFloat(clipbuff[i]);
}
nclips++;
if (nclips >= numClipPlanes) {
break;
}
}
}
}
buff.flip();
update(gl, buff);
return nclips;
}
use of maspack.render.GL.GLClipPlane in project artisynth_core by artisynth.
the class DrawToolBase method getTransformFromClippingPlane.
private boolean getTransformFromClippingPlane(RigidTransform3d X) {
if (myViewer.getNumClipPlanes() > 0) {
GLClipPlane plane = myViewer.getClipPlane(0);
X.set(plane.getGridToWorld());
return true;
} else {
return false;
}
}
use of maspack.render.GL.GLClipPlane in project artisynth_core by artisynth.
the class EditingAgent method intersectClipPlane.
/**
* Intersects a ray with a viewer clip plane and returns the corresponding
* point. If there is no intersection because the plane is perpendicular to
* the eye direction, then null is returned.
*/
public Point3d intersectClipPlane(Line ray, GLClipPlane clipPlane) {
Point3d res = new Point3d();
Plane plane = new Plane();
clipPlane.getPlane(plane);
if (ray.intersectPlane(res, plane) == Double.POSITIVE_INFINITY) {
return null;
} else {
return res;
}
}
use of maspack.render.GL.GLClipPlane in project artisynth_core by artisynth.
the class ClipPlanesUBO method updateClipPlanes.
/**
* Returns the number of enabled clip distances
*/
public int updateClipPlanes(GL3 gl, List<GLClipPlane> clips) {
float[] clipbuff = new float[4];
int nclips = 0;
ByteBuffer buff = getBuffer();
for (GLClipPlane cp : clips) {
if (cp.isClippingEnabled()) {
buff.position(getByteOffset(nclips));
cp.getClipPlaneValues(clipbuff, 0, false);
for (int i = 0; i < 4; ++i) {
buff.putFloat(clipbuff[i]);
}
nclips++;
if (nclips >= numClipPlanes) {
break;
}
if (cp.isSlicingEnabled()) {
buff.position(getByteOffset(nclips));
cp.getClipPlaneValues(clipbuff, 0, true);
for (int i = 0; i < 4; ++i) {
buff.putFloat(clipbuff[i]);
}
nclips++;
if (nclips >= numClipPlanes) {
break;
}
}
}
}
int bytesLeft = getSize() - buff.position();
for (int i = 0; i < bytesLeft; ++i) {
buff.put((byte) 0);
}
buff.flip();
update(gl, buff);
return nclips;
}
use of maspack.render.GL.GLClipPlane in project artisynth_core by artisynth.
the class ViewerToolBar method addClipPlane.
private void addClipPlane() {
GLClipPlane clipPlane = myViewer.addClipPlane(null, 0);
ClipPlaneControl ctrl = new ClipPlaneControl(clipPlane);
ctrl.setColor(getClipPlaneColor(myClipPlaneControls.size()));
if (myViewer.numFreeClipPlanes() > 0) {
ctrl.setActive(true);
} else {
ctrl.setActive(false);
}
myClipPlaneControls.add(ctrl);
}
Aggregations