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 bc079e70 authored by Bordais Anaelle's avatar Bordais Anaelle
Browse files

Permieère version

parent 493a81e9
......@@ -589,7 +589,6 @@ public class Nomad3DEditor extends Application {
camera = new PerspectiveCamera();
camera.setNearClip(0.1);
camera.setFarClip(Double.MAX_VALUE);
subScene.setCamera(camera);
}
......
......@@ -4,6 +4,7 @@ import javafx.geometry.Point2D;
import javafx.geometry.Point3D;
import javafx.scene.Camera;
import javafx.scene.Node;
import javafx.scene.shape.Sphere;
import javafx.scene.transform.Affine;
import javafx.scene.transform.NonInvertibleTransformException;
import javafx.scene.transform.Rotate;
......@@ -64,16 +65,16 @@ public class CameraControls {
*/
public CameraControls() {
this.longitude = 0;
this.latitude = 45;
this.latitude = 45; // 45 de base
this.center = new Point3D(0, 0, 0);
this.radius = 100;
this.radius = 100; //100 de base
this.target = null;
this.centerNode = null;
this.controlMultiplier = 10;
this.shiftMultiplier = 0.1;
this.rotationSensitivity = 0.1;
this.translationSensitivity = 0.25;
this.translationSensitivity = 0.0; //0.25 de base
this.zoomSensitivity = 0.5;
this.setResolution(new Point2D(1280, 720));
......@@ -81,6 +82,27 @@ public class CameraControls {
this.centerTransform = new Translate();
}
/** Copy constructor**/
public CameraControls(CameraControls cam){
this.longitude = cam.longitude;
this.latitude = cam.latitude;
this.center = cam.center;
this.radius = cam.radius;
this.target = cam.target;
this.centerNode = cam.centerNode;
this.controlMultiplier = cam.controlMultiplier;
this.shiftMultiplier = cam.shiftMultiplier;
this.rotationSensitivity = cam.rotationSensitivity;
this.translationSensitivity = cam.translationSensitivity;
this.zoomSensitivity = cam.zoomSensitivity;
this.setResolution(cam.getResolution());
this.transform = cam.getTransform();
this.centerTransform = cam.getCenterTransform();
}
/**
* Gets the longitude.
* @return The longitude
......@@ -399,6 +421,10 @@ public class CameraControls {
* Must be called when a parameter is changed.
*/
public void update() {
System.out.println("Vue Avant corps update: \n "+"resolution"+ resolution+ "center " + center + ", angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
target.getTransforms().remove(transform);
transform.setToIdentity();
if (centerNode != null) {
......@@ -407,19 +433,52 @@ public class CameraControls {
centerTransform = new Translate(center.getX(), center.getY(), center.getZ());
transform.append(centerTransform);
Rotate rx = new Rotate(longitude, Rotate.Y_AXIS);
transform.append(rx);
Rotate ry = new Rotate(latitude, Rotate.X_AXIS);
System.out.println("YAXIS ROT: \n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
Rotate ry = new Rotate(latitude, Rotate.X_AXIS);
transform.append(ry);
Rotate rz = new Rotate(180, Rotate.Z_AXIS);
System.out.println("XAXIS ROT \n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
Rotate rz = new Rotate(180, Rotate.Z_AXIS);//180 de base
transform.append(rz);
Translate t = new Translate(-resolution.getX()/2, -resolution.getY()/2, radius);
System.out.println("ZAXIS ROT \n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
Translate t = new Translate(-resolution.getX()/2, -resolution.getY()/2, radius); // de base avec radius
transform.append(t);
System.out.println("TRANSLATE RESOLUTION\n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
// Translate t2 = new Translate(0, 0, radius); // elle n'y est pas
// transform.append(t2);
// System.out.println("TRANSLATE RADIUS \n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
// System.out.println("Transform matrix : "+ transform);
// System.out.println("Center transform matrix :" + centerTransform);
//
target.getTransforms().add(transform);
if (centerNode != null) {
centerNode.getTransforms().add(centerTransform);
}
System.out.println("APRES TOUT UPDATE: \n "+"resolution"+ resolution+ "center " + center + "\n angles " + longitude + ", " + latitude + ", radius " + radius);
System.out.println("Transform matrix : "+ transform);
System.out.println("Center transform matrix :" + centerTransform);
//System.out.println(target.);
System.out.println("-----------------------------------------------------");
System.out.println("view direction" + viewDirection());
}
/**
......
......@@ -2,6 +2,9 @@ package fr.ill.ics.n3d.gui;
import java.io.File;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Scanner;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -9,6 +12,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;
import java.util.logging.Logger;
......@@ -71,15 +75,20 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Sphere;
import javafx.scene.text.TextAlignment;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.converter.DoubleStringConverter;
import javafx.geometry.Point3D;
/**
* Menu bar of the Nomad3DEditor.getInstance().
......@@ -101,6 +110,10 @@ public class EditorMenuBar extends MenuBar {
/** Selection menu. */
private Menu selection;
// -------- JE RAJOUTE---------
/**CameraView menu**/
private Menu cameraView;
/** Help menu. */
private Menu help;
......@@ -2674,8 +2687,237 @@ public class EditorMenuBar extends MenuBar {
this.help.getItems().addAll(cameraHelpItem, wikiItem);
update();
//--------- RAJOUTE-----------
this.cameraView = new Menu("Camera View");
MenuItem setCamViewItem = new MenuItem("Set Camera POVs");
setCamViewItem.setOnAction(e->{
// if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getRoot() == null) {
// return;
// }
GridPane scenePane = new GridPane();
scenePane.setPadding(new Insets(30));
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setTitle(setCamViewItem.getText());
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
TableView<CameraControls> table = new TableView();
//table.setEditable(true);
// // Set column
TableColumn<CameraControls, Point3D > firstColumn = new TableColumn<>("Center");
firstColumn.setMinWidth(300);
// TableColumn xcol = new TableColumn("xcol");
// xcol.setMinWidth(130);
//
//
// TableColumn ycol = new TableColumn("ycol");
// ycol.setMinWidth(130);
// xcol.setCellValueFactory(new PropertyValueFactory<CameraControls, Point3D.Double>("x"));
// ycol.setCellValueFactory(new PropertyValueFactory<Point3D, Double>("y"));
// firstColumn.getColumns().addAll(xcol, ycol);
firstColumn.setCellValueFactory(new PropertyValueFactory<CameraControls, Point3D>("center"));
TableColumn<CameraControls, Double > column2 = new TableColumn<>("Latitude");
column2.setMinWidth(100);
column2.setCellValueFactory(new PropertyValueFactory<CameraControls, Double>("latitude"));
TableColumn<CameraControls, Double > column3 = new TableColumn<>("Longitude");
column3.setMinWidth(100);
column3.setCellValueFactory(new PropertyValueFactory<CameraControls, Double>("Longitude"));
TableColumn<CameraControls, Double > column4 = new TableColumn<>("Radius");
column4.setMinWidth(100);
column4.setCellValueFactory(new PropertyValueFactory<CameraControls, Double>("radius"));
final ObservableList<CameraControls> data = FXCollections.observableArrayList();
//Button
Button addButton = new Button("Add");
Button deleteButton = new Button("Delete");
Button exportButton = new Button ("Export camera views");
Button viewButton = new Button("See camera view");
// Buttons actions
addButton.setOnAction(event->{
CameraControls cam = Nomad3DEditor.getInstance().getControls();
// Point3D center = cam.getCenter();
// double latitude = cam.getLatitude();
// double longitude = cam.getLongitude();
// double radius = cam.getRadius();
CameraControls newCam = new CameraControls(cam);
data.add(newCam);
});
deleteButton.setOnAction(event->{
ObservableList<CameraControls> camSelected, allCams;
allCams = table.getItems(); // gets all the items in the table
camSelected = table.getSelectionModel().getSelectedItems();
camSelected.forEach(allCams::remove);
});
exportButton.setOnAction(event->{
// // TO DO
// FileChooser fileChooser = new FileChooser();
// fileChooser.setTitle("Open Resource File");
// File file = fileChooser.showOpenDialog(displayStage);
//
Stage fileStage = new Stage();
fileStage.setTitle("File path");
fileStage.setWidth(400);
HBox fileBox = new HBox();
Label fileLabel = new Label("File Path : ");
TextField fileInput = new TextField();
fileInput.setPromptText("filepath.txt");
Button createFileButton = new Button("Create file");
fileBox.getChildren().addAll(fileLabel, fileInput, createFileButton);
fileBox.setSpacing(20);
Scene fileScene = new Scene(fileBox);
fileStage.setScene(fileScene);
fileStage.show();
createFileButton.setOnAction(eventButton->{
fileStage.close();
try {
String fileName = fileInput.getText();
File file = new File(fileName);
System.out.println("Filename :" + fileName);
if (file.createNewFile()) {
System.out.println("File has been created.");
} else {
System.out.println("File already exists.");
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
data.forEach((CameraControls)->{
// ----------- TO DO : REVOIR LES CONVERSIONS -----------------
// la distance va pas et le centre non plus, si on change ca marche pas
String radiusString = Double.toString(-CameraControls.getRadius());
String latitudeString = Double.toString((-CameraControls.getLatitude()+180.0)*Math.PI/180);
String longitudeString = Double.toString((-CameraControls.getLongitude()+180.0)*Math.PI/180);
String rotAxisZString = Double.toString((Math.PI));
String xString = Double.toString(-CameraControls.getCenter().getX());
String yString = Double.toString(-CameraControls.getCenter().getY());
String zString = Double.toString(-CameraControls.getCenter().getZ());
try {
bw.write(xString+" ");
bw.write(yString+" ");
bw.write(zString+" ");
bw.write(latitudeString+" ");
bw.write(longitudeString + " ");
bw.write(rotAxisZString + " ");
bw.write(radiusString + " " );
bw.write("\n");}
catch(IOException error) {
}
});
bw.close();}
catch(IOException error) {
}
});});
viewButton.setOnAction(event->{
CameraControls cam = Nomad3DEditor.getInstance().getControls();
System.out.println("resolution : " + cam.getResolution()+"control multiplier :"+ cam.getControlMultiplier() +"center : " + cam.getCenter() + "latitude :" + cam.getLatitude() + "longitude :" + cam.getLongitude() +"radius" + cam.getRadius());
cam = table.getSelectionModel().getSelectedItem();
System.out.println("ligne selectionnée : " + cam);
System.out.println("resolution : " + cam.getResolution()+"control multiplier :"+ cam.getControlMultiplier()+"center : " + cam.getCenter() + "latitude :" + cam.getLatitude() + "longitude :" + cam.getLongitude() +"radius" + cam.getRadius());
System.out.println("Avant Update");
cam.update();
System.out.println("Apres Update, Fin view Butoon action");
});
// HBOX for buttons
HBox hbox = new HBox();
hbox.setPadding(new Insets(10,10,10,10));
hbox.setSpacing(10);
hbox.getChildren().addAll(addButton, deleteButton, exportButton, viewButton);
table.setItems(data);
table.getColumns().addAll(firstColumn, column2, column3, column4);
scenePane.addRow(0, table, hbox);
displayStage.show();
});
this.cameraView.getItems().addAll(setCamViewItem);
MenuItem sphereItem = new MenuItem("Sphere");
sphereItem.setOnAction(event->{
Sphere sphere = new Sphere(10);
Group roottt = Nomad3DEditor.getInstance().getRoot();
roottt.getChildren().add(sphere);
GridPane scenePane = new GridPane();
scenePane.setPadding(new Insets(30));
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setTitle(setCamViewItem.getText());
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
Sphere spherex = new Sphere(10);
spherex.setLayoutX(100);
roottt.getChildren().add(spherex);
Sphere spherey = new Sphere(10);
spherey.setLayoutY(200);
roottt.getChildren().add(spherey);
Sphere spherez = new Sphere(10);
spherez.setTranslateZ(300);
roottt.getChildren().add(spherez);
HBox box = new HBox();
Button radiusButton = new Button("SetRadius");
TextField radiusInput = new TextField();
box.getChildren().addAll(radiusInput, radiusButton);
radiusButton.setOnAction(e->{
sphere.setRadius(Double.parseDouble(radiusInput.getText()));
});
scenePane.addRow(0, box);
displayStage.show();
update();
});
this.cameraView.getItems().addAll(sphereItem);
this.getMenus().addAll(this.file, this.edit, this.view, this.selection, this.cameraView, this.help);
this.getMenus().addAll(this.file, this.edit, this.view, this.selection, this.help);
//---------------------------------------------- FIN RAJOUTE
}
private void applyValue(String value) {
......@@ -2730,7 +2972,7 @@ public class EditorMenuBar extends MenuBar {
String text = "Current Value ";
if (type == Axis.Type.ROTATION) {
text += "";
text += "";
} else if (type == Axis.Type.TRANSLATION) {
text += "mm";
}
......
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