New SDK tool: Blender-esque selection and manipulation

I recently changed the selection tool to behave as the manipulation in Blender operates. This should make using the SDK in conjunction with Blender a little easier to get used to.



In summary it operates as so:

Left-Click: to set cursor

Right-Click: to select a spatial (selection now selects the node parent, not the geometry

Middle-Click: rotate the camera

Middle-Click + Shift: pan the camera

G: grab and translate the selected object, left-click to set it when you are done moving

R: rotate an object, left-click to set it when you are done rotating

S: scale an object, left-click to set it when you are done scaling

As with blender you can hit X,Y, or Z to select the axis to translate/rotate/scale along. After typing an axis you can then type in a number, such as -90 to rotate -90 degrees along the y-axis (after you hit enter). Example: G X 30 Enter: moves the object 30 units along the X-axis.

Shift+D: duplicate an object, puts you in grab mode.

X: deletes an object



Hit Esc or right-click to exit a transformation.



Panel options:

  • You can now have the spatial that you are grabbing/translating snap to objects in the scene, such as the terrain
  • The grabbing/translation of an object can be restricted to grid (integer) points. This will be configurable in the future.
  • You can ignore terrain selection when selecting objects

    http://i.imgur.com/Z2cSG.png



    Remaining issues:
  • Currently the scene composer does not receive focus if you just right-click or middle-mouse click on the scene, and then the keyboard commands won’t respond. You have to first left-click then they will work.
  • Option to hold Ctrl or Alt to have fixed rotations and scales as you manipulate



    This is currently in the nightly version of the SDK.



    If there is anything else you would like added to the tool please submit a patch and I will get it in there asap. The class is com.jme3.gde.scenecomposer.tools.SelectTool and has lots of documentation, and should be easy to modify.
11 Likes

Awesome!

I’ll test it asap

Awesome, amazing that you were able to add the functionality within a week, after I first posted the question xD



thx :slight_smile:

1 Like
@nightmare2real said:
Awesome, amazing that you were able to add the functionality within a week, after I first posted the question xD

You hold amazing sway over our development cycle, hehe :)

@Sploreg, Nice work.

Here are the issues I ran into :

1- The G key does not seem to work. I hit G with my object selected and move the mouse but nothing happens.

(to be thorough I checked that my G key does type a “g” in a text window. It could have been the reason considering the number of times I spilled some coffee on my keyboard :D)



2- Sometime when I select a geom i have this exception (not every time though)



java.lang.NullPointerException

at com.jme3.gde.scenecomposer.tools.SelectTool.isTerrain(SelectTool.java:791)

at com.jme3.gde.scenecomposer.tools.SelectTool.actionSecondary(SelectTool.java:414)

at com.jme3.gde.scenecomposer.SceneComposerToolController.doEditToolActivatedSecondary(SceneComposerToolController.java:192)

at com.jme3.gde.scenecomposer.ComposerCameraController.checkClick(ComposerCameraController.java:95)

at com.jme3.gde.core.scene.controller.AbstractCameraController.update(AbstractCameraController.java:511)

at com.jme3.app.state.AppStateManager.update(AppStateManager.java:255)

[catch] at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:276)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:227)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:619)





3- Typing an axis works fine, but entering a value with the num pad does not seem to work. (the view short cuts seems to trigger instead).



More minor issues are :

4- The scene explorer does not refresh when you duplicate an object (and btw the the grab mode does not trigger itself upon duplication, maybe that related with issue 1)

5- The bounding box rotates/scales around its center and not around the center of the geom.



More “nice to have” features :

6- In blender when initiating a grab/rotate/scale, the right click cancels it (like esc key)

7- The hot key in blender for duplicating is shift+D, why ctrl+shift+D?



Ofc i can help to resolve those issues, let me know if you want me to look into them

Thanks for the feedback Remy.

  1. I’m not sure why G stopped working 8O
  2. For that exception, it shouldn’t be selecting null… but I just added in a check where the NPE happened.
  3. Hmm yea it might take some fiddling to get this to work, I will see what I can do
  4. noted, will fix
  5. ya it’s annoying, it treats itself as a completely separate geometry and it isn’t quite matched up correctly
  6. should be easy enough to do
  7. I think shift+D conflicted with something else in netbeans, but maybe I had a weird key mapping. I will set it to shift+D and see how it goes.



    I should be able to tackle these ones today.

okay I fixed 1,2,4,5,6,7. Changes should be in tonight’s nightly build.

The selection box can be a little big sometimes since it is generated from the bounding box and then transformed. So if you are rotated and then select the object, the box will be reasonably large, and not a snug fit. But it seems okay for now.

1 Like

@Sploreg is the blender control is option or set to stone? For me, I am a maya user so its will be difficult for me to adapt to new behavior. Especially, right click selection.



You might want to put the binding information to an external config file, so I might be able to hack my way in.

It’s semi-set right now. The key commands will be flexible in the near future however and you will be able to customize them. However the main order of operations to move, rotate, translate (mouse clicks etc) will remain fixed.

@Sploreg said:
However the main order of operations to move, rotate, translate (mouse clicks etc) will remain fixed.


What do you mean by the order of operation?

Well for example you would be able to change the G for ‘grab’ to say ‘T’. But then it would still be: ‘T x 30 Enter’ to translate 30 along the x-axis. It would just be the key mapping that would be interchangeable, not what the tool does itself.

@Sploreg:

I can’t tell how much I love these features, since back a while I have to write my own tool to make such a translation, I’m deeply appreciated. A few things I wish can be added to the tool. :

  1. Is there a Mode that user can decide when they want to choose “Select Node or Select Geometry” <= this is important because sometime the Geometry position when wrong…
  2. The scale tool axis-lock by keyboard is cool, but what if we can scale XY,YZ, ZX by just drag in the working plane on the gizmo ( just like drag to move)?
  3. Some time I like the gizmo look extractly the same in every zoom level ( yeah, like in other 3D editors)… Maybe an option for that too…
  4. The snap feature is simply awesome !!!
  5. May be when the whole things in a good status, you may have time think about the organization of the SceneComposer panel :stuck_out_tongue: … It’s now not feel like really organized!
  6. Do you think about using nifty GUI for such tool UI, I did in game translate tool with nifty, and it’s feel cool :stuck_out_tongue:



    Yeah and I have a clear view of what code you have added or removed, :stuck_out_tongue: cause I kept tracking and read them dozen of times, tell me if you need some help…
1 Like

Thanks for the feedback @atomix!

Some of these should be easy to implement.


  1. ya I could add in a key or checkbox for that
  2. good idea
  3. I’m not sure what you mean here…
  4. thanks, I like it too :slight_smile:
  5. ya it needs to evolve a bit and be cleaned up
  6. I don’t plan to introduce any nifty UI into the editor tools. Mixing it with swing will be confusing
  1. I meant let set the ToolNode (which I called the gizmo) scale to fit in 100px x 100px square on the screen, when we zoom, the Tool Node 's scaled too, so, even if we are very far from the position, the ToolNode is look extractly the same. Maybe we can have a checkbox for that feature, the implementation of it it fairly simple, we just have to know the Width and Height of the current Camera.



    I think you can write the code but if you don’t have time, I will send my code here :stuck_out_tongue:

Oh I see what you mean.

If you have the code to implement that piece it is more than welcome :slight_smile:

[java]

float constantSize = 10f;

@Override

protected void controlUpdate(float tpf) {

if (camFix) {

Vector3f cursorPos = gizmo.getWorldTranslation();

Vector3f campos = cam.getLocation();

float dis2 = campos.distance(cursorPos);



float scale = dis2 / constantSize ;

float customScale = 2.5f;

float camScale = getCamFOV() / constantSize;

float camScaleFix = camScale * camScale;

gizmo.setLocalScale(scale * customScale * camScale);

}



}



// Get the camera FOV

public float getCamFOV() {

float h = cam.getFrustumTop();

float w = cam.getFrustumRight();

float near = cam.getFrustumNear();

float fovY = FastMath.atan(h / near)

/ (FastMath.DEG_TO_RAD * .5f);

//return fovY * FastMath.RAD_TO_DEG;



return fovY;

}

[/java]

P/s: The gizmo is the ToolNode in SceneApplication . I call it gizmo because i also use gizmo in my in-game editing. So I don’t directly use ToolNode