Package processing.core

Examples of processing.core.PImage


    textField.setText("Scene 2");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApplication.width/2f, mtApplication.height/2f));
   
    //Button to change to the previous scene on the scene stack
    PImage arrow = mtApplication.loadImage(imagePath + "arrowRight.png");
    MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
    previousSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      previousSceneButton.setUseDirectGL(true);
    previousSceneButton.addActionListener(new ActionListener() {
View Full Code Here


    textField.setText("Scene 1");
    this.getCanvas().addChild(textField);
    textField.setPositionGlobal(new Vector3D(mtApp.width/2f, mtApp.height/2f));
   
    //Button to get to the next scene
    PImage arrow = mtApplication.loadImage(imagePath +  "arrowRight.png");
    MTImageButton nextSceneButton = new MTImageButton(arrow, mtApplication);
    nextSceneButton.setNoStroke(true);
    if (MT4jSettings.getInstance().isOpenGlMode())
      nextSceneButton.setUseDirectGL(true);
    nextSceneButton.addActionListener(new ActionListener() {
View Full Code Here

   
//    this.setFillDrawMode(GL.GL_QUADS);//FIXME TEST
   
    if (MT4jSettings.getInstance().isOpenGlMode()){
      //Set the texture to be non-repeating but clamping to the border to avoid artefacts
      PImage tex = this.getTexture();
      if (tex instanceof GLTexture) {
        GLTexture glTex = (GLTexture) tex;
//        glTex.setWrap(GL.GL_CLAMP, GL.GL_CLAMP);
//        glTex.setWrap(GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
       
View Full Code Here


  //FIXME TEST
  public void setTextureFiltered(boolean scalable) {
    if (MT4jSettings.getInstance().isOpenGlMode()){
      PImage tex = this.getTexture();
      if (tex instanceof GLTexture) {
        GLTexture glTex = (GLTexture) tex;
        //FIXME normally we would use GL_LINEAR as magnification filter but sometimes
        //small text is too filtered and smudged so we use NEAREST -> but this makes
        //scaled text very ugly and pixelated..
View Full Code Here

    //Load from file system
//    PImage keyboardImg = app.loadImage(System.getProperty("user.dir")+File.separator + "examples"+  File.separator +"advanced"+ File.separator+ File.separator + "flickrMT"+ File.separator +  File.separator + "data"+ File.separator
////    + "keyb2.png");
//    + "keyb128.png");
    //Load from classpath
    PImage keyboardImg = app.loadImage("advanced" + MTApplication.separator + "flickrMT"+ MTApplication.separator + "data"+ MTApplication.separator
//        + "keyb2.png");
        + "keyb128.png");
   
    final MTImageButton keyboardButton = new MTImageButton(keyboardImg, app);
    keyboardButton.setFillColor(new MTColor(255,255,255,200));
View Full Code Here

     *
     * @param filename the filename
     * @param settings the settings
     */
    public void loadTexture(String filename, GLTextureSettings settings){
      PImage img = app.loadImage(filename);
      this.glTextureSettings = settings;
        if (!(ToolsMath.isPowerOfTwo(img.width) && ToolsMath.isPowerOfTwo(img.height)) ){
            this.glTextureSettings.target = TEXTURE_TARGET.RECTANGULAR;
        }
      this.loadTexture(img, this.glTextureSettings);
View Full Code Here

        if (p.Ns != -1.0f)
          m.setShininess(p.Ns);
       

        if (p.t != null) {
          PImage tex = p.t;
         
//          /*
          //Apply alpha mask from transparancy map to the texture
          if (p.d != null){
            //System.out.println("Trying to add alpha mask for material: " + matName);
           
              PImage alphaMap = p.d;
              if (alphaMap.width == tex.width && alphaMap.height == tex.height){
                tex.mask(alphaMap);
                 
                  if (tex instanceof GLTexture) {
                    GLTexture glTex = (GLTexture) tex;
View Full Code Here

      st.lowerCaseMode(true);

      if (tFile != "") {
       
        PImage texture = null;
       
        // Check for filename with no extension
        if (tFile.lastIndexOf('.') != -1) {
          try {
            // Convert filename to lower case for extension comparisons
            String suffix = tFile.substring(tFile.lastIndexOf('.') + 1).toLowerCase();

//            TextureLoader t = null;
           
            tFile = toLowerCase(tFile);

            if ((suffix.equals("int")) || (suffix.equals("inta")) ||
                (suffix.equals("rgb")) || (suffix.equals("rgba")) ||
                (suffix.equals("bw")) || (suffix.equals("sgi"))
            ) {
             
              PImage cachedImage = textureCache.get(tFile);
              if (cachedImage != null){
                texture = cachedImage;
                //System.out.println("->Loaded texture from CACHE : \"" + tFile + "\"");
              }else{
                File textureFile = new File(basePath + tFile);
                if (textureFile.exists()){
                  boolean success = textureFile.renameTo(new File(basePath + tFile));
                    if (!success) {
                        // File was not successfully renamed
                      System.out.println("failed to RENAME file: " + textureFile.getAbsolutePath());
                    }
                   
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }else{
                  System.out.println("Trying to load obj texture from: " + basePath + tFile);
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }
              }
             
//              RgbFile f;
//              if (fromUrl) {
//                f = new RgbFile(new URL(basePath + tFile).openStream());
//              } else {
//                f = new RgbFile(new FileInputStream(basePath + tFile));
//              }
//              BufferedImage bi = f.getImage();

              boolean luminance = suffix.equals("int") || suffix.equals("inta");
              boolean alpha = suffix.equals("inta") || suffix.equals("rgba");
              cur.transparent = alpha;

              String s = null;
              if (luminance && alpha) s = "LUM8_ALPHA8";
              else if (luminance) s = "LUMINANCE";
              else if (alpha) s = "RGBA";
              else s = "RGB";

//              t = new TextureLoader(bi, s, TextureLoader.GENERATE_MIPMAP);
            } else {
//              tFile.toLowerCase();
//              tFile.toLowerCase(Locale.ENGLISH);
//              basePath.toLowerCase();
             
              PImage cachedImage = textureCache.get(tFile);
              if (cachedImage != null){
                texture = cachedImage;
                //System.out.println("->Loaded texture from CACHE : \"" + tFile + "\"");
              }else{
                File textureFile = new File(basePath + tFile);
                if (textureFile.exists()){
                  boolean success = textureFile.renameTo(new File(basePath + tFile));
                    if (!success) {
                        // File was not successfully renamed
                      System.out.println("failed to RENAME file: " + textureFile.getAbsolutePath());
                    }
                   
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
                    textureCache.put(tFile, texture);
                }else{
                  System.out.println("Trying to load obj texture from: " + basePath + tFile);
                    if (MT4jSettings.getInstance().isOpenGlMode()){
                      PImage img = pa.loadImage(basePath + tFile);
                    if (Tools3D.isPowerOfTwoDimension(img)){
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    }else{
                      texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
//                      ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
View Full Code Here

      }while (st.ttype != ObjectFileParser.TT_EOL);

      st.lowerCaseMode(true);

      if (tFile != "") {
        PImage alphaMap;
        // Check for filename with no extension
        if (tFile.lastIndexOf('.') != -1) {
          try {
            // Convert filename to lower case for extension comparisons
            String suffix = tFile.substring(tFile.lastIndexOf('.') + 1).toLowerCase();
View Full Code Here

        materialName.trim();
        materialName.toLowerCase();

        //Try to load texture
        try {
          PImage cachedImage = textureCache.get(materialName);
          if (cachedImage != null){
            mesh.setTexture(cachedImage);
            mesh.setTextureEnabled(true);
            if (debug)
              logger.debug("->Loaded texture from CACHE : \"" + materialName + "\"");
            return;
          }
         
          if (modelFile.exists()){ //If model is loaded from local file system
            String modelFolder  = modelFile.getParent();// pathToModel.substring(), pathToModel.lastIndexOf(File.pathSeparator)
            File modelFolderFile = new File (modelFolder);
            if (modelFolderFile.exists() &&  modelFolderFile.isDirectory())
              modelFolder = modelFolderFile.getAbsolutePath();
            else{
              modelFolder = "";
            }

            String[] suffix = new String[]{"jpg", "JPG", "tga" , "TGA", "bmp", "BMP", "png", "PNG", "tiff", "TIFF"};
            for (int j = 0; j < suffix.length; j++) {
              String suffixString = suffix[j];
              //Try to load and set texture to mesh
              String texturePath   = modelFolder + MTApplication.separator + materialName + "." +  suffixString;
              File textureFile = new File(texturePath);
              if (textureFile.exists()){
                boolean success = textureFile.renameTo(new File(texturePath));
                if (!success) {
                  // File was not successfully renamed
                  logger.debug("failed to RENAME file: " + textureFile.getAbsolutePath());
                }
                PImage texture = null;
                if (MT4jSettings.getInstance().isOpenGlMode()){ //TODO check if render thread
                  PImage img = pa.loadImage(texturePath);
                  if (Tools3D.isPowerOfTwoDimension(img)){
                    texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                  }else{
                    texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                    // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
                  }
                }else{
                  texture     = pa.loadImage(texturePath);
                }
                mesh.setTexture(texture);
                mesh.setTextureEnabled(true);

                textureCache.put(materialName, texture);
                if (debug)
                  logger.debug("->Loaded material texture: \"" + materialName + "\"");
                break;
              }
              if (j+1==suffix.length){
                logger.error("Couldnt load material texture: \"" + materialName + "\"");
              }
            }
          }else{//Probably loading from jar file
            PImage texture = null;
            String[] suffix = new String[]{"jpg", "JPG", "tga" , "TGA", "bmp", "BMP", "png", "PNG", "tiff", "TIFF"};
            for (String suffixString : suffix) {
              String modelFolder  = pathToModel.substring(0, pathToModel.lastIndexOf(MTApplication.separator));
              String texturePath   = modelFolder + MTApplication.separator + materialName + "." +  suffixString;
              if (MT4jSettings.getInstance().isOpenGlMode()){
                PImage img = pa.loadImage(texturePath);
                if (Tools3D.isPowerOfTwoDimension(img)){
                  texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                }else{
                  texture = new GLTexture(pa, img, new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT));
                  // ((GLTexture)texture).setFilter(SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear);
View Full Code Here

TOP

Related Classes of processing.core.PImage

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.