Teleporters and Portals

Started by
1 comment, last by toddhd 19 years, 10 months ago
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?
-Todd"Windows dectected that your mouse has moved. Please reboot for the changes to take effect"
Advertisement
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.
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
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. *-
-* So many things to do, so little time to spend. *-

This topic is closed to new replies.

Advertisement