Skip to content

Commit 7679ebd

Browse files
committed
updated transform tools
1 parent 962d286 commit 7679ebd

33 files changed

Lines changed: 1111 additions & 575 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
* [Wiki](https://bitbucket.org/JavaSabr/jme3-spaceshift-editor/wiki/Home)
55
* [Download](https://yadi.sk/d/UuKcJBNgqbV3a)
6+
* [Gitter](https://gitter.im/jME3-SpaceShift-Editor/Lobby?source=orgpage)
67
* [Official jMonkey thread](https://hub.jmonkeyengine.org/t/jme3-spaceshift-editor/35179)
78
* [Youtube channel](https://www.youtube.com/playlist?list=PLNdOH0eRoQMBkLPBvTIDn02UFhcTJWsh7)
89

9-
## [Video about this editor](https://www.youtube.com/watch?v=I9ads0-I_LI&feature=youtu.be) ##
10+
## [Video about this editor](https://youtu.be/h6azH-D28qk) ##
1011

1112
## ver. 0.9.10 ##
1213
* -Added supporting macOS.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sourceCompatibility = 1.8
88
targetCompatibility = 1.8
99

1010
ext.jmeVersion = "3.2_branch-SNAPSHOT"
11-
ext.jme3_xbuf_version = '213c6a499d'
11+
ext.jme3_xbuf_version = '0.9.1'
1212
ext.lwjglVersion = "3.1.2"
1313

1414
repositories {

src/main/java/com/jme3/scene/Spatial.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -366,24 +366,6 @@ protected void setMatParamOverrideRefresh() {
366366
}
367367
}
368368

369-
/**
370-
* Indicate that the bounding of this spatial has changed and that
371-
* a refresh is required.
372-
*/
373-
protected void setBoundRefresh() {
374-
refreshFlags |= RF_BOUND;
375-
376-
Spatial p = parent;
377-
while (p != null) {
378-
if ((p.refreshFlags & RF_BOUND) != 0) {
379-
return;
380-
}
381-
382-
p.refreshFlags |= RF_BOUND;
383-
p = p.parent;
384-
}
385-
}
386-
387369
/**
388370
* (Internal use only) Forces a refresh of the given types of data.
389371
*
@@ -451,6 +433,24 @@ public boolean checkCulling(Camera cam) {
451433
return frustrumIntersects != Camera.FrustumIntersect.Outside;
452434
}
453435

436+
/**
437+
* Indicate that the bounding of this spatial has changed and that
438+
* a refresh is required.
439+
*/
440+
protected void setBoundRefresh() {
441+
refreshFlags |= RF_BOUND;
442+
443+
Spatial p = parent;
444+
while (p != null) {
445+
if ((p.refreshFlags & RF_BOUND) != 0) {
446+
return;
447+
}
448+
449+
p.refreshFlags |= RF_BOUND;
450+
p = p.parent;
451+
}
452+
}
453+
454454
/**
455455
* Sets the name of this spatial.
456456
*

src/main/java/com/ss/editor/Editor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ private static void configureLogger() {
138138
run(() -> createDirectories(logFolder));
139139
}
140140

141-
LoggerManager.addListener(new FolderFileListener(logFolder));
141+
if (!LoggerLevel.DEBUG.isEnabled()) {
142+
LoggerManager.addListener(new FolderFileListener(logFolder));
143+
}
142144
}
143145

144146
/**

src/main/java/com/ss/editor/Messages.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ public class Messages {
455455
* The constant MODEL_FILE_EDITOR_FAST_SKY.
456456
*/
457457
public static final String MODEL_FILE_EDITOR_FAST_SKY;
458+
/**
459+
* The constant MODEL_FILE_EDITOR_TRANSFORM_MODE.
460+
*/
461+
public static final String MODEL_FILE_EDITOR_TRANSFORM_MODE;
458462
/**
459463
* The constant MODEL_FILE_EDITOR_NODE_MESH.
460464
*/
@@ -2422,6 +2426,7 @@ public class Messages {
24222426
MODEL_FILE_EDITOR_NAME = bundle.getString("ModelFileEditorName");
24232427
MODEL_FILE_EDITOR_NO_SKY = bundle.getString("ModelFileEditorNoSky");
24242428
MODEL_FILE_EDITOR_FAST_SKY = bundle.getString("ModelFileEditorFastSky");
2429+
MODEL_FILE_EDITOR_TRANSFORM_MODE = bundle.getString("ModelFileEditorTransformMode");
24252430
MODEL_FILE_EDITOR_NODE_MESH = bundle.getString("ModelFileEditorNodeMesh");
24262431
MODEL_FILE_EDITOR_NODE_AMBIENT_LIGHT = bundle.getString("ModelFileEditorNodeAmbientLight");
24272432
MODEL_FILE_EDITOR_NODE_DIRECTION_LIGHT = bundle.getString("ModelFileEditorNodeDirectionLight");

src/main/java/com/ss/editor/config/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public abstract class Config {
7070
* The flag to enable debug of camera moving.
7171
*/
7272
public static final boolean DEV_CAMERA_DEBUG;
73+
/**
74+
* The flag to enable debug of transforms controls.
75+
*/
76+
public static final boolean DEV_TRANSFORMS_DEBUG;
7377
/**
7478
* Flag is for showing debug of the JavaFX.
7579
*/
@@ -92,6 +96,7 @@ public abstract class Config {
9296

9397
DEV_DEBUG = vars.getBoolean("Dev.debug", false);
9498
DEV_CAMERA_DEBUG = vars.getBoolean("Dev.cameraDebug", false);
99+
DEV_TRANSFORMS_DEBUG = vars.getBoolean("Dev.transformsDebug", false);
95100
DEV_DEBUG_JFX_KEY_INPUT = vars.getBoolean("Dev.jfxKeyInput", false);
96101
DEV_DEBUG_JFX = vars.getBoolean("Dev.debugJFX", false);
97102
ENABLE_PBR = vars.getBoolean("Graphics.enablePBR", true);
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package com.ss.editor.control.transform;
2+
3+
import static com.ss.rlib.util.ObjectUtils.notNull;
4+
import com.jme3.collision.CollisionResult;
5+
import com.jme3.math.Quaternion;
6+
import com.jme3.math.Transform;
7+
import com.jme3.math.Vector3f;
8+
import com.jme3.scene.Geometry;
9+
import com.jme3.scene.Node;
10+
import com.jme3.scene.control.AbstractControl;
11+
import com.ss.editor.Editor;
12+
import com.ss.editor.control.transform.EditorTransformSupport.PickedAxis;
13+
import com.ss.rlib.logging.Logger;
14+
import com.ss.rlib.logging.LoggerManager;
15+
import org.jetbrains.annotations.NotNull;
16+
17+
/**
18+
* The base implementation of transform control.
19+
*
20+
* @author JavaSaBr
21+
*/
22+
public abstract class AbstractTransformControl extends AbstractControl implements TransformControl {
23+
24+
/**
25+
* The logger.
26+
*/
27+
@NotNull
28+
protected static final Logger LOGGER = LoggerManager.getLogger(MoveToolControl.class);
29+
30+
/**
31+
* The editor.
32+
*/
33+
@NotNull
34+
protected static final Editor EDITOR = Editor.getInstance();
35+
36+
/**
37+
* The scene editor controller.
38+
*/
39+
@NotNull
40+
private final EditorTransformSupport editorControl;
41+
42+
/**
43+
* The collision plane.
44+
*/
45+
@NotNull
46+
private final Node collisionPlane;
47+
48+
/**
49+
* The parent node.
50+
*/
51+
@NotNull
52+
private final Node parentNode;
53+
54+
/**
55+
* The child node.
56+
*/
57+
@NotNull
58+
private final Node childNode;
59+
60+
/**
61+
* Instantiates a new Rotation tool control.
62+
*
63+
* @param editorControl the editor control
64+
*/
65+
public AbstractTransformControl(@NotNull final EditorTransformSupport editorControl) {
66+
this.editorControl = editorControl;
67+
this.collisionPlane = notNull(editorControl.getCollisionPlane());
68+
this.parentNode = new Node("Parent");
69+
this.childNode = new Node("Child");
70+
this.parentNode.attachChild(childNode);
71+
}
72+
73+
/**
74+
* @return the collision plane.
75+
*/
76+
@NotNull
77+
protected Node getCollisionPlane() {
78+
return collisionPlane;
79+
}
80+
81+
/**
82+
* @return the scene editor controller.
83+
*/
84+
@NotNull
85+
protected EditorTransformSupport getEditorControl() {
86+
return editorControl;
87+
}
88+
89+
/**
90+
* @return the parent node.
91+
*/
92+
@NotNull
93+
protected Node getParentNode() {
94+
return parentNode;
95+
}
96+
97+
/**
98+
* @return the child node.
99+
*/
100+
@NotNull
101+
protected Node getChildNode() {
102+
return childNode;
103+
}
104+
105+
@Override
106+
public void setCollisionPlane(@NotNull final CollisionResult collisionResult) {
107+
108+
final EditorTransformSupport editorControl = getEditorControl();
109+
final Transform transform = editorControl.getTransformCenter();
110+
111+
if (transform == null) {
112+
LOGGER.warning(this, "not found transform center for the " + editorControl);
113+
return;
114+
}
115+
116+
detectPickedAxis(editorControl, collisionResult);
117+
118+
// set the collision Plane location and rotation
119+
final Node collisionPlane = getCollisionPlane();
120+
collisionPlane.setLocalTranslation(transform.getTranslation());
121+
collisionPlane.setLocalRotation(Quaternion.IDENTITY);
122+
}
123+
124+
protected void detectPickedAxis(@NotNull final EditorTransformSupport editorControl,
125+
@NotNull final CollisionResult collisionResult) {
126+
127+
final Geometry geometry = collisionResult.getGeometry();
128+
final String geometryName = geometry.getName();
129+
130+
if (geometryName.contains(getNodeX())) {
131+
editorControl.setPickedAxis(PickedAxis.X);
132+
} else if (geometryName.contains(getNodeY())) {
133+
editorControl.setPickedAxis(PickedAxis.Y);
134+
} else if (geometryName.contains(getNodeZ())) {
135+
editorControl.setPickedAxis(PickedAxis.Z);
136+
}
137+
}
138+
139+
@NotNull
140+
protected Vector3f getPickedVector(@NotNull final Transform transform, @NotNull final PickedAxis pickedAxis) {
141+
if (pickedAxis == PickedAxis.Y) {
142+
return Vector3f.UNIT_Y;
143+
} else if (pickedAxis == PickedAxis.Z) {
144+
return Vector3f.UNIT_Z;
145+
} else return Vector3f.UNIT_X;
146+
}
147+
148+
@NotNull
149+
protected String getNodeX() {
150+
throw new RuntimeException();
151+
}
152+
153+
@NotNull
154+
protected String getNodeY() {
155+
throw new RuntimeException();
156+
}
157+
158+
@NotNull
159+
protected String getNodeZ() {
160+
throw new RuntimeException();
161+
}
162+
}

0 commit comments

Comments
 (0)