# How do portals work?

## Recommended Posts

In portal rendering, is a portal a polygon shared by two sectors? Or do both sectors have portals that link to each other? I'm a little confused. I understand how portal rendering works, I just cant understand how portals link to other sectors. Any help would be great. thanks Kazade.

##### Share on other sites
Well, portals are just virtual "geometry". You can either have have one portal and link both sectors to it, or duplicate it and add it to each sector. If they are used just for visibility, then they are always 2 way. If A can see B then B can see A. But if you use them for something else (pathfinding?) then this might not be always true.

##### Share on other sites
Well, i'm making a map editor and i want to make it possible to add portals. I already have planned so that the user can assign different areas as sectors, i'm just wondering should a CPortal class have something like:

class CPortal {private:      int linkedSectors[2]; //Which would hold the sector ID's that                           //the portal links};

Or should a portal be a special type of poly which is part of a sector and merely points to the sector it links to? or will both ways work?

tell me if i'm not making sense :D

Thanks

##### Share on other sites
You can do it whatever way suits your engine structure. You may want to have a special type of polygon to represent a portal, and store a link to the sector it's "looking at" in that. Then you'd need two copies of the polygon in most situations; one from sector A to sector B, one from B to A, but it would make it easy to have one-way portals. You can store portals separately from the other geometry. You can keep portal polygons with the rest of your geometry, and store sector and portal link information separately from the geometry. Basically, you can do it however you want, as long as the engine has a way to get all the information it needs to render. Which way will be best depends on how the rest of your engine is designed.

John B

##### Share on other sites
Thanks, i think i've got it worked out now. I'll just make it so the level editor can set a polygon to be a portal and then it'll just ask which sector it's to link to.

Thanks again,

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628320
• Total Posts
2982072

• 21
• 9
• 9
• 13
• 11