|
|
|
@ -2,49 +2,51 @@ package visualiser.layout;
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.geometry.Point3D;
|
|
|
|
import javafx.geometry.Point3D;
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
|
|
|
|
import javafx.scene.media.AudioClip;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
import javafx.scene.shape.*;
|
|
|
|
import javafx.scene.shape.*;
|
|
|
|
import javafx.scene.transform.Rotate;
|
|
|
|
import javafx.scene.transform.Rotate;
|
|
|
|
import javafx.scene.transform.Translate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Created by zwu18 on 24/09/17.
|
|
|
|
* Created by zwu18 on 24/09/17.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class FireParticle extends Subject3D {
|
|
|
|
public class HealthEffect extends Subject3D {
|
|
|
|
|
|
|
|
|
|
|
|
private int sourceID;
|
|
|
|
private int sourceID;
|
|
|
|
private long currentTime;
|
|
|
|
private long currentTime;
|
|
|
|
private long flashInterval;
|
|
|
|
private long flashInterval;
|
|
|
|
|
|
|
|
private AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/warning.mp3").toExternalForm());
|
|
|
|
|
|
|
|
|
|
|
|
public FireParticle(int sourceID, long currentTime){
|
|
|
|
public HealthEffect(int sourceID, long currentTime){
|
|
|
|
super(createFire(), 0);
|
|
|
|
super(createEffect(), 0);
|
|
|
|
this.sourceID = sourceID;
|
|
|
|
this.sourceID = sourceID;
|
|
|
|
this.currentTime = currentTime;
|
|
|
|
this.currentTime = currentTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Shape3D createFire(){
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Initialise the mesh view with image
|
|
|
|
Image fire = new Image(FireParticle.class.getClassLoader().getResourceAsStream("images/warning.png"));
|
|
|
|
* @return Mesh view
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static Shape3D createEffect(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Image image = new Image(HealthEffect.class.getClassLoader().getResourceAsStream("images/warning.png"));
|
|
|
|
|
|
|
|
|
|
|
|
Plane3D plane = new Plane3D(20, 20, 10, 10);
|
|
|
|
Plane3D plane = new Plane3D(20, 20, 10, 10);
|
|
|
|
|
|
|
|
|
|
|
|
PhongMaterial material = new PhongMaterial();
|
|
|
|
PhongMaterial material = new PhongMaterial();
|
|
|
|
material.setDiffuseColor(Color.web("#FFFFFF"));
|
|
|
|
material.setDiffuseColor(Color.web("#FFFFFF"));
|
|
|
|
material.setSpecularColor(Color.web("#000000"));
|
|
|
|
material.setSpecularColor(Color.web("#000000"));
|
|
|
|
material.setDiffuseMap(fire);
|
|
|
|
material.setDiffuseMap(image);
|
|
|
|
|
|
|
|
|
|
|
|
MeshView fireSurface = new MeshView(plane);
|
|
|
|
MeshView imageSurface = new MeshView(plane);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fireSurface.setMaterial(material);
|
|
|
|
imageSurface.setMaterial(material);
|
|
|
|
fireSurface.setMouseTransparent(true);
|
|
|
|
imageSurface.setMouseTransparent(true);
|
|
|
|
//fireSurface.toFront(); this.flashInterval = flashInterval;
|
|
|
|
//imageSurface.toFront(); this.flashInterval = flashInterval;
|
|
|
|
|
|
|
|
|
|
|
|
return fireSurface;
|
|
|
|
return imageSurface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void rotateView(Double angle, Double pivotX, Double pivotY, Double pivotZ, Point3D axis){
|
|
|
|
public void rotateView(Double angle, Double pivotX, Double pivotY, Double pivotZ, Point3D axis){
|
|
|
|
@ -64,12 +66,21 @@ public class FireParticle extends Subject3D {
|
|
|
|
return sourceID;
|
|
|
|
return sourceID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void flash(long checkTime, long flashInterval){
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Flash the mesh view at a certain interval
|
|
|
|
|
|
|
|
* @param checkTime The current time of flash
|
|
|
|
|
|
|
|
* @param flashInterval Desired flash interval
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void flash(long checkTime, long flashInterval, boolean playerBoat){
|
|
|
|
if(checkTime >= (currentTime+flashInterval)){
|
|
|
|
if(checkTime >= (currentTime+flashInterval)){
|
|
|
|
this.currentTime = checkTime;
|
|
|
|
this.currentTime = checkTime;
|
|
|
|
if(this.getMesh().isVisible()){
|
|
|
|
if(this.getMesh().isVisible()){
|
|
|
|
this.setVisible(false);
|
|
|
|
this.setVisible(false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if(playerBoat) {
|
|
|
|
|
|
|
|
sound.setVolume(0.1);
|
|
|
|
|
|
|
|
sound.play();
|
|
|
|
|
|
|
|
}
|
|
|
|
this.setVisible(true);
|
|
|
|
this.setVisible(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|