Jump to content
Posted 16 July 2012 - 03:07 PM
Posted 16 July 2012 - 07:12 PM
If your cells aren't box shaped, they should probably be convex polytopes., which can be described as an array of planes (if a point is on the 'inside' of every plane in the array, then it's inside the polytope). You can start by checking against each cell's bounding box first (which might give more than 1 result), and then do the more expensive plane test for every cell that passed the first test.
How do you keep track of which cell the player is currently in? Do you contain each cell in a bounding box? if so, what about cells that aren't box shaped?
To project a point from world to screen, you multiply it with the view-projection matrix.
Also I have read that a good method is to project the portal into screen space and check which objects in the connecting cell are within the 2d bounds of the portal. Could anybody explain how to do this I dont really understand how to project the portal from world to screen space and test collisions with objects this way.
Posted 17 July 2012 - 02:19 AM
Posted 17 July 2012 - 05:18 AM
In theory, the latter is optimal. However, it's probably complicated to implement, wheras the former option is simple (if somewhat brute force). I'd probably default to the first option, and only worry with the complexity of actually tracking the player if it turned out to be prohibitively slow.
Ok, so would you check the players bounds against all of the cell bounding boxes each frame? or would you need to keep track of the players movement through portals to speed this up?
Yes, you could project all 8 points and take the min/max to get their 2D bounds.
So when you project the corners of the portal into screen space and build a 2D bounding box from them how do you project the objects to screen space and get a 2D box from those? Would you take the corners of the objects bounding box and project them to screen space and then create the smallest 2D box from the 8 corners?
Posted 17 July 2012 - 06:25 AM
Posted 17 July 2012 - 02:07 PM
Posted 17 July 2012 - 08:43 PM
Posted 18 July 2012 - 01:43 AM