Jump to content
• Advertisement

# Portals and Transformations

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

If you intended to correct an error in the post then please contact us.

## Recommended Posts

hi, I'm currently messing around with portals and was wondering how transformations are usally handled between two portals, specifically rotations -I have been able to get a simple translation portal working where the scene is rendered first through all portals(the portal is represented by two polygons and a translation vector, the portals construct accepts one polygon and a translation vector, it then calculates the second polygon). when rendering through portals I translate the camera position by the portals translation then construct a frustum through the second polygon, I then render the scene clipped to this frustum and the camera's viewing frustum, then restore the camera's position, fill the Z-buffer with the first polygon and render the scene again. I was wondering what the typical structure of a portal is, whether it contains a transformation matrix (or two) and how you should normally render using portals, and how rotation is handled. also (for simple portals, doors etc.) would you normally position two sectors/scene nodes next to each other so you can ignore the transformations??

#### Share this post

##### Share on other sites
Advertisement
Do you mean teleporting portals, as in Portal and Narbacular Drop, or zone-culling portals, for culling scene geometry based on visibility? For the previous, you'd have 3 things:
- transformation matrix for side A of portal
- transformation matrix for side B of portal
- transformation matrix for camera
The procedure is, very basically: get the camera into local/object space of side A (multiply by inverse of A's transformation matrix), and then get it back into world space, but using side B's matrix. This effect keeps the relativity between the camera and the two sides of the portals the same, which is what a portal is. Note that you want to rotate the transformation matrix of B by 180 degrees first, though, since A's front doesn't match up to B's front, but to B's back.

#### Share this post

##### Share on other sites
Quote:
 Do you mean teleporting portals, as in Portal and Narbacular Drop, or zone-culling portals, for culling scene geometry based on visibility?

both, they are really just the same although portals for visibility may not have any transformations, or do they?
The reason I'm using them is for visibility but I plan on implementing things like mirror effects etc.

#### Share this post

##### Share on other sites
In the following I'm using column vectors.

The camera is placed in a zone z1 where a 1st portal is given. The camera's frame is
Cz1
given w.r.t. the zone's co-ordinate frame (e.g. the world). Similarly, the portal's frame in the same zone is
Pz1,1
This frame is defined to "look into" the portal, i.e. it is placed before the portal.

Now, a 2nd portal in another zone z2 (that may be the same as z1) is given as
Pz2,2
using the zone's reference frame. This frame is defined to "look out of" the portal, i.e. it is placed behind the portal. And geometry that should be seen through the 2nd portal
Gz2

Relating the geometry to the 2nd portal creates a local co-ordinate frame
Gp2 := Pz2,2-1 * Gz2

This frame should appear as being identical to those of the 1st portal, so
Gz1 := Pz1,1 * Gp2

Viewing this through the camera then means
Gc := Cz1-1 * Gz1

Hence, the overall transformation before viewing would be
Gz1 := Pz1,1 * Pz2,2-1 * Gz2

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
14
5. 5
A4L
13
• Advertisement

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!