private void calcV(Camera viewCam) { isVisible = false; // isLookingAt = false; // deltaCenter = Float.MAX_VALUE; if (cMarker.z < -1f) { isVisible = true; if (MixUtils.pointInside(cMarker.x, cMarker.y, 0, 0, viewCam.width, viewCam.height)) { // float xDist = cMarker.x - viewCam.width / 2; // float yDist = cMarker.y - viewCam.height / 2; // float dist = xDist * xDist + yDist * yDist; // deltaCenter = (float) Math.sqrt(dist); // // if (dist < 50 * 50) { // isLookingAt = true; // } } } }
private boolean isClickValid(float x, float y) { float currentAngle = MixUtils.getAngle(cMarker.x, cMarker.y, signMarker.x, signMarker.y); // if the marker is not active (i.e. not shown in AR view) we don't have to check it for clicks if (!isActive()) return false; // TODO adapt the following to the variable radius! pPt.x = x - signMarker.x; pPt.y = y - signMarker.y; pPt.rotate(Math.toRadians(-(currentAngle + 90))); pPt.x += txtLab.getX(); pPt.y += txtLab.getY(); float objX = txtLab.getX() - txtLab.getWidth() / 2; float objY = txtLab.getY() - txtLab.getHeight() / 2; float objW = txtLab.getWidth(); float objH = txtLab.getHeight(); if (pPt.x > objX && pPt.x < objX + objW && pPt.y > objY && pPt.y < objY + objH) { return true; } else { return false; } }
public void drawTextBlock(PaintScreen dw) { // TODO: grandezza cerchi e trasparenza float maxHeight = Math.round(dw.getHeight() / 10f) + 1; // TODO: change textblock only when distance changes String textStr = ""; double d = distance; DecimalFormat df = new DecimalFormat("@#"); if (d < 1000.0) { textStr = title + " (" + df.format(d) + "m)"; } else { d = d / 1000.0; textStr = title + " (" + df.format(d) + "km)"; } textBlock = new TextObj(textStr, Math.round(maxHeight / 2f) + 1, 250, dw, underline); if (isVisible) { dw.setColor(DataSource.getColor(datasource)); float currentAngle = MixUtils.getAngle(cMarker.x, cMarker.y, signMarker.x, signMarker.y); txtLab.prepare(textBlock); dw.setStrokeWidth(1f); dw.setFill(true); dw.paintObj( txtLab, signMarker.x - txtLab.getWidth() / 2, signMarker.y + maxHeight, currentAngle + 90, 1); } }