Hallo
ich habe ein problem ich habe diese zwei Klassen hier gemacht
und
so ausgeführt
dabei Rausgekommen ist:
ich habe ein problem ich habe diese zwei Klassen hier gemacht
Java:
import javafx.scene.Group;
public class Cube extends Group{
private static Wall w1;
private static Wall w2;
private static Wall w3;
private static Wall w4;
private static Wall w5;
private static Wall w6;
public Cube(String name,String Input,double x,double y,double z){
w1 = new Wall(Input,name);
w1.addToGroup(QuickSpiel.wo, name);
w1.setPos(name, x + w1.getWidth(name)/2, y, z);
w1.setRotation(name, 0, 90, 0);
String name2 = name + "1";
w2 = new Wall(Input, name2);
w1.addToGroup(QuickSpiel.wo, name2);
w2.setPos(name2, x, y, z + w2.getDepth(name2)/2);
String name3 = name + "2";
w3 = new Wall(Input,name3);
w1.addToGroup(QuickSpiel.wo, name3);
w3.setPos(name3, x, y + w3.getHeight(name3)/2, z);
w3.setRotation(name3, 90, 0, 0);
String name4 = name + "3";
w4 = new Wall(Input,name4);
w1.addToGroup(QuickSpiel.wo, name4);
w4.setPos(name4, x, y - w4.getHeight(name4)/2, z);
w4.setRotation(name4, 90, 0, 0);
String name5 = name + "4";
w5 = new Wall(Input,name5);
w1.addToGroup(QuickSpiel.wo, name5);
w5.setPos(name5, x - w5.getWidth(name5)/2, y, z);
w5.setRotation(name5, 0, 90, 0);
String name6 = name + "5";
w6 = new Wall(Input, name6);
w1.addToGroup(QuickSpiel.wo, name6);
w6.setPos(name6, x, y, z - w2.getDepth(name6)/2);
}
}
und
Java:
package Spiele.MrTroble;
import java.util.ArrayList;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.transform.Rotate;
public class Wall extends Group{
private static final ArrayList<ImageView[]> list = new ArrayList<ImageView[]>();
private static final ArrayList<String[]> Source = new ArrayList<String[]>();
private static final ArrayList<double[]> koord = new ArrayList<double[]>();
public Wall(String ip,String src){
this(ip, src, true);
}
public Wall(String ip,String sourc,boolean vis){
this(ip,sourc,0,0,0,vis);
}
public Wall(String ip,String sourc,double x,double y,double z,boolean vis){
this(ip,sourc,x,y,z,0,0,0,vis);
}
public Wall(String ip,String sourc,double x,double y,double z,double rotX,double rotY,double rotZ,boolean vis){
ImageView vw = new ImageView(new Image(Cube.class.getResourceAsStream(ip)));
vw.setTranslateX(x);
vw.setTranslateY(y);
vw.setTranslateZ(z);
Rotate xr = new Rotate(rotX, Rotate.X_AXIS);
Rotate yr = new Rotate(rotY, Rotate.Y_AXIS);
Rotate zr = new Rotate(rotZ, Rotate.Z_AXIS);
vw.getTransforms().addAll(xr,yr,zr);
vw.setVisible(vis);
ImageView[] im = {vw};
String[] src = {sourc};
double[] ifo = {x,y,z,vw.layoutBoundsProperty().get().getWidth(),vw.layoutBoundsProperty().get().getHeight(),vw.layoutBoundsProperty().get().getDepth(),rotX,rotY,rotZ};
koord.add(ifo);
Source.add(src);
list.add(im);
}
public ImageView getImageView(int place){
return list.get(place)[0];
}
public static ImageView getImageView(String src){
return list.get(getPlace(src))[0];
}
public static int getPlace(String source){
int i = 0;
while(!(source == Source.get(i)[0])){
if(i == getSize()){
Logger.Error("Array Limite has reatched");
return (Integer) null;
}
i += 1;
}
return i;
}
public String getName(int place){
return Source.get(place)[0];
}
public void addToGroup(Group g,String n){
g.getChildren().add(getImageView(n));
}
public static int getSize(){
return Source.size();
}
public void setPos(String src,double x,double y,double z){
ImageView v = getImageView(src);
v.setTranslateX(x);
v.setTranslateY(y);
v.setTranslateZ(z);
add(v,src);
}
public void setRotation(String src,double rx,double ry,double rz){
Rotate xr = new Rotate(rx, Rotate.X_AXIS);
Rotate yr = new Rotate(ry, Rotate.Y_AXIS);
Rotate zr = new Rotate(rz, Rotate.Z_AXIS);
getImageView(src).getTransforms().addAll(xr,yr,zr);
add(getImageView(src), src);
}
private static void add(Node vw,String sourc){
double[] ifo = {vw.getTranslateX(),vw.getTranslateY(),vw.getTranslateZ(),vw.layoutBoundsProperty().get().getWidth(),vw.layoutBoundsProperty().get().getHeight(),vw.layoutBoundsProperty().get().getDepth(),vw.getTransforms().get(0).getTx(),vw.getTransforms().get(0).getTy(),vw.getTransforms().get(0).getTz()};
koord.set(getPlace(sourc), ifo);
}
public double getHeight(String src){
return koord.get(getPlace(src))[3];
}
public double getWidth(String src){
return koord.get(getPlace(src))[4];
}
public double getDepth(String src){
return koord.get(getPlace(src))[5];
}
public Point3D getPos(String src){
Point3D p = new Point3D(getImageView(src).getTranslateX(), getImageView(src).getTranslateY(), getImageView(src).getTranslateX());
return p;
}
public String toString(){
String st = "";
int i = 0;
while(!(i == getSize())){
st += getName(i);
}
return "Size from List:" + getSize() + String.format("%n") + "Names:" + st;
}
public void setVisible(String src,boolean vis){
getImageView(src).setVisible(vis);
}
public boolean isVisible(String src){
return getImageView(src).isVisible();
}
}
so ausgeführt
Java:
Cube w = new Cube("Hollo","WallNormal.png", 5, 5, 5);
dabei Rausgekommen ist: