I originally wrote a program that generates an area of 2D rectangles. SUDDENLY, I wanted to arrange an isometric projection. I thought that the easiest way to do this is using 3D rectangles. I adapted the code and in general everything turned out the way I wanted. However, there was a problem that I do not know how to solve. Each new rectangle is placed as if on top of the rest. Because of what appears the effect of the relief of the area. I would like the platform to be flat. Below on the screen you will understand everything.
I tried to experiment with setTranslateZ(), but it has no effect at all.
protected List fillingArea()
{
manyPlacedSquares.add(new CustomBox(100,50,100, 0, 0, 0));
for(int y = 0; y < numberOfSquares; y++)
{
for(CustomBox i: manyPlacedSquares)
{
CustomBox upBox = new CustomBox(100,50,100,i.getTranslateX()+70,i.getTranslateY()-50, i.getTranslateZ()-1 );
manyPotentialSquares.add(upBox);
CustomBox rightBox = new CustomBox(100,50,100,i.getTranslateX()-70,i.getTranslateY()-50,i.getTranslateZ()-1);
manyPotentialSquares.add(rightBox);
CustomBox belowBox = new CustomBox(100,50,100,i.getTranslateX()+70,i.getTranslateY()+50,i.getTranslateZ()-1);
manyPotentialSquares.add(belowBox);
CustomBox leftBox = new CustomBox(100,50,100,i.getTranslateX()-70,i.getTranslateY()+50,i.getTranslateZ()-1);
manyPotentialSquares.add(leftBox);
}
System.out.println(manyPotentialSquares.size());
System.out.println(manyPlacedSquares.size());
System.out.println(manyPotentialSquares.get(1).getTranslateX());
manyPotentialSquares.removeAll(manyPlacedSquares);
System.out.println(manyPotentialSquares.size());
index = randomGenerator.nextInt(manyPotentialSquares.size());
manyPlacedSquares.add(manyPotentialSquares.get(index));
}
return manyPlacedSquares;
}
The custom box has plain content and is unlikely to be needed, but just in case, I'll show its content. equals () method redefined for correct operation removeall ()
public class CustomBox extends Box {
Double tt;
Double tt1;
public CustomBox(double width, double height, double depth, double gtx, double gty, double gtz)
{
super(width, height, depth);
this.setTranslateX(gtx);
this.setTranslateY(gty);
this.setTranslateZ(gtz);
tt = gtx;
tt1 = gty;
}
@Override
public boolean equals(Object obj)
{
if(this.tt.equals(((CustomBox) obj).getTranslateX()) && this.tt1.equals(((CustomBox) obj).getTranslateY()))
{
System.out.println(tt + " " + ((CustomBox) obj).getTranslateX());
return true;
}
if (obj == null || obj.getClass() != this.getClass())
{
return false;
}
return false;
}
}