Login  Register

Dificuldades ao usar ArrayList para adicionar multiplos objectos LineArray ao Grafo de Cenas com ActionEvent em Tempo de Execução

Posted by Helton Antunes on Feb 24, 2025; 3:37pm
URL: https://forum.jogamp.org/Dificuldades-ao-usar-ArrayList-para-adicionar-multiplos-objectos-LineArray-ao-Grafo-de-Cenas-com-Acto-tp4043684.html

Hello all Dev in the community, I'm new to Java and I recently started exploring and learning the Java3D API and I'm having a lot of difficulties in the process of developing a simple project. My idea is to add multiple LineArray objects to each mouse click at Runtime.

This is a piece of code where I can simply render a single line.



 public static java.util.ArrayList < javax.media.j3d.Shape3D > modelos_3d = new java.util.ArrayList < javax.media.j3d.Shape3D >();
       
        public static java.util.ArrayList < javax.media.j3d.TransformGroup > transform_grp = new java.util.ArrayList < javax.media.j3d.TransformGroup >();
       
        public static javax.media.j3d.Shape3D forma3D = new javax.media.j3d.Shape3D();

        public static javax.media.j3d.TransformGroup transform_group = new javax.media.j3d.TransformGroup();
       
       
       
        public static void line_array()
        {
       
            javax.media.j3d.BranchGroup branch_grupo = new javax.media.j3d.BranchGroup();//OBS: O grafo de cenas

           
            LineArray line_array = new LineArray(2, LineArray.COORDINATES|LineArray.COLOR_3);
           
           
           
            line_array.setCoordinate(0, new javax.vecmath.Point3f(-0.8f,0.8f,0f));
       
            line_array.setColor(0,new javax.vecmath.Color3f(Color.RED));
           
           
            graphics_engine.line_array.add(line_array);
           
           
            for(int i = 0; i < graphics_engine.line_array.size(); i++)
            {
               
                 
                    graphics_engine.forma3D.setCapability(graphics_engine.forma3D.ALLOW_GEOMETRY_WRITE);

                    graphics_engine.modelos_3d.add(graphics_engine.forma3D);
                    //graphics_engine.forma3D.setGeometry(line_array);
                    graphics_engine.forma3D.setGeometry(graphics_engine.line_array.get(i));


                    graphics_engine.transform_group.setCapability(graphics_engine.transform_group.ALLOW_TRANSFORM_WRITE);


                    graphics_engine.transform_group.addChild(graphics_engine.modelos_3d.get(i));


                    branch_grupo.addChild(graphics_engine.transform_group);

                    gui_components.objecto_branch_grupo.addChild(branch_grupo);

               
            }
           
        }









But when I turn the javax.media.j3d.Shape3D object into a vector, nothing is rendered on the screen. This is code that I'm using after making this change.


public static java.util.ArrayList < javax.media.j3d.Shape3D > modelos_3d = new java.util.ArrayList < javax.media.j3d.Shape3D >();
       
        public static java.util.ArrayList < javax.media.j3d.TransformGroup > transform_grp = new java.util.ArrayList < javax.media.j3d.TransformGroup >();
       
        public static javax.media.j3d.Shape3D forma3D[]; //= new javax.media.j3d.Shape3D();

        public static javax.media.j3d.TransformGroup transform_group = new javax.media.j3d.TransformGroup();
       
       
       
        public static void line_array()
        {
       
            javax.media.j3d.BranchGroup branch_grupo = new javax.media.j3d.BranchGroup();//OBS: O grafo de cenas

           
            LineArray line_array = new LineArray(2, LineArray.COORDINATES|LineArray.COLOR_3);
           
           
           
            line_array.setCoordinate(0, new javax.vecmath.Point3f(-0.8f,0.8f,0f));
       
            line_array.setColor(0,new javax.vecmath.Color3f(Color.RED));
           
           
            graphics_engine.line_array.add(line_array);
           
           
            for(int i = 0; i < graphics_engine.line_array.size(); i++)
            {
               
                 
                    graphics_engine.forma3D[i].setCapability(graphics_engine.forma3D[i].ALLOW_GEOMETRY_WRITE);

                    graphics_engine.modelos_3d.add(graphics_engine.forma3D[i]);
                    //graphics_engine.forma3D.setGeometry(line_array);
                    graphics_engine.forma3D[i].setGeometry(graphics_engine.line_array.get(i));


                    graphics_engine.transform_group.setCapability(graphics_engine.transform_group.ALLOW_TRANSFORM_WRITE);


                    graphics_engine.transform_group.addChild(graphics_engine.modelos_3d.get(i));


                    branch_grupo.addChild(graphics_engine.transform_group);

                    gui_components.objecto_branch_grupo.addChild(branch_grupo);

               
            }
           
        }



I would like to know and learn how I could do this or what I am doing wrong in this algorithm, all help, teachings and criticism is always welcome.

Thank you in advance for everyone's help. Thank you very muchThis is the result produced when I run the idea of the first algorithm