SDK SceneComposer : - added local, global and camera choice into the scenecomposer, this option is displayed into the SceneComposer Window close to scene edit tool.

- the scale tool still only work as local
- the camera option still need some enhancement
experimental
Maselbas 10 years ago
parent d48c1e0e9d
commit 0eac437862
  1. 41
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java
  2. 22
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  3. 26
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditTool.java
  4. 18
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/MoveTool.java
  5. 15
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/PickManager.java
  6. 9
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/RotateTool.java
  7. 11
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/ScaleTool.java

@ -10,6 +10,7 @@ import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.core.scene.controller.SceneToolController;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
import com.jme3.gde.scenecomposer.tools.PickManager;
import com.jme3.input.event.KeyInputEvent;
import com.jme3.light.Light;
import com.jme3.light.PointLight;
@ -50,7 +51,12 @@ public class SceneComposerToolController extends SceneToolController {
private boolean snapToScene = false;
private boolean selectTerrain = false;
private boolean selectGeometries = false;
private TransformationType transformationType = TransformationType.local;
public enum TransformationType {
local, global, camera
}
public SceneComposerToolController(final Node toolsNode, AssetManager manager, JmeNode rootNode) {
super(toolsNode, manager);
this.rootNode = rootNode;
@ -347,8 +353,37 @@ public class SceneComposerToolController extends SceneToolController {
public void setSelectGeometries(boolean selectGeometries) {
this.selectGeometries = selectGeometries;
}
public void setTransformationType(String type) {
if(type != null){
if(type.equals("Local")){
setTransformationType(transformationType.local);
} else if(type.equals("Global")){
setTransformationType(TransformationType.global);
} else if(type.equals("Camera")){
setTransformationType(TransformationType.camera);
}
}
}
/**
* @return the transformationType
*/
public TransformationType getTransformationType() {
return transformationType;
}
/**
* @param transformationType the transformationType to set
*/
public void setTransformationType(TransformationType type) {
if(type != this.transformationType){
this.transformationType = type;
if(editTool != null){
//update the transform type of the tool
editTool.setTransformType(transformationType);
}
}
}
/**
* A marker on the screen that shows where a point light or

@ -97,6 +97,8 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
sceneInfoLabel1 = new javax.swing.JLabel();
sceneInfoLabel2 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
transformationTypeComboBox = new javax.swing.JComboBox();
jSeparator9 = new javax.swing.JToolBar.Separator();
selectButton = new javax.swing.JToggleButton();
moveButton = new javax.swing.JToggleButton();
rotateButton = new javax.swing.JToggleButton();
@ -165,6 +167,16 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
transformationTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Local", "Global", "Camera" }));
transformationTypeComboBox.setMaximumSize(new java.awt.Dimension(160, 50));
transformationTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
transformationTypeComboBoxActionPerformed(evt);
}
});
jToolBar1.add(transformationTypeComboBox);
jToolBar1.add(jSeparator9);
spatialModButtonGroup.add(selectButton);
selectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/scenecomposer/icon_select.png"))); // NOI18N
selectButton.setSelected(true);
@ -207,6 +219,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
}
});
jToolBar1.add(rotateButton);
rotateButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.rotateButton.AccessibleContext.accessibleDescription")); // NOI18N
spatialModButtonGroup.add(scaleButton);
scaleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/scenecomposer/icon_arrow_inout.png"))); // NOI18N
@ -221,6 +234,8 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
}
});
jToolBar1.add(scaleButton);
scaleButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.scaleButton.AccessibleContext.accessibleDescription")); // NOI18N
jToolBar1.add(jSeparator5);
jToggleScene.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/scenecomposer/snapScene.png"))); // NOI18N
@ -644,6 +659,11 @@ private void jToggleSelectTerrainActionPerformed(java.awt.event.ActionEvent evt)
private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleSelectGeomActionPerformed
toolController.setSelectGeometries(jToggleSelectGeom.isSelected());
}//GEN-LAST:event_jToggleSelectGeomActionPerformed
private void transformationTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transformationTypeComboBoxActionPerformed
toolController.setTransformationType((String)transformationTypeComboBox.getSelectedItem());
}//GEN-LAST:event_transformationTypeComboBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton camToCursorSelectionButton;
private javax.swing.JButton createPhysicsMeshButton;
@ -671,6 +691,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
private javax.swing.JSeparator jSeparator6;
private javax.swing.JToolBar.Separator jSeparator7;
private javax.swing.JToolBar.Separator jSeparator8;
private javax.swing.JToolBar.Separator jSeparator9;
private javax.swing.JTextField jTextField1;
private javax.swing.JToggleButton jToggleGrid;
private javax.swing.JToggleButton jToggleScene;
@ -692,6 +713,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
private javax.swing.JToggleButton showGridToggleButton;
private javax.swing.JToggleButton showSelectionToggleButton;
private javax.swing.ButtonGroup spatialModButtonGroup;
private javax.swing.JComboBox transformationTypeComboBox;
// End of variables declaration//GEN-END:variables
private void emit(Spatial root) {

@ -57,7 +57,8 @@ public abstract class SceneEditTool {
protected Node axisMarker;
protected Material redMat, blueMat, greenMat, yellowMat, cyanMat, magentaMat, orangeMat;
protected Geometry quadXY, quadXZ, quadYZ;
protected SceneComposerToolController.TransformationType transformType;
protected enum AxisMarkerPickType {
axisOnly, planeOnly, axisAndPlane
@ -72,6 +73,7 @@ public abstract class SceneEditTool {
public void activate(AssetManager manager, Node toolNode, Node onTopToolNode, Spatial selectedSpatial, SceneComposerToolController toolController) {
this.manager = manager;
this.toolController = toolController;
this.setTransformType(toolController.getTransformationType());
//this.selectedSpatial = selectedSpatial;
addMarker(toolNode, onTopToolNode);
}
@ -130,7 +132,19 @@ public abstract class SceneEditTool {
public void doUpdateToolsTransformation() {
if (toolController.getSelectedSpatial() != null) {
axisMarker.setLocalTranslation(toolController.getSelectedSpatial().getWorldTranslation());
axisMarker.setLocalRotation(toolController.getSelectedSpatial().getLocalRotation());
switch (transformType) {
case local:
axisMarker.setLocalRotation(toolController.getSelectedSpatial().getLocalRotation());
break;
case global:
axisMarker.setLocalRotation(Quaternion.IDENTITY);
break;
case camera:
if(camera != null){
axisMarker.setLocalRotation(camera.getRotation());
}
break;
}
setAxisMarkerScale(toolController.getSelectedSpatial());
} else {
axisMarker.setLocalTranslation(Vector3f.ZERO);
@ -487,4 +501,12 @@ public abstract class SceneEditTool {
public void setCamera(Camera camera) {
this.camera = camera;
}
public SceneComposerToolController.TransformationType getTransformType() {
return transformType;
}
public void setTransformType(SceneComposerToolController.TransformationType transformType) {
this.transformType = transformType;
}
}

@ -103,25 +103,19 @@ public class MoveTool extends SceneEditTool {
}
if (pickedMarker.equals(QUAD_XY)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_XZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(ARROW_X)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_X; // move only X
} else if (pickedMarker.equals(ARROW_Y)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Y; // move only Y
} else if (pickedMarker.equals(ARROW_Z)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Z; // move only Z
}
startPosition = toolController.getSelectedSpatial().getLocalTranslation().clone();

@ -5,6 +5,7 @@
*/
package com.jme3.gde.scenecomposer.tools;
import com.jme3.gde.scenecomposer.SceneComposerToolController;
import com.jme3.gde.scenecomposer.SceneEditTool;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
@ -35,10 +36,6 @@ public class PickManager {
protected static final Quaternion PLANE_YZ = new Quaternion().fromAngleAxis(-FastMath.PI / 2, new Vector3f(0, 1, 0));//YAW090
protected static final Quaternion PLANE_XZ = new Quaternion().fromAngleAxis(FastMath.PI / 2, new Vector3f(1, 0, 0)); //PITCH090
public enum TransformationType {
local, global, camera
}
public PickManager() {
float size = 1000;
@ -55,7 +52,7 @@ public class PickManager {
spatial = null;
}
public void initiatePick(Spatial selectedSpatial, Quaternion planeRotation, TransformationType type, Camera camera, Vector2f screenCoord) {
public void initiatePick(Spatial selectedSpatial, Quaternion planeRotation, SceneComposerToolController.TransformationType type, Camera camera, Vector2f screenCoord) {
spatial = selectedSpatial;
startSpatialLocation = selectedSpatial.getWorldTranslation().clone();
@ -65,16 +62,16 @@ public class PickManager {
startPickLoc = SceneEditTool.pickWorldLocation(camera, screenCoord, plane, null);
}
public void setTransformation(Quaternion planeRotation, TransformationType type) {
public void setTransformation(Quaternion planeRotation, SceneComposerToolController.TransformationType type) {
Quaternion rot = new Quaternion();
if (type == TransformationType.local) {
if (type == SceneComposerToolController.TransformationType.local) {
rot.set(spatial.getWorldRotation());
rot.multLocal(planeRotation);
origineRotation = spatial.getWorldRotation().clone();
} else if (type == TransformationType.global) {
} else if (type == SceneComposerToolController.TransformationType.global) {
rot.set(planeRotation);
origineRotation = new Quaternion(Quaternion.IDENTITY);
} else if (type == TransformationType.camera) {
} else if (type == SceneComposerToolController.TransformationType.camera) {
rot.set(planeRotation);
origineRotation = planeRotation.clone();
}

@ -96,14 +96,11 @@ public class RotateTool extends SceneEditTool {
}
if (pickedMarker.equals(QUAD_XY)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_XZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
} else if (pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ,
PickManager.TransformationType.local, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
}
startRotate = toolController.getSelectedSpatial().getLocalRotation().clone();
}

@ -97,18 +97,15 @@ public class ScaleTool extends SceneEditTool {
if (pickedMarker.equals(QUAD_XY) || pickedMarker.equals(QUAD_XZ) || pickedMarker.equals(QUAD_YZ)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), camera.getRotation(),
PickManager.TransformationType.camera, camera, screenCoord);
SceneComposerToolController.TransformationType.camera, camera, screenCoord);
} else if (pickedMarker.equals(ARROW_X)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY,
PickManager.TransformationType.global, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XY, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_X; // scale only X
} else if (pickedMarker.equals(ARROW_Y)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ,
PickManager.TransformationType.global, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_YZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Y; // scale only Y
} else if (pickedMarker.equals(ARROW_Z)) {
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ,
PickManager.TransformationType.global, camera, screenCoord);
pickManager.initiatePick(toolController.getSelectedSpatial(), PickManager.PLANE_XZ, getTransformType(), camera, screenCoord);
constraintAxis = Vector3f.UNIT_Z; // scale only Z
}
startScale = toolController.getSelectedSpatial().getLocalScale().clone();

Loading…
Cancel
Save