Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java3D mipmap level problem.

1012772Jun 22 2017

Hello,

I'm new in the 3D world, therefore I apology whether my questions are stupide.

I'm trying to  make  a cube to  rotate with different pictures on its 6 faces.  I looked at different forums  to understand how things work:  The only examples I have found was with different colors (not images).

Unfortunately I spent many hours  without success.

When I start my class below, (I'm testing under  Eclipse for the moment), I get the  message :  Texture: mipmap image not set at level0

I'm running  with JAVA  1.8.0_131-b11 and i Jave installed all J3 modules.

After many tries  and reading  a lot of documents, I should admit  I do not understand the link betweeen the way to define a TextureCubeMap occurence and the way to specify the level of added images.

Thanks in advance for any help, and sorry for my bad English.

Gérard

package test;

import java.awt.Graphics2D;

import javax.imageio.ImageIO;

import javax.media.j3d.Alpha;

import javax.media.j3d.Appearance;

import javax.media.j3d.BoundingSphere;

import javax.media.j3d.BranchGroup;

import javax.media.j3d.Canvas3D;

import javax.media.j3d.ImageComponent2D;

import javax.media.j3d.RotationInterpolator;

import javax.media.j3d.Texture;

import javax.media.j3d.TextureAttributes;

import javax.media.j3d.TextureCubeMap;

import javax.media.j3d.Transform3D;

import javax.media.j3d.TransformGroup;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.vecmath.Point3d;

import com.sun.j3d.utils.geometry.Box;

import com.sun.j3d.utils.universe.SimpleUniverse;

import java.awt.BorderLayout;

import java.awt.image.BufferedImage;

import java.io.File;

public class Cube extends JFrame

{

    private static final long serialVersionUID = 1L;

    private static final int IMG_WIDTH = 128;

    private static final int IMG_HEIGHT = 128;

    private  ImageComponent2D[] myImages  = new ImageComponent2D[6] ;

    private SimpleUniverse universe = null;

    private BranchGroup root = null;

   

    public Cube()

    {

        process() ;

    }

    private void  process()

    {

        créerImages();

        getContentPane().setLayout(null);

        setSize(300,300 );

        JPanel canvasPanel = new JPanel();

        canvasPanel.setLayout(new BorderLayout());

        canvasPanel.setBounds(10, 11, 256, 256);

        Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());

        universe = new SimpleUniverse(canvas);

        universe.getViewingPlatform().setNominalViewingTransform();

        root = new BranchGroup();

        root = createSceneGraph();

        universe.addBranchGraph(root);

       

        canvasPanel.add(canvas);

        getContentPane().add(canvasPanel);

        this.setLocationRelativeTo(null);

        setVisible(true);

    }

   

     private  void créerImages()

     {

         File img = null;

         ImageComponent2D[] myImages  = new ImageComponent2D[6] ;

         BufferedImage buffImg = null, newImg = null;

         String[] photos = {"Steven.jpg", "Steven Paul.jpg","Steven.jpg", "Steven Paul.jpg", "Steven.jpg", "Steven Paul.jpg"};

         String  userdir  =     System.getProperties().getProperty("user.dir") ;

         try

         {

             for (int i=0; i<myImages.length; i++)

              {     

                  img = new File(userdir + File.separator + "Images" + File.separator + photos[i] );

                  buffImg = ImageIO.read(img );

                  int type = buffImg.getType() == 0? BufferedImage.TYPE_INT_ARGB : buffImg.getType();

                  newImg  = resizeImage(buffImg, type);

                  myImages[i] = new ImageComponent2D(ImageComponent2D.FORMAT_RGB,newImg );

              }

         }

         catch (Exception ex)

         {

                System.out.println(ex.getMessage());

                System.exit(1);

        }

     }

    public BranchGroup createSceneGraph()

      {

         try

           {

             int mipmaplevel = 0;

             TransformGroup objTrans = new TransformGroup();

             objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

             root.addChild(objTrans);

             

             Appearance app = new Appearance();

             TextureCubeMap tex = new TextureCubeMap(Texture.BASE_LEVEL,Texture.RGB, IMG_WIDTH);

             tex.setCapability(Texture.ALLOW_ENABLE_WRITE);

             tex.setImage(mipmaplevel, TextureCubeMap.POSITIVE_X,   myImages[0]);

             tex.setImage(mipmaplevel, TextureCubeMap.NEGATIVE_X,   myImages[1]);

             tex.setImage(mipmaplevel, TextureCubeMap.POSITIVE_Y,   myImages[2]);

             tex.setImage(mipmaplevel, TextureCubeMap.NEGATIVE_Y,   myImages[3]);

             tex.setImage(mipmaplevel, TextureCubeMap.POSITIVE_Z,   myImages[4]);

             tex.setImage(mipmaplevel, TextureCubeMap.NEGATIVE_Z,   myImages[5]);

             app.setTexture(tex);

             TextureAttributes texAttr = new TextureAttributes();

             texAttr.setTextureMode(TextureAttributes.MODULATE);

             app.setTextureAttributes(texAttr);

        

            Box textureCube = new Box(0.4f, 0.4f, 0.4f,   Box.GENERATE_TEXTURE_COORDS, app);

            objTrans.addChild(textureCube);

         

          

            Transform3D yAxis = new Transform3D();

            Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

        

            RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,  objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f);

            BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

            rotator.setSchedulingBounds(bounds);

            objTrans.addChild(rotator);

        

            // Je compile ma scene.

                root.compile();

         

            return root;

       }

       catch (Exception ex)

           {

               System.out.println(ex.toString()); System.exit(1);}

               return null;

        }

    

     private static BufferedImage resizeImage(BufferedImage originalImage, int type)

      {

            BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);

            Graphics2D g = resizedImage.createGraphics();

            g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);

            g.dispose();

            return resizedImage;

      }

     public static void main(String[] args)

     {

         new Cube();

     }

}

                          new Cube();

                       }

}

Comments

Create a custom authentication process and check for the entry in your custom table for that user.

van Baal HR
Answer

That is just what I did. I have created a separate package with a function and a procedure in it, that uses the user defined table to select the user data from. Then I changed the code behind the login process to call for the newly created package. I have pretty much used the concept posed here: http://o7planning.org/en/10443/custom-authentication-in-oracle-apex#a1349999

Marked as Answer by van Baal HR · Sep 27 2020
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 20 2017
Added on Jun 22 2017
0 comments
495 views