customizing javafx 3d box or rotating stackpane -


my goal game played dice. using javafx.

first question: there easy way customize 3d box in javafx. doesn't matter me, if have add image every side of die or if use 1 image wraps around box. (after lots of research didn't find it.)

in code below created stackpane, 3d cube. build 6 rectangles, each of filled 1 side of die (1 6). if rotate stackpane 180 degrees, rectangle should in foreground in background , 1 before in front visible again.

second question: how fix this?

or there better way realize that? first thinking using trianglemesh, seemd complicated version.

@fxml private stackpane stack;  @override public void initialize(url url, resourcebundle rb) { ... //other code   (int = 1; < 7; i++){                rectangle rt = getrectangle(i);             rt.setsmooth(true);             stack.getchildren().add(rt);             switch(i) {                 case 1:                     rt.settranslatez(100);                                             break;                 case 2:                     rt.gettransforms().add(new rotate(270, 50,50,0,rotate.x_axis));                     rt.settranslatez(100*0.5);                     rt.setheight(100);                     rt.settranslatey(100*0.5);                     break;                 case 3:                     rt.settranslatez(100*0.5);                     rt.gettransforms().add(new rotate(90, 50, 50, 0, rotate.y_axis));                     rt.setwidth(100);                     rt.settranslatex(-(100*0.5-1));                     break;                 case 4:                     rt.settranslatez(100*0.5);                     rt.gettransforms().add(new rotate(90,50,50,0,rotate.y_axis));                     rt.setwidth(100);                     rt.settranslatex(100*0.5);                     break;                 case 5:                         rt.settranslatez(100*0.5);                     rt.settranslatey(-(100*0.5));                     rt.gettransforms().add(new rotate(270,50,50,0, rotate.x_axis));                     rt.setheight(100);                     break;                 case 6:                     rt.settranslatez(0);                     break;             }        private rectangle getrectangle(int number){     rectangle rt = new rectangle(100, 100);     rt.setfill(new imagepattern(loadimage(number)));     return rt; } 

the problem box, may have noticed, if apply image diffuse map, applied equally 6 faces.

if have @ fxyz project, there's implementation of similar 3d shape, cuboidmesh.

having full access 'trianglemesh` it's easy customize way texture mapped diffuse image. in case, way implemented using net of cube:

cube net

so need provide own net. instance, one:

dice net

from here

just rotate 180ยบ , crop border, , short code have dice:

cuboidmesh cuboid = new cuboidmesh(10f,10f,10f); cuboid.settexturemodeimage(getclass().getresource("rotated_image014.jpg").toexternalform()); 

dice


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -