camera - JMonkey Selection Square Complication -


i have created way draw selection box on screen when click , drag mouse. in strategy games. when mouse pressed, call draw method creates quad mesh , adds guinode. (flat on screen).

while mouse still pressed, following update method called:

    main.gui.getchild("selection box").removefromparent();     xmousecur = inputmanager.getcursorposition().x;     ymousecur = inputmanager.getcursorposition().y;      if (xmousecur < xmouse) {     }      quad = new quad(xmousecur - xmouse, ymousecur - ymouse, false);      geom = new geometry("selection box", quad);     geom.setlocaltranslation(new vector3f(xmouse, ymouse, 0));     geom.setmaterial(mat1);     geom.setcullhint(cullhint.never);     main.gui.attachchild(geom); 

the method creates new quad based on first click location of mouse , current location of mouse. issue when try click , drag left, square doesnt show. when drag right, does.

my assumption when on left side, width parameter when creating new quad negative number, , causing issues quad class. im not sure. how fix this? rotate quad? alternatives?

thank much

your issue backface culling. when width (or height) of quad negative seeing side of tyhe object, culled default per-triangle. geom.setcullhint frustrum culling (draw when camera isn't looking @ you), gui node won't worry about.

either force quad of positive size: setting position , size appropriately each frame.

or use mat1.getadditionalrenderstate().setfacecullmode(facecullmode.off) tell material draw side. drawing both sides time though, exacerbate garbage collection of using new geometry every frame.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -