@erlend_sh said:
If you could put together some images or even a video to showcase the impact of these latest feature additions that would make it a lot easier to see up front what has improved. Also I would have something pretty to push out to the interwebs :P
Good idea! I'll do when I'm finished, I still have some tweaks to do! ^^
@Sploreg said:
kickass! Send me the diff and I can add it in.
Can you give your opinion if this is ok. I put the logic on TerrainTool on the same method that the sub-classes can override. Maybe this method should be final and then it would call the method that sub-classes can override, and the sub-classes can only change
useStraightLine boolean.
[patch]Index: com/jme3/gde/terraineditor/tools/TerrainTool.java
===================================================================
--- com/jme3/gde/terraineditor/tools/TerrainTool.java (revisĂŁo 9682)
+++ com/jme3/gde/terraineditor/tools/TerrainTool.java (cĂłpia de trabalho)
@@ -34,6 +34,7 @@
import com.jme3.asset.AssetManager;
import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.terraineditor.ExtraToolParams;
+import com.jme3.input.KeyInput;
import com.jme3.input.event.KeyInputEvent;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
@@ -62,6 +63,10 @@
protected float radius;
protected float weight;
protected float maxToolSize = 20; // override in sub classes
+ protected boolean useStraightLine = true;
+ private boolean doStraightline = false;
+ private Vector3f startPress;
+ private Vector3f axis;
private Meshes mesh;
public static enum Meshes {
@@ -94,7 +99,15 @@
/**
* Key was pressed.
*/
- public void keyPressed(KeyInputEvent kie) {}
+ public void keyPressed(KeyInputEvent kie) {
+ if (useStraightLine && kie.getKeyCode() == KeyInput.KEY_LCONTROL) {
+ doStraightline = kie.isPressed();
+ if (!doStraightline) { // Clean the values
+ startPress = null;
+ axis = null;
+ }
+ }
+ }
/**
* Location of the primary editor marker
@@ -111,8 +124,36 @@
* @param newLoc
*/
public void markerMoved(Vector3f newLoc) {
- if (markerPrimary != null)
- markerPrimary.setLocalTranslation(newLoc);
+ if (markerPrimary != null) {
+ if (!useStraightLine || (!doStraightline && useStraightLine))
+ markerPrimary.setLocalTranslation(newLoc); // if we're not using the straight line feature or the key isn't pressed
+ else {
+ if (startPress == null)
+ startPress = newLoc.clone(); // the user just started presseing
+ else {
+ Vector3f sub = newLoc.subtract(startPress);
+ if (axis == null) {
+ // grab the axis that the user is moving
+ Vector3f closest = Vector3f.UNIT_X;
+ float dist = sub.distance(closest);
+ float ddist;
+ if ((ddist = sub.distance(Vector3f.UNIT_Z)) < dist) {
+ closest = Vector3f.UNIT_Z;
+ dist = ddist;
+ }
+ if ((ddist = sub.distance(Vector3f.UNIT_Z.negate())) < dist) {
+ closest = Vector3f.UNIT_Z;
+ dist = ddist;
+ }
+ if (sub.distance(Vector3f.UNIT_X.negate()) < dist) {
+ closest = Vector3f.UNIT_X;
+ }
+ axis = closest;
+ }
+ markerPrimary.setLocalTranslation(sub.mult(axis).add(startPress)); // move the marker in straight line
+ }
+ }
+ }
}
/**
Index: com/jme3/gde/terraineditor/tools/SlopeTerrainTool.java
===================================================================
--- com/jme3/gde/terraineditor/tools/SlopeTerrainTool.java (revisĂŁo 9682)
+++ com/jme3/gde/terraineditor/tools/SlopeTerrainTool.java (cĂłpia de trabalho)
@@ -47,6 +47,7 @@
import com.jme3.scene.Spatial;
import com.jme3.scene.control.BillboardControl;
import com.jme3.scene.shape.Line;
+import com.jme3.scene.shape.Quad;
import com.jme3.scene.shape.Sphere;
import org.openide.loaders.DataObject;
@@ -123,6 +124,7 @@
@Override
public void keyPressed(KeyInputEvent kie) {
+ super.keyPressed(kie);
switch (kie.getKeyCode()) {
case KeyInput.KEY_LCONTROL:
leftCtrl = kie.isPressed();[/patch]