0 Replies Latest reply: Apr 13, 2013 8:24 PM by KonradZuse RSS

    weird issue with set/get Layout() and Translate()

    KonradZuse
      Basically I was working on this last night and decided to add an "original" mesh and work based on that. I kept having issues where only 2 mesh's would display, and I wasn't sure why. Last night I was able to display as many as I needed, by setting the LayoutX each time, but now I am working with Translate.

      I realized that when I do
       original.setLayout
      it sets that layout, but when I get to
       meshV.setLayout(original.getLayout()) 
      it grabs the original layout of original, not the 100/100 updated one. The same thing happens when I try to translate. It only translates once, and keeps updating the original layout.

      I tried to use Translations, and do them based on previous locations instead, but when I try to get [d-1] where d = 1 I get a nullpointerException for some reason? I tried it when d = 2 also, and still nothing.
                                       meshV[d].setTranslateZ(meshV[d-1].getTranslateZ() + (meshV[d].getBoundsInLocal().getDepth() *meshV[d].getScaleZ())); 
      To me, all of this shouldn't happen, and I don't think I've ever had an issue like this, so I feel I'm doing something pretty stupid, but who knows :P.
      Caused by: java.lang.NullPointerException
           at Face.populate(Face.java:102)
           at Face.<init>(Face.java:52)
           at draw.<init>(draw.java:37)
           ... 8 more
      Java Result: 1
       protected final void populate()
                      {
                          MeshView original = new MeshView(this.mesh);
                          super.getChildren().add(original);
                          original.setLayoutX(100);
                          original.setLayoutY(100);
                          
                          original.setScaleX(10);
                          original.setScaleY(10);
                          original.setScaleZ(10);
                          r.setDiffuseColor(Color.RED);
                          original.setMaterial(r);
                        //  for(int w = 0; w < wide; w++)
                        //  {
                          //  for(int h = 0; h < high; h++)
                           // {
                            for(int d = 0; d < deep; d++)
                             { 
                            MeshView meshV = new MeshView(this.mesh);
      
                              p.setDiffuseColor(Color.AQUA);
                              meshV.setMaterial(p);
                              meshV.setScaleX(10);
                              meshV.setScaleY(10);
                              meshV.setScaleZ(10);
      
                              if(d ==0)
                              {
      
                                //  meshV[d].setLayoutX(original.getLayoutX());
                                 //meshV[d].setLayoutY(original.getLayoutY());
      
                              }
                              else if (d == 1)
                              {
                                  meshV.setTranslateZ(meshV.getBoundsInLocal().getDepth() *meshV.getScaleZ());
                              }
                              
                              else if (d == 2)
                              {
                                   meshV.setTranslateZ(500);
                              }
      
                              super.getChildren().add(meshV);
                              System.out.println("1");
                                      
                          }
                        //      System.out.println("2");
                        //  }
                        //  System.out.println("3");
                        //  }
                      }
      This code; however, will work.
                            for(int d = 0; d < deep; d++)
                          {
                              meshV = new MeshView(this.mesh);
                              p.setDiffuseColor(Color.AQUA);
                              meshV.setMaterial(p);
                              
                              meshV.setScaleX(10);
                              meshV.setScaleY(10);
                              meshV.setScaleZ(10);
                              if(d ==0)
                              {
                              meshV.setTranslateZ(0);
      
                              }
                              else
                              {
                                  meshV.setTranslateZ(super.getChildren().get(d-1).getTranslateZ() + meshV.getBoundsInLocal().getDepth() *meshV.getScaleZ());
                              }
                              super.getChildren().add(meshV);
                          }
      Granted I don't think we should ever use an array while using a group and their observableList, but I'm curious why it's happening :)


      Thanks,
      ~KZ

      Edited by: KonradZuse on Apr 13, 2013 6:23 PM