Thank you AndrewT, that worked nicely. Jezza, I don't know how to do bounding boxes but will probably make a crack at it when I get a chance. There are some drawbacks to just getting dbOjectScreenX() and checking for distance....mainly that you don't get the rest ofthe info vectors you normally would with dbPick stuff, also you're forced to a distance from the center (rather than picking the actual object).
Nevertheless, it worked for what I'm doing, so cheers.
For the curious, or for anyone *newer* than myself, here's the code used:
// Pick the mouse location on 2D screen from crosshairs. Should pick up close objects easily
cam.target = dbPickObject(cam.crosshair.x, cam.crosshair.y, START_OBJ, LAST_OBJ);
if ((cam.target < OBJ_STAR_MULTI) && (cam.target > (OBJ_PLANET_FIRST - 1)))
{ // do nothing, we have what we want
}
else
{
// check if it's close to object, if so, pick it. This is to see far distant stars
int xDist = 0;
int yDist = 0;
for (int iterObj = OBJ_SINGLE_STAR; iterObj < LAST_OBJ; iterObj++)
{
xDist = dbAbs(dbObjectScreenX(iterObj) - cam.crosshair.x);
yDist = dbAbs(dbObjectScreenY(iterObj) - cam.crosshair.y);
// crosshairs and object within 10 of each other?
if ((xDist < 10) && (yDist < 10))
{
cam.target = iterObj;
}
}
}
-Jason