Dynamically add textures to ColorCube java3d

I am very new to java 3D and I would like to add texture to ColorCube()

. I found this page:

http://www.java-tips.org/other-api-tips/java3d/how-to-apply-a-texture-image-to-a-cube.html

However, I cannot get it to work, I am not sure how to implement it in my code:

 protected BranchGroup createCube() {
        BranchGroup bg = new BranchGroup();
        bg.setCapability(BranchGroup.ALLOW_DETACH);
        bg.addChild(new com.sun.j3d.utils.geometry.ColorCube());
        bg.setUserData("Cube");
        return bg;
    }

      

Finally, is it possible to dynamically change this texture?

How do I click a button or load a new texture and change it dynamically?

These are very broad questions, however I am very new to this.

+3


source to share





All Articles