0

Update: I updated my code to loop through the list of meshviews and add each to the group using group.getChildren.add(meshview[i]) but still does not show up on screen. Thanks.

I am trying to add an array list of MeshView type to a scene in JavaFx based GUI. I was able to get an initial example to work where it was one MeshView, but now I have a case where the data that is read in from a file results in an array of MeshView type. I could not find a "add" or "addAll" type function on the Group type to let me loop through all of the elements and add them and I could not get the Group constructor to let me add the list at ones in the arguments. I am using a Group to contain them because the over all GUI makes use of a BorderLayout defined using an FXML file. So my initial version adds the meshview to a group along with some point lights and then that group is added to the center of the border layout using the set method of it. Any help would be appreciated. Thanks.

Ps. I think I may have just found an answer. I forgot the add method is under the get children: group.getChildren().addAll(meshView, pointLight); as the line above from another answer shows. But I would still be interested in hearing the best ways because I still am confused on how to deal with sitaution where you have say 20 meshviews that make up a part to be shown on screen and you want to combine those and appropriate lights etc and scale to fit in center or borderlayout. I'm guessin I can first all all meshviews using add and then add the lights but was not sure. Thanks again.

user3064141
  • 407
  • 4
  • 17

1 Answers1

0

You can always add mesh views to any Node type object like Group or BorderLayout ex.

root.getChildren().add(meshView);

you can add as most as you can to this root object and translate the meshView in the scene

meshView.setTranslateX(200);
meshView.setTranslateY(200);
meshView.setTranslateZ(200);

and set the camera and lightpoints configuration and add them as well to the scene

Ahmed Emad
  • 674
  • 6
  • 19
  • If I'm adding more than one meshView to root in your example using say a loop where i'm looping and adding all of the meshviews in a MeshView list array, would I do that and then do any settings for lights, camera, etc. Thanks. – user3064141 Jul 28 '18 at 21:01
  • the lights and camera are added to the scene not the root so it's outside of the loop – Ahmed Emad Jul 29 '18 at 13:56