🔒 Locked
portals
Advertisement
Original Post
hi!
how can i check wheater a portal is in my frustum of not?
my portals are representated by vertices. when i check these vertices it doesn''t work correctly (because my portals are too large).
one possibility would be to calculate other vertices, which are in these portals, but i guess this isn''t the right way, though.
so? what shall i do?!
(sorry for my bad english :D)
It''s been a while since I''ve done anything with portals, but if I remember correctly your supposed to check if the portal''s polygon is inside your frustrum (use the plane equation and such). If it is, then you clip its polygon against your frustrum, then use this new portal to "simulate" another frustrum looking into the next room. You keep doing this process until there are no portals visible.
Hope I explained it right
Hope I explained it right
Hi
Well in my portal engine, I store for each of my portals its AABB, so to test if it is visible for my cam, I use a AABB - Frustum intersection test.
Theres an other method presented "Real-Time Rendering", which projects the portals AABB to screen coords and then test 2D intersection beetween your portals RECT and your screen RECT.
Hope this help,
Oscar
Well in my portal engine, I store for each of my portals its AABB, so to test if it is visible for my cam, I use a AABB - Frustum intersection test.
Theres an other method presented "Real-Time Rendering", which projects the portals AABB to screen coords and then test 2D intersection beetween your portals RECT and your screen RECT.
Hope this help,
Oscar
quote:
Original post by guts
yeah i know this stuff; but when i come to close to my portal the frustum intersection test fails (because there isn''t any vertex of the portal in it...)
Hmm, I see. How big are your portal polygons? Maybe you could add a center vertex to it, if its not too large. If its giant then you should consider subdividing it into smaller polygons.
quote:
another question:
How can i calculate the view frustum of a polygon (portal)?
I do not a working source code. Math tutorials would help me too...
I can''t remember where it was but a while back (a looong time ago) I found a really good article that explained everything about portals. I''ll try and dig it back up.
But in the meantime, building a frustrum from the polygon shouldn''t be all that different that building one from the screen. The only issue is that the polygon can take on any shape, so your frustrum will look a bit strange. I''d imagine you could apply the frustrum calculation algorithm that you used to the polygon.
You should change your frustum cull code a bit so it can detect intersections. I guess you already have 6 planes defined in your frustum class (left, right, top, bottom, far, near). If not, do this first. Then check all your portal vertices against all these planes:
for EACH plane:
1) if ALL vertices are on the outside, the plane is on the outside of the frustum. stop culling agains the other planes
2) if ALL vertices are on the inside of this plane, continue culling against the remaining planes.
3) If only SOME of the vertices were on the inside, it''s intersecting. Keep culling against the remainder of the planes.
after this has been done 6 times (for all planes):
4) Was culling abandoned by ANY plane at step (1)? Then it''s outside.
5) were ALL vertices on the inside of ALL planes? If yes, then the portal is inside the frustum. If no, then it''s intersecting.
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
for EACH plane:
1) if ALL vertices are on the outside, the plane is on the outside of the frustum. stop culling agains the other planes
2) if ALL vertices are on the inside of this plane, continue culling against the remaining planes.
3) If only SOME of the vertices were on the inside, it''s intersecting. Keep culling against the remainder of the planes.
after this has been done 6 times (for all planes):
4) Was culling abandoned by ANY plane at step (1)? Then it''s outside.
5) were ALL vertices on the inside of ALL planes? If yes, then the portal is inside the frustum. If no, then it''s intersecting.
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement