Package processing.core

Examples of processing.core.PApplet


  public void onExit(Controller controller) {
    System.out.println("Leap Motion Exited");
  }

  private void invokeCallback(Gesture gesture) {
    PApplet parent = this.leap.getParent();

    if (parent != null) {
      switch (gesture.type()) {
        case TYPE_CIRCLE:
          CircleGesture circleGesture = new CircleGesture(gesture);
          String clockwiseness;
          if (circleGesture.pointable().direction().angleTo(circleGesture.normal()) <= Math.PI / 4) {
            // Clockwise if angle is less than 90 degrees
            clockwiseness = "clockwise";
          } else {
            clockwiseness = "counterclockwise";
          }
          try {
            parent.getClass()
                .getMethod(this.callbackMethodNameCircle, CircleGesture.class, String.class)
                .invoke(parent, circleGesture, clockwiseness);
          } catch (Exception e) {
            PApplet.println(e.getMessage() + " CALLBACK ERROR");
          }
          break;
        case TYPE_SWIPE:
          SwipeGesture swipeGesture = new SwipeGesture(gesture);
          try {
            parent.getClass().getMethod(this.callbackMethodNameSwipe, SwipeGesture.class)
                .invoke(parent, swipeGesture);
          } catch (Exception e) {
            PApplet.println(e.getMessage() + " CALLBACK ERROR");
          }
          break;
        case TYPE_SCREEN_TAP:
          ScreenTapGesture screenTapGesture = new ScreenTapGesture(gesture);
          try {
            parent.getClass().getMethod(this.callbackMethodNameScreenTap, ScreenTapGesture.class)
                .invoke(parent, screenTapGesture);
          } catch (Exception e) {
            PApplet.println(e.getMessage() + " CALLBACK ERROR");
          }
          break;
        case TYPE_KEY_TAP:
          KeyTapGesture keyTapGesture = new KeyTapGesture(gesture);
          try {
            parent.getClass().getMethod(this.callbackMethodNameKeyTap, KeyTapGesture.class)
                .invoke(parent, keyTapGesture);
          } catch (Exception e) {
            PApplet.println(e.getMessage() + " CALLBACK ERROR");
          }
          break;
View Full Code Here


   */
  @Override
  public void drawComponent(PGraphics g) {
//    super.drawComponent(g);
   
    PApplet renderer = this.getRenderer();
       
    //Draw the shape
    if (MT4jSettings.getInstance().isOpenGlMode()  
       && this.isUseDirectGL()){
      GL gl = Tools3D.beginGL(renderer);
View Full Code Here

        IFontFactory fontFactory = FontManager.getInstance().getFactoryForFileSuffix("");
        if (fontFactory != null && fontFactory instanceof BitmapFontFactory){
          BitmapFontFactory bitmapFontFactory = (BitmapFontFactory)fontFactory;
          if (this.getCharacters().length > 0 && this.getCharacters()[0] != null && this.getCharacters()[0] instanceof MTComponent){
            MTComponent comp = (MTComponent)this.getCharacters()[0];
            PApplet pa = comp.getRenderer();
            List<BitmapFontCharacter> charactersList = bitmapFontFactory.getCharacters(pa, unicode, fillColor, strokeColor, this.fontFileName, this.originalFontSize, this.antiAliased);
            BitmapFontCharacter[] characters = charactersList.toArray(new BitmapFontCharacter[charactersList.size()]);
            if (characters.length >= 1 && characters[0] != null){
              BitmapFontCharacter loadedCharacter = characters[0];
              BitmapFontCharacter[] newArray = new BitmapFontCharacter[this.getCharacters().length + 1];
View Full Code Here

    System.err.println("MT Line doesent support vbos.");
  }
 
  @Override
  public void drawComponent(PGraphics g) {
    PApplet renderer = this.getRenderer();
    if (MT4jSettings.getInstance().isOpenGlMode()  
        && this.isUseDirectGL()){
        GL gl=((PGraphicsOpenGL)renderer.g).beginGL();
     
        //Draw with PURE opengl
View Full Code Here

   * <p>
   * If the geometry had vbos already, we should delete them first
   * usually.
   */
  private void generateOrUpdateVertColStrokeColTexVBOs(){
    PApplet pa     = this.getRenderer();
    int vertexCount = this.getVertexCount();
    //If no vbos exist yet, create them now
    if (this.getVBOVerticesName()   == -1){
      this.vboVerticesID   = ToolsVBO.generateVertexVBO(pa, this.getVertBuff(), vertexCount);
    }else{
View Full Code Here

   * usually.
   */
  public void generateOrUpdateAllVBOs(){
    //If no normals vbo exists, create it now
    if (this.isContainsNormals()){
      PApplet pa = this.getRenderer();
      if (this.getVBONormalsName() == -1){
        this.vboNormalsID   = ToolsVBO.generateNormalsVBO(pa, this.getNormalsBuff(), this.getNormals().length);
      }else{
        this.updateNormalsVBO(this.getNormalsBuff(), false, false);
      }
View Full Code Here

        IFontFactory fontFactory = FontManager.getInstance().getFactoryForFileSuffix(".ttf");
        if (fontFactory != null && fontFactory instanceof TTFontFactory){
          TTFontFactory ttFontFactory = (TTFontFactory)fontFactory;
          if (this.getCharacters().length > 0 && this.getCharacters()[0] != null && this.getCharacters()[0] instanceof MTComponent){
            MTComponent comp = (MTComponent)this.getCharacters()[0];
            PApplet pa = comp.getRenderer();
            VectorFontCharacter[] characters = ttFontFactory.getTTFCharacters(pa, unicode, fillColor, strokeColor, this.fontFileName, this.originalFontSize, this.antiAliased);
            if (characters.length == 1 && characters[0] != null){
              VectorFontCharacter loadedCharacter = characters[0];
              VectorFontCharacter[] newArray = new VectorFontCharacter[this.getCharacters().length + 1];
              System.arraycopy(this.getCharacters(), 0, newArray, 0, this.getCharacters().length);
View Full Code Here

  /* (non-Javadoc)
   * @see org.mt4j.components.visibleComponents.AbstractVisibleComponent#drawComponent(processing.core.PGraphics)
   */
  @Override
  public void drawComponent(PGraphics g) {
    PApplet pa = this.getRenderer();
   
    if (this.isUseDirectGL()){
      GL gl=((PGraphicsOpenGL)g).beginGL();
        this.drawComponent(gl);
      ((PGraphicsOpenGL)this.getRenderer().g).endGL();
    }else{ //Draw with pure proccessing...
      pa.strokeWeight(this.getStrokeWeight());
     
//      if (ConstantsAndSettings.getInstance().isOpenGlMode()){
        if (this.isDrawSmooth())
          pa.smooth();
        else      
          pa.noSmooth();
//      }
     
      //NOTE: if noFill() and noStroke()->absolutely nothing will be drawn-even when texture is set
      if (this.isNoFill()) 
        pa.noFill();
      else{
        MTColor fillColor = this.getFillColor();
        pa.fill(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
      }
     
      if (this.isNoStroke())  
        pa.noStroke();
      else{
        MTColor strokeColor = this.getStrokeColor();
        pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
      }
     
      //Set the tint values
      MTColor fillColor = this.getFillColor();
      pa.tint(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha())

      //handles the drawing of the vertices with the texture coordinates
      //try doing a smoothed poly outline with opengl
//      if (
////          ConstantsAndSettings.getInstance().isOpenGlMode()  &&
//        this.isDrawSmooth() &&
//        !this.isNoStroke()
//      ){
//        pa.noStroke();
//        pa.noSmooth();
//       
//        //draw insided of polygon, without smooth or stroke
//        this.drawWithProcessing(pa, this.getVerticesObjSpace(), PApplet.TRIANGLES, true);
//
//        pa.smooth();
//        pa.noFill();
//        pa.stroke(this.getStrokeRed(), this.getStrokeGreen(), this.getStrokeBlue(), this.getStrokeAlpha());
//
//        // DRAW SMOOTHED THE OUTLINE SHAPE OF THE POLYGON WIHTOUT FILL OR TEXTURE
////        drawWithProcessing(pa);
//       
//        for (Vertex[] outline : this.outlineContours){
//          this.drawWithProcessing(pa, outline, PApplet.LINE, false);
//        }
//      }else{
      if (!this.isNoStroke()){
        pa.noFill();
        MTColor strokeColor = this.getStrokeColor();
        pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
        pa.strokeWeight(2);
       
        if (this.isDrawSmooth())
          pa.smooth();
       
        for (Vertex[] outline : this.outlineContours){
          this.drawWithProcessing(pa, outline, PApplet.POLYGON, false);
        }
      }

      if (!this.isNoFill()){
        pa.noStroke();
        pa.noSmooth();
        pa.fill(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
        this.drawWithProcessing(pa, this.getVerticesLocal(), PApplet.TRIANGLES, true);
      }


//      }//end if gl and smooth

      //reSet the tint values to defaults
      pa.tint(255, 255, 255, 255);

      if (/*ConstantsAndSettings.getInstance().isOpenGlMode() && */
          this.isDrawSmooth())
        pa.noSmooth(); //because of tesselation bug
    }

    if (drawNormals)
      this.drawNormals();
  }
View Full Code Here

  }
 
 
  public void setHardwareInputEnabled(boolean hardwareInput){
    try {
      PApplet app = getRenderer();
      if (hardwareInput) {
        app.registerKeyEvent(this);
      }else{
        app.unregisterKeyEvent(this);
      }
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    this.hardwareInput = hardwareInput;
View Full Code Here

  /**
   * Draws the face normals of the mesh.
   */
  private void drawNormals(){
    PApplet r = this.getRenderer();
//    Vector3D[] normals = this.getGeometryInfo().getNormals();
    r.stroke(255, 0, 0);
    r.strokeWeight(0.5f);
   
    for (int i = 0; i < triangles.length; i++) {
      Triangle t = triangles[i];
      r.pushMatrix();
      Vector3D centerPoint = t.getCenterPointLocal();
      r.translate(centerPoint.x, centerPoint.y, centerPoint.z);
      r.scale(-2,-2,-2);
     
      r.line(0, 0, 0,  t.getNormalLocal().x, t.getNormalLocal().y, t.getNormalLocal().z);
      r.popMatrix();
    }
//    for (int i = 0; i < normals.length; i++) {
//      Vector3D vector3D = normals[i];
//    }
  }
View Full Code Here

TOP

Related Classes of processing.core.PApplet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.