I'm trying to make it so that no matter how far apart two objects are they'll both remain on screen. I'm using JOGL, but that shouldn't matter as I just need help with the math. This is what I have so far:
float distance = (float) ((Math.sqrt((p1.x - p2.x) + (p1.y - p2.y))));
float camx = (float)((p1.x + p2.x) * 0.5);
float camy = (float)((p1.y + p2.y) * 0.5);
float camz = (float) (distance * 5);
What is the math I need so the Z zooms in and out correctly?