Help with instancing objects at runtime with Custom controls

Hello,



I am working on a project that I hope can make it to the contest. However I have one question.



Is there a way to add objects to a scene at runtime from a custom control and not from SimpleApplication of there is a way around it?



I ask because I might have many scenes and objects so I was wondering a way to do this.



Thanks

You think the wrong way around. Your appState should attach the spatials and then it can give whatever control whatever it needs from the application (best it only needs appStates). You can load a j3o and then pass parameters to controls e.g. like this:

[java]

Node scene = (Node)assetManager.loadMode(model);

scene.getChild("spatial_with_control").getControl(MyControl.class).setApplication(app);

[/java]



Edit: btw if your spatial is a Node you can easily attach children to it :wink:

thanks normen!



I now know how to put up everything together the way I wanted.