java - Positioning of 3d boxes in JavaFx -
i'm beginner in javafx 3d modelling. i'm trying create 3d-model of boxes in room. have dimensions of boxes , coords front-left-bottom corner of every box. i've tried set coords settranslatex(), result isn't correct. here pice of code try set coords:
for (int = 0; < main.load.size(); i++) { load l=main.load.get(i); box sphere = new box(l.getlength()*10, l.getwidth()*10, l.getheight()*10); sphere.settranslatex(l.getx()*10); sphere.settranslatey(l.gety()*10); sphere.settranslatez(l.getz()*10); phongmaterial m = new phongmaterial(); m.setdiffusecolor(new color(math.random(),math.random(),math.random(),1)); m.setspecularcolor(color.black); sphere.setmaterial(m); root.getchildren().add(sphere); }
i hope can me.
here example:
sizes: blue (30,50,50) pink (10,10,20)
position: blue (0,0,0) pink (30,0,0)
when translation of javafx 3d object box need account half width of object along axis. default placement box centered @ origin meaning center of box object @ 0,0,0. width 30 * 10 translatex converts 0*10=0. right edge of blue box x=150 (300 / 2.0 = 150). pink box has translatex of 10*30=300. center of pink box translated 300 means left edge @ 300 - (width/2.0) = 300 - (50) = 250.
Comments
Post a Comment