The code.ill.fr has been recreated and upgraded with the latest version this weekend, If you encounter any problem please inform the Helpdesk.

Commit 0691722e authored by legoc's avatar legoc
Browse files

Better lighting

parent 03b537a8
......@@ -115,6 +115,18 @@ public class Nomad3DEditor extends Application {
/** The editor menu bar. */
private EditorMenuBar menuBar;
/** Front light */
private PointLight frontLight;
/** Back light */
private PointLight backLight;
/** Left light */
private PointLight leftLight;
/** Right light */
private PointLight rightLight;
/** Title of the editor's window. */
public final static String TITLE = "Nomad3D Editor";
......@@ -537,38 +549,39 @@ public class Nomad3DEditor extends Application {
root.getChildren().add(new AmbientLight(Color.color(0.3, 0.3, 0.3)));
Color pointColor = Color.color(0.5, 0.5, 0.5);
PointLight light = null;
double lightHeight = sceneBox.getMinY() + 1.1 * sceneBox.getHeight();
double coef = 10.0;
double interval = sceneBox.getMaxZ() - sceneBox.getMinZ();
// Front.
frontLight = new PointLight(pointColor);
frontLight.setTranslateX(0.0);
frontLight.setTranslateY(0.0);
frontLight.setTranslateZ(sceneBox.getMinZ() - interval * coef);
root.getChildren().add(frontLight);
// Back.
// light = new PointLight(pointColor);
// light.setTranslateX(0.0);
// light.setTranslateY(0.0);
// light.setTranslateZ(sceneBox.getMaxZ() * coef);
// root.getChildren().add(light);
backLight = new PointLight(pointColor);
backLight.setTranslateX(0.0);
backLight.setTranslateY(0.0);
backLight.setTranslateZ(sceneBox.getMaxZ() + interval * coef);
root.getChildren().add(backLight);
// Front.
light = new PointLight(pointColor);
light.setTranslateX(0.0);
light.setTranslateY(0.0);
light.setTranslateZ(-sceneBox.getMaxZ() * coef);
root.getChildren().add(light);
interval = sceneBox.getMaxX() - sceneBox.getMinX();
// Left.
leftLight = new PointLight(pointColor);
leftLight.setTranslateX(sceneBox.getMaxX() + interval * coef);
leftLight.setTranslateY(0.0);
leftLight.setTranslateZ(0.0);
root.getChildren().add(leftLight);
// Right.
light = new PointLight(pointColor);
light.setTranslateX(-sceneBox.getMaxX() * coef);
light.setTranslateY(0.0);
light.setTranslateZ(0.0);
root.getChildren().add(light);
// Left.
light = new PointLight(pointColor);
light.setTranslateX(sceneBox.getMaxX() * coef);
light.setTranslateY(0.0);
light.setTranslateZ(0.0);
root.getChildren().add(light);
rightLight = new PointLight(pointColor);
rightLight.setTranslateX(sceneBox.getMinX() - interval * coef);
rightLight.setTranslateY(0.0);
rightLight.setTranslateZ(0.0);
root.getChildren().add(rightLight);
}
/**
......@@ -727,4 +740,20 @@ public class Nomad3DEditor extends Application {
resetCamera(component, false);
}
public void enableFrontLight(boolean value) {
frontLight.setLightOn(value);
}
public void enableBackLight(boolean value) {
backLight.setLightOn(value);
}
public void enableLeftLight(boolean value) {
leftLight.setLightOn(value);
}
public void enableRightLight(boolean value) {
rightLight.setLightOn(value);
}
}
......@@ -114,6 +114,12 @@ public class EditorMenuBar extends MenuBar {
/** Walls visibility. */
private boolean showWalls;
/** Lights */
private boolean frontLight = true;
private boolean backLight = true;
private boolean leftLight = true;
private boolean rightLight = true;
/** Show type. */
private Component.ShowType showType;
......@@ -2535,7 +2541,48 @@ public class EditorMenuBar extends MenuBar {
Nomad3DEditor.getInstance().getControls().right();
});
cameraMenu.getItems().addAll(topItem, bottomItem, frontItem, backItem, rightItem, leftItem);
Menu lightsMenu = new Menu("Lights");
CheckMenuItem frontLightItem = new CheckMenuItem("Front");
frontLightItem.setSelected(this.backLight);
frontLightItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
frontLight = frontLightItem.isSelected();
Nomad3DEditor.getInstance().enableFrontLight(frontLight);
}
});
CheckMenuItem backLightItem = new CheckMenuItem("Back");
backLightItem.setSelected(this.backLight);
backLightItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
backLight = backLightItem.isSelected();
Nomad3DEditor.getInstance().enableBackLight(backLight);
}
});
CheckMenuItem leftLightItem = new CheckMenuItem("Left");
leftLightItem.setSelected(this.leftLight);
leftLightItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
leftLight = leftLightItem.isSelected();
Nomad3DEditor.getInstance().enableLeftLight(leftLight);
}
});
CheckMenuItem rightLightItem = new CheckMenuItem("Right");
rightLightItem.setSelected(this.rightLight);
rightLightItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rightLight = rightLightItem.isSelected();
Nomad3DEditor.getInstance().enableRightLight(rightLight);
}
});
lightsMenu.getItems().addAll(frontLightItem, backLightItem, leftLightItem, rightLightItem);
this.lodMenu = new Menu("Level of detail");
updateLodMenu();
......@@ -2635,7 +2682,7 @@ public class EditorMenuBar extends MenuBar {
statsStage.show();
}
});
this.view.getItems().addAll(cameraMenu, new SeparatorMenuItem(), lodMenu, new SeparatorMenuItem(), showAxesItem, showSystemItem, showWallsItem, new SeparatorMenuItem(), resetMoveItem, moveToZeroItem, new SeparatorMenuItem(), statsItem);
this.view.getItems().addAll(cameraMenu, lightsMenu, new SeparatorMenuItem(), lodMenu, new SeparatorMenuItem(), showAxesItem, showSystemItem, showWallsItem, new SeparatorMenuItem(), resetMoveItem, moveToZeroItem, new SeparatorMenuItem(), statsItem);
this.selection = new Menu("Selection");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment