Java Code Examples for processing.opengl.PGraphicsOpenGL#pushMatrix()

The following examples show how to use processing.opengl.PGraphicsOpenGL#pushMatrix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Skylight_BasicGUI.java    From PixelFlow with MIT License 6 votes vote down vote up
public void displayScene(PGraphicsOpenGL canvas){
  if(canvas == skylight.renderer.pg_render){
    canvas.background(BACKGROUND);
    displaySamples(canvas);
  }
  
  if(canvas == geombuffer.pg_geom){
    canvas.pgl.clearDepth(1.0f);
    canvas.pgl.clearColor(1, 1, 1, clip_z_far);
    canvas.pgl.clear(PGL.COLOR_BUFFER_BIT | PGL.DEPTH_BUFFER_BIT);
  }
  
  canvas.pushMatrix();
  canvas.applyMatrix(mat_scene_view);
  canvas.shape(shp_group);
  canvas.popMatrix();
}
 
Example 2
Source File: DrawUtils.java    From PapARt with GNU Lesser General Public License v3.0 6 votes vote down vote up
static public void drawText(PGraphicsOpenGL pg3d, String text, PFont font, int x, int y) {
        
        pg3d.pushMatrix();
        pg3d.translate(x, y);
        pg3d.text(text, 0, 0);
        pg3d.popMatrix();
        
//        pg3d.pushMatrix();
//        pg3d.translate(x, y);
//        pg3d.scale(-1, 1, 1);
//        pg3d.rotate(PApplet.PI);
//        pg3d.textMode(PApplet.MODEL);
//        pg3d.textFont(font);
//        pg3d.text(text, 0, 0);
//        pg3d.popMatrix();
    }
 
Example 3
Source File: DrawUtils.java    From PapARt with GNU Lesser General Public License v3.0 6 votes vote down vote up
static public void drawText(PGraphicsOpenGL pg3d, String text, PFont font, int fontSize, int x, int y) {
        pg3d.pushMatrix();
        pg3d.translate(x, y);
        pg3d.textMode(PApplet.MODEL);
        pg3d.textFont(font, fontSize);
        pg3d.text(text, 0, 0);
        pg3d.popMatrix();

        
//        pg3d.pushMatrix();
//        pg3d.translate(x, y);
//        pg3d.scale(-1, 1, 1);
//        pg3d.rotate(PApplet.PI);
//        pg3d.textMode(PApplet.MODEL);
//        pg3d.textFont(font, fontSize);
//        pg3d.text(text, 0, 0);
//        pg3d.popMatrix();
    }
 
Example 4
Source File: MultiSimpleCalibrator.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawProgress(PGraphicsOpenGL g,
            MultiSimpleCalibrator multiCalibrator, PVector pt) {
        g.pushMatrix();
        g.translate(120, 150);
        g.fill(255);  // necessary for text
        g.text("Photos: ", 0, 8);
//        g.text("Markers: ", 150, 200 + 8);
        g.strokeWeight(1);
        g.stroke(255);

        for (int i = 0; i < multiCalibrator.nbScreenPoints; i++) {
            if (i < multiCalibrator.currentScreenPoint) {
                g.fill(0, 255, 0); // green
            } else {
                if (i == multiCalibrator.currentScreenPoint) {
                    g.fill(242, 193, 48); // orange
                } else {
                    g.fill(66, 66, 66); // nothing
                }
            }
            g.rect(50 + i * 20, 0, 20, 20);
        }
        g.popMatrix();

        // Color captures
        int[][] savedColors = multiCalibrator.savedColors;
        g.noStroke();
        int rectSize = 15;
        for (int i = 0; i < multiCalibrator.nbScreenPoints; i++) {

            for (int j = 0; j < multiCalibrator.nbColors; j++) {
                g.fill(savedColors[i * 2][j]);
                g.rect(i * rectSize, j * 2 * rectSize, rectSize, rectSize);

                g.fill(savedColors[i * 2 + 1][j]);
                g.rect(i * rectSize, (j * 2 + 1) * rectSize, rectSize, rectSize);
            }
        }

    }
 
Example 5
Source File: DrawUtils.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
static public void drawImage2(PGraphicsOpenGL g, PImage img, int x, int y, int w, int h) {
    g.pushMatrix();
    g.translate(x, y);
    g.scale(-1, 1, 1);
    g.rotate(PApplet.PI);
    g.image(img, 0, 0, w, h);
    g.popMatrix();
}
 
Example 6
Source File: DrawUtils.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
static public void drawImage(PGraphicsOpenGL g, PImage img, int x, int y, int w, int h) {
//        g.pushMatrix();
//        g.translate(x, y);
//        g.scale(-1, 1, 1);
//        g.rotate(PApplet.PI);
//        g.image(img, 0, 0, w, h);
//        g.popMatrix();

//        g.beginShape(QUADS);
//        g.texture(img);
//        g.vertex(x, y, 0, h);
//        g.vertex(x, y + h, 0, 0);
//        g.vertex(x + w, y + h, w, 0);
//        g.vertex(x + w, y, w, h);
//        g.endShape();

        g.pushMatrix();
        g.translate(x, y);
        g.beginShape(QUADS);
        g.textureMode(NORMAL);
        g.texture(img);
        g.vertex(0, 0, 0, 1);
        g.vertex(0, h, 0, 0);
        g.vertex(w, h, 1, 0);
        g.vertex(w, 0, 1, 1);
        g.endShape();
        
        g.popMatrix();

    }
 
Example 7
Source File: MultiSimpleCalibrator.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void drawCalibration(PGraphicsOpenGL screenGraphics) {
    Papart papart = Papart.getPapart();
    MultiSimpleCalibrator multiCalibrator = papart.multiCalibrator;
    PApplet parent = multiCalibrator.parent;
    PGraphicsOpenGL g = (PGraphicsOpenGL) parent.g;

    if (!multiCalibrator.isActive()) {
        System.out.println("ERROR: cannot calibrate with inactive calibrator.");
        return;
    }

    if (skatolo == null) {
        initGUI(parent, g, multiCalibrator);
    }

    g.clear();

    drawAR(parent, g, multiCalibrator, INVALID_VECTOR);

    drawFrame(parent, g, multiCalibrator);

    // number of valid 
    PVector point = multiCalibrator.screenPoints[multiCalibrator.currentScreenPoint];

    drawProgress(g, multiCalibrator, point);

    if (multiCalibrator.doCalibration) {
        PVector pt = multiCalibrator.screenPoints[multiCalibrator.currentScreenPoint];
        g.pushMatrix();
        g.translate(pt.x, pt.y);
        g.rotate(pt.z);
        drawTarget(g, multiCalibrator);
        drawHints(g, multiCalibrator, pt);
        g.popMatrix();
    }

    if (multiCalibrator.showTouch) {
        drawTouchCalibrated(g, multiCalibrator);
    }

    skatolo.draw(g);
}