Page 1 of 1

Portal effect

Posted: Tue Feb 27, 2007 7:33 pm
by Xharock
Hi, I've been trying to create a portal affect similar to what is seen in the game Narbacular Drop (And Prey it seems) whereby there are two portals and as you look out of one you see whats on the other side of the other. I haven't done very well. I've been looking at the tech docs for the game and it describes the technique for doing it but I just can't seem to get it into Irrlicht. Here is the extract from the document:
Essentially, a portal is just a textured quad. But the contents of the texture are dynamic and the texture coordinates change based on how you're looking at the quad.

To create the contents of the texture:
1. Convert the current camera position and look vector into coordinates relative to the portal.
2. Find this position and rotation in relation to the portal's exit.
3. Move the camera to the point and rotation found in step 2.
4. Render the scene while culling all objects between the camera and the portal exit.
5. The render surface is now the source texture for the portal and the camera should be moved back to where it was before step 1.

To render the quad with the proper texture coordinates:
1. Convert each coordinate into screen space.
2. Copy the normalized screen space x and y components into the u and v coordinates of each vertex.
3. Render the quad.
Any ideas on how this could be achieved in Irrlicht? I am not familiar with the process of changing a models texture coordinates in this engine. My portal quad meshes are simply on sided planes in an IAnimatedMeshSceneNode. I am pretty sure that to convert a World Space coordinate to Screen Space all I have to do is multiply the vector by the projection matrix?

Posted: Tue Feb 27, 2007 8:12 pm
by vitek
This has been done before. Search for 'Prey AND Portal'.

Travis

Posted: Wed Feb 28, 2007 1:44 pm
by JP
Blizportals is what was done previously, a few versions using RTT, DirectX or OpenGL, I also made some portals based on those in my Curse of the Pharoah project.

Irrlicht+DirectX
Irrlicht+OpenGL
Curse of the Pharoah