Adding Custom Controls with GUI

Hi,



I am trying to add a GhostControl to a spatial with the GUI.



I don’t know how the “Create Custom Control” wizard works internally but maybe the problem is, that it wants to call a non argument constructor.



As I noticed, for the GhostControl to work properly it must have been instantiated with a CollisionShape object, otherwise the setPhysicsLocation/setPhysicsRotation in the GhostControl’s setSpatial method will thow an exception.



Obviously the workaround could be to override the GhostControl’s setSpatial() method and modify it by setting the GhostControl’s CollisionShape just before the setPhysicsLocation method. In this case the GhostControl can be instantiated and added to a spatial without Exceptions.





I am just wondering… is there any other way to add GhostControl to a spatial with the SDK GUI?



Thanks!

never tried a ghostcontrol on the gui, maybe its possible, idk.



The GhostControl moves with the spatial, so try move the spatial instead

I don’t need to move the spatial actually; the setPhysicsLocation/setPhysicsRotation method came from the GhostControl’s setSpatial method.

Only controls with an empty constructor can be added, else you need to create your own “Create Control” entry, possibly with a wizard, in the SDK. This is easier than it sounds: https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:development:sceneexplorer#adding_items_to_the_add_and_tools_menus

Wow, I haven’t seen this tutorial yet. Thanks Normen.

Hm… I might have misunderstood something.



I have extended the AbstractNewControlAction according to the tutorial and left the resulting class it my project’s source folder next to the other classes.



The class is exactly the same ilke the one in the tutorial except that I’ve changed the name: name = “Static RigidBody2”;



Should I see the new “Static Rigidbody2” under the “Add Control…” submenu?

So nobody is using this feature?