I have created a way to draw a selection box on the screen when you click and drag the mouse. Like in most strategy games. When the mouse is pressed, i call my draw method which creates a quad mesh and adds it to the guiNode. (Flat on screen).
While the mouse is still pressed, the following update method is 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 a new Quad based on the first click location of the mouse and the current location of the mouse. Now the issue is that when i try to click and drag to the left, the square doesnt show. However when i drag to the right, it does.
My assumption is that when it is on the left side, the width parameter when creating a new Quad is a negative number, and that is causing issues for the Quad class. BUt im not sure. How could i fix this? Rotate the Quad? Any alternatives?
Thank you very Much