Implemented basic 3D start screen with no background race
#story[1301]
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.image.Image;
|
||||
@@ -14,9 +17,11 @@ import javafx.scene.media.AudioClip;
|
||||
import javafx.scene.media.Media;
|
||||
import javafx.scene.media.MediaPlayer;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.stage.Modality;
|
||||
import mock.exceptions.EventConstructionException;
|
||||
import visualiser.app.App;
|
||||
import visualiser.layout.SeaSurface;
|
||||
import visualiser.layout.SkyBox;
|
||||
import visualiser.layout.Subject3D;
|
||||
import visualiser.layout.View3D;
|
||||
@@ -49,15 +54,44 @@ public class TitleController extends Controller {
|
||||
ambientLight.setTranslateZ(210);
|
||||
ambientLight.setLightOn(true);
|
||||
|
||||
PointLight pointLight = new PointLight(Color.web("#AAAAFF"));
|
||||
pointLight.setTranslateX(250);
|
||||
pointLight.setTranslateZ(210);
|
||||
pointLight.setLightOn(true);
|
||||
|
||||
ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||
View3D view3D = new View3D();
|
||||
view3D.addAmbientLight(ambientLight);
|
||||
view3D.addPointLight(pointLight);
|
||||
view3D.setDistance(10);
|
||||
view3D.setPitch(5);
|
||||
view3D.setItems(subjects);
|
||||
|
||||
SkyBox skyBox = new SkyBox(750,200,250,0,250);
|
||||
subjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
|
||||
SeaSurface seaSurface = new SeaSurface(750, 200);
|
||||
seaSurface.setX(250);
|
||||
seaSurface.setZ(250);
|
||||
subjects.add(seaSurface);
|
||||
|
||||
URL asset = RaceViewController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
importer.read(asset);
|
||||
Subject3D boat = new Subject3D(new MeshView(importer.getImport()), 0);
|
||||
boat.setScale(0.1);
|
||||
subjects.add(boat);
|
||||
view3D.trackSubject(boat, -45);
|
||||
|
||||
view3DContainer.add(view3D, 0, 0);
|
||||
|
||||
AnimationTimer loop = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
boat.setZ(boat.getPosition().getZ() + 0.05);
|
||||
}
|
||||
};
|
||||
loop.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,7 +169,7 @@ public class View3D extends Pane {
|
||||
PickResult result = e.getPickResult();
|
||||
if(result != null && result.getIntersectedNode() != null && result.getIntersectedNode() instanceof Shape3D) {
|
||||
untrackSubject();
|
||||
trackSubject(shapeMap.get(result.getIntersectedNode()));
|
||||
trackSubject(shapeMap.get(result.getIntersectedNode()), 0);
|
||||
setThirdPerson();
|
||||
}
|
||||
});
|
||||
@@ -216,15 +216,16 @@ public class View3D extends Pane {
|
||||
/**
|
||||
* Set camera to follow the selected subject
|
||||
* @param subject to track
|
||||
* @param yaw to add to boat heading
|
||||
*/
|
||||
private void trackSubject(Subject3D subject) {
|
||||
public void trackSubject(Subject3D subject, double yaw) {
|
||||
target.set(subject);
|
||||
|
||||
this.trackBoat = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
updatePivot(target.get().getPosition());
|
||||
setYaw(target.get().getHeading().getAngle());
|
||||
setYaw(target.get().getHeading().getAngle() + yaw);
|
||||
}
|
||||
};
|
||||
trackBoat.start();
|
||||
|
||||
Reference in New Issue
Block a user