#### Archived

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

# Teleporters and Portals

This topic is 5226 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am designing a "dungeon" for an RPG. There are parts of the dungeon where the player will teleport to another part of the dungeon, however, this will (by design) not be obvious to the player. It is a trick to confuse them. Anyway, I''m trying to decide the best way to handle this. Consider this *very oversimplified* example:
      |   |
======|   |========
|       x         |
|     ====        |
|     ====        |
|       y         |
======|   |========
|   |


Assume that the player is standing at the "x", walking/looking north (up). What he "sees" the wall at position "y". If he keeps walking north, he will teleport and end up at position y. But as far as he knows, he just walked into another room just north of his current position. Ok, so here is the question - what is the best way to implement this using OpenGL. The obvious answer to me is that I''ll need to recreate the room so that it does actually exist, and thus, the player sees it as it should be. In tight quarters however, this might be a real pain, and I would have to keep careful track of the player position, and either draw the "portal" or the real dungeon walls depending on where they are. (To consider a tougher example, imagine a magic mirror that they step through to another room). Is there a way or technique in opengl to handle this situation? I was kind of thinking a "viewport" of some type, as long as it will consitnue to look right as the player walks around. Or do I need to physically create the illusion as described above?

##### Share on other sites
Basic portal rendering is easy. Firstly, youll need a point of reference to match the 2 points in space up to each other. ie.

      | # |======|   |========|       x         ||     ====        ||     ====        ||       y         |======|   |========      | @ |

@ and # are your points of reference. Now, when rendering, you can do a little math to make these points match up, and then continue drawing the "portal" scene as per normal. This will allow you to see into the portal room as if it was really there infront of you.

A good way to handle that is to actually draw the portal view first, clear Z, draw your portal polygon to Z only, and then draw the room youre in normally. This way, the portal polygon in the Z buffer will stop anything behind the portal polygons being drawn over the portal view, but everything else renders around it just fine. This is good if you have a portal in the centre of a room with objects around it.

To move freely between the portal rooms, when your player crosses the portal view polygon, you can work out the players offset from your first reference point, and then apply that offset at the second reference point and drop the player off there.

It takes a little bit of work to get it right, but you can end up with seamless traversal through portal polygons. Its not overly hard.. I made a small Quake1 mod that could do this.

##### Share on other sites
The ''good'' way to render portal is render to texture.
http://www.pvrdev.com/pub/PC/doc/idx/whitepapers.htm

Portal Techniques explains it.

-* So many things to do, so little time to spend. *-

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• ### Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• ### Who's Online (See full list)

There are no registered users currently online

×