Examples of GLTextureSettings


Examples of org.mt4j.util.opengl.GLTextureSettings

//              textureToRenderTo.initTexture(rectC.width, rectC.height);
//            }
//          });
//      }
     
      GLTextureSettings ts = new GLTextureSettings();
      ts.shrinkFilter = SHRINKAGE_FILTER.BilinearNoMipMaps;
//      ts.shrinkFilter = SHRINKAGE_FILTER.Trilinear; //For better quality
      ts.expansionFilter = EXPANSION_FILTER.Bilinear;
      ts.wrappingHorizontal = WRAP_MODE.CLAMP_TO_EDGE;
      ts.wrappingVertical = WRAP_MODE.CLAMP_TO_EDGE;
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

    //Create the earth
    earth = new MTSphere(pa, "earth", 40, 40, 80, TextureMode.Projected); //TextureMode.Polar);
    earth.setLight(light);
    earth.setMaterial(material);
    earth.rotateX(earth.getCenterPointRelativeToParent(), -90);
    earth.setTexture(new GLTexture(pa,imagesPath + "worldMap.jpg", new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        earth.generateAndUseDisplayLists();
        earth.setPositionGlobal(new Vector3D(pa.width/2f, pa.height/2f, 250)); //earth.setPositionGlobal(new Vector3D(200, 200, 250));
        //Animate earth rotation
        new Animation("rotation animation", new MultiPurposeInterpolator(0,360, 17000, 0, 1, -1) , earth).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
            earth.rotateY(earth.getCenterPointLocal(), ae.getCurrentStepDelta(), TransformSpace.LOCAL);
          }}).start();
       
        //Put planets in a group that can be manipulated by gestures
        //so the rotation of the planets doesent get changed by the gestures
    MTComponent group = new MTComponent(mtApplication);
    group.setComposite(true); //This makes the group "consume" all picking and gestures of the children
    group.registerInputProcessor(new DragProcessor(mtApplication));
    group.addGestureListener(DragProcessor.class, new DefaultDragAction());
    group.addGestureListener(DragProcessor.class, new InertiaDragAction(80, 0.8f, 10));
    group.registerInputProcessor(new RotateProcessor(mtApplication));
    group.addGestureListener(RotateProcessor.class, new DefaultRotateAction());
    //Scale the earth from the center. Else it might get distorted
    group.registerInputProcessor(new ScaleProcessor(mtApplication));
    group.addGestureListener(ScaleProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        earth.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), earth.getCenterPointGlobal());
        return false;
      }
    });
    this.getCanvas().addChild(group);
        group.addChild(earth);
       
        //Create the moon
        final MTSphere moonSphere = new MTSphere(pa, "moon", 35, 35, 25, TextureMode.Polar);
         moonSphere.setMaterial(material);
        moonSphere.translate(new Vector3D(earth.getRadius() + moonSphere.getRadius() + 50, 0,0));
        moonSphere.setTexture(new GLTexture(pa, imagesPath + "moonmap1k.jpg", new GLTextureSettings(TEXTURE_TARGET.RECTANGULAR, SHRINKAGE_FILTER.Trilinear, EXPANSION_FILTER.Bilinear, WRAP_MODE.CLAMP_TO_EDGE, WRAP_MODE.CLAMP_TO_EDGE)));
        moonSphere.generateAndUseDisplayLists();
        moonSphere.unregisterAllInputProcessors();
        //Rotate the moon around the earth
        new Animation("moon animation", new MultiPurposeInterpolator(0,360, 12000, 0, 1, -1) , moonSphere).addAnimationListener(new IAnimationListener(){
          public void processAnimationEvent(AnimationEvent ae) {
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

      if (MT4jSettings.getInstance().isOpenGlMode())
        this.getGeometryInfo().updateTextureBuffer(this.isUseVBOs());
    }
   
    if (MT4jSettings.getInstance().isOpenGlMode()){
      GLTextureSettings g = new GLTextureSettings(TEXTURE_TARGET.TEXTURE_2D, SHRINKAGE_FILTER.BilinearNoMipMaps, EXPANSION_FILTER.Bilinear, WRAP_MODE.REPEAT, WRAP_MODE.REPEAT);
      GLTexture tex;
      if (pot){
        tex = new GLTexture(mtApp, bgImage, g);
      }else{
        if (tiled){
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

                    }
                   
                    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);
                    }
                    }else{
                      texture = pa.loadImage(basePath + tFile);
                    }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

                }
                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);
                }
              }else{
                texture = pa.loadImage(texturePath);
              }
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

////          "blackRoundSolidCorner64sh2.png", tp);
//      GLTexture glTex = new GLTexture(app, menuImage.width, menuImage.height, tp);
//      glTex.putPixelsIntoTexture(menuImage);
//      this.setTexture(glTex);
     
      GLTextureSettings ts = new GLTextureSettings();
      ts.wrappingHorizontal = WRAP_MODE.CLAMP;
      ts.wrappingVertical = WRAP_MODE.CLAMP;
      GLTexture glTex = new GLTexture(app, menuImage.width, menuImage.height, ts);
      glTex.loadGLTexture(menuImage);
      this.setTexture(glTex);
View Full Code Here

Examples of org.mt4j.util.opengl.GLTextureSettings

        //FIXME always save last tex dimensions? also if POT?
        this.lastTextureDimension.setXYZ(newTexImage.width, newTexImage.height, 0);
      }else{
        //We are in OpenGL mode but the new texture is not a GLTexture -> create new GLTexture from PImage
        boolean isPOT = Tools3D.isPowerOfTwoDimension(newTexImage);
        GLTextureSettings ts = new GLTextureSettings();
        if (!isPOT){
          ts.target = TEXTURE_TARGET.RECTANGULAR;
          this.setTextureMode(PConstants.IMAGE);
         
          if (this.getGeometryInfo().isTextureCoordsNormalized()){
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.