
09-17-2007, 02:30 PM
|
 | PT Admin | | Join Date: Jun 2007 Location: In front of computer...
Posts: 1,118
| |
I found the solution for this one Quote:
Oh, I see your problem.
Your ships are in 3D coordinates, which are completely different from the screen coordinates. So your Max/Min X/Z values should be computed in spatial coordinates. These values, after you find them will be resolution independent.
They are tied to the camera view and projection matrices. The distance from the XZ, and the field of view both determine how much of that plane you can see, and what are the bounds that you're looking for. If the distance is larger, or the field of view is greater, more area will be visible. If the distace is lower, or the field of view is narrower, less area will be visible. But since your distance is fixed (8000) and fov is also fixed (45), once you find appropriate values (begin with +-500 for both axis, and slowly increase until you reach a value you are satisfied with), you can hardcode them.
I don't know how to better explain this more clearly...
| PHP Code: public void CheckBoundaryCollision() { int MaxX = 500; int MinX = -500;
int MaxZ = 500; int MinZ = -500;
if (shipPosition.X > MaxX) { shipPosition.X = MaxX; } else if (shipPosition.X < MinX) { shipPosition.X = MinX; } if (shipPosition.Z > MaxZ) { shipPosition.Z = MaxZ; } else if (shipPosition.Z < MinZ) { shipPosition.Z = MinZ; } }
Quote:
Then run the game, and see how the ships behave. After that, modify the MaxX, MinX, MaxZ and MinZ values slightly (add / subtract 100), run again, and repeat this process until the boundaries are ok.
You don't have to do anything with Viewport.Width and Viewport.Height. The coordinates in space have no relation to these values.
| Thanx for XBOX Live ID CatalinZima for the answer  |