This topic is now archived and is closed to further replies.


Portals and terrains!

Recommended Posts

Azrael    128
Yes the bug mix that will make PR be awesome mixing the portal and terrain engine, for this im building my own portal engine with the help of someother people then we are adding the resulting code to the terrain engine, lets see how it goes. Now this is a different aproach, I want to start a thread on this important topic.. so post your comments about it here.. have you made it work? what was your aproach? Of course I will post my comments about it too, so pay attention to this thread. happy coding guys!

Share this post

Link to post
Share on other sites
Whirlwind    134
Dual engine design:

Use a switch located at the doorways between the portal engine and the terrain engine. When a player steps on the switch, you not the variable that holds the switch (no need to know whether the player is entering or exiting a portal). Scenario:

A player goes from a terrain to a building, located at the building enterance (inside the building a few feet or so), there is a switch/portal that flags the inside/outside switch. The terrain engine checks to see whether any portal in/out switches have been triggered, if so, pulls the map name from the data structure for the switch for the first room, and passes it into the portal engine. The player then leaves the building, triggering the same portal in/out switch which exits the portal engine and starts the terrain engine again.

By using properly disguised enterance ways (T-rooms as enterance ways) you can do the above method without many hitches. Portals that lead to long hallways will require a different approach.

A potential way to deal with long hallway enterances is to use rendering flags to determine what part of the screen the portal engine is responsible for drawing. If a portal is visible, render the scene using the terrain engine, and then render in the portal section of the screen, just like the painter''s alogarithm would do - draw the back, then the front. You''d have to do some work to define the faces of the terrain that block the view of faces of the portal engine drawing area, but clever map design might prevent that.

The objects on the terrain itslef should be rendered based on whether they are in front of or behind the portal. The ones behind are rendered first, then the portal engine goes to work, then the ones in front of the portal should be drawn. While the player is inside a portalized map, visibility checks should be done in order to see if the outside is visible from the room (is there a portal that is a in/out switch in the room) and if so, the portal engine work should be last, and the terrain should only be drawn if not ocluded by the walls in the portal engine.

Share this post

Link to post
Share on other sites