private void initWidget() {
    SceneApplication.getApplication().addSceneListener(this);
    Sphere sphMesh = new Sphere(32, 32, 2.5f);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 2.5f, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    sphere = new Geometry("previewSphere", sphMesh);
    sphere.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_X));

    Box boxMesh = new Box(new Vector3f(0, 0, 0), 1.75f, 1.75f, 1.75f);
    TangentBinormalGenerator.generate(boxMesh);
    box = new Geometry("previewBox", boxMesh);
    box.setLocalRotation(
        new Quaternion()
            .fromAngleAxis(-FastMath.DEG_TO_RAD * 30, Vector3f.UNIT_X)
            .multLocal(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y)));

    Quad quadMesh = new Quad(4.5f, 4.5f);
    TangentBinormalGenerator.generate(quadMesh);
    quad = new Geometry("previewQuad", quadMesh);
    quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));

    currentGeom = sphere;
    sphereButton.setSelected(true);
    init = true;
  }
  private void doShowMaterial(Material m) {

    //        geom.setLocalTranslation(-2.5f, -2.5f, 0);
    //        geom.lookAt(new Vector3f(5, 5, 5), Vector3f.UNIT_Y);
    currentGeom.setMaterial(m);
    if (currentGeom.getMaterial() != null) {
      PreviewRequest request = new PreviewRequest(this, currentGeom);
      request.getCameraRequest().setLocation(new Vector3f(0, 0, 7));
      request.getCameraRequest().setLookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
      SceneApplication.getApplication().createPreview(request);
    }
  }
Example #3
0
  public DDSPreview(ProjectAssetManager assetManager) {
    this.assetManager = assetManager;

    Quad quadMesh = new Quad(4.5f, 4.5f);
    Quad quadMesh3D = new Quad(4.5f, 4.5f);
    quadMesh3D.scaleTextureCoordinates(new Vector2f(4, 4));
    quad = new Geometry("previewQuad", quadMesh);
    quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
    quad3D = new Geometry("previewQuad", quadMesh3D);
    quad3D.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
    material3D = new Material(assetManager, "com/jme3/gde/core/properties/preview/tex3DThumb.j3md");
    material3D.setFloat("InvDepth", 1f / 16f);
    material3D.setInt("Rows", 4);
    material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    SceneApplication.getApplication().addSceneListener(this);
  }
Example #4
0
  public void requestPreview(
      String textureName,
      String displayName,
      int width,
      int height,
      JComponent picLabel,
      JLabel infoLabel) {
    TextureKey key = new TextureKey(textureName);
    picPreview = picLabel;
    assetManager.deleteFromCache(key);
    Texture t = assetManager.loadTexture(key);
    Spatial geom = quad;
    if (key.getTextureTypeHint() == Texture.Type.TwoDimensional) {
      material.setTexture("ColorMap", t);
      geom.setMaterial(material);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + "    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight());
      }
    } else if (key.getTextureTypeHint() == Texture.Type.ThreeDimensional) {
      geom = quad3D;
      assetManager.deleteFromCache(key);
      key.setTextureTypeHint(Texture.Type.ThreeDimensional);
      t = assetManager.loadTexture(key);
      material3D.setTexture("Texture", t);
      geom.setMaterial(material3D);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + " (Texture3D)    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight()
                + "    d : "
                + t.getImage().getDepth());
      }
    } else if (key.getTextureTypeHint() == Texture.Type.CubeMap) {
      assetManager.deleteFromCache(key);
      geom = SkyFactory.createSky(assetManager, textureName, SkyFactory.EnvMapType.CubeMap);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + " (CubeMap)    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight());
      }
    }

    PreviewRequest request = new PreviewRequest(this, geom, width, height);
    request.getCameraRequest().setLocation(new Vector3f(0, 0, 5.3f));
    request.getCameraRequest().setLookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y.mult(-1));
    SceneApplication.getApplication().createPreview(request);
  }
Example #5
0
 public void cleanUp() {
   SceneApplication.getApplication().removeSceneListener(this);
 }