Search in sources :

Example 1 with GLClipPlane

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;
}
Also used : ByteBuffer(java.nio.ByteBuffer) GLClipPlane(maspack.render.GL.GLClipPlane)

Example 2 with GLClipPlane

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;
    }
}
Also used : GLClipPlane(maspack.render.GL.GLClipPlane)

Example 3 with GLClipPlane

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;
    }
}
Also used : Plane(maspack.matrix.Plane) GLClipPlane(maspack.render.GL.GLClipPlane) Point3d(maspack.matrix.Point3d)

Example 4 with GLClipPlane

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;
}
Also used : ByteBuffer(java.nio.ByteBuffer) GLClipPlane(maspack.render.GL.GLClipPlane)

Example 5 with GLClipPlane

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);
}
Also used : GLClipPlane(maspack.render.GL.GLClipPlane)

Aggregations

GLClipPlane (maspack.render.GL.GLClipPlane)7 Point (java.awt.Point)2 ByteBuffer (java.nio.ByteBuffer)2 Dragger3d (maspack.render.Dragger3d)2 RenderList (maspack.render.RenderList)2 GL2 (com.jogamp.opengl.GL2)1 Plane (maspack.matrix.Plane)1 Point3d (maspack.matrix.Point3d)1