Previous Blog Next Blog
Prev/Next Blog
by date

Portal Thingy

Portal Thingy
Name:Bill Vee 
Date Posted:Aug 14, 2007
Rating:2.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Bill Vee

Blog post
Last Friday I had surgery to remove a 10 inch plate from my leg that was put in about a year ago so if I misspell something or start rambling blame it on the the meds.

While this is unrelated to my current game project I think it may be useful to the community.

First watch this video.


What you see is a portal thingy I thought about while recuperating and basically what it is is a copy of the waterblock class. With some changes to the updateReflection code to point to another object in the game as to what to be viewed/reflected from.

What I want it to do is reflect the view of the object it is referencing.
Think placing this object at the door of a small shack while the reference object "looks" into a large building . Instant Tardis effect. Shack appears bigger on inside than on outside.

As you can see its not working exactly right.

I know someone will suggest using a render to texture type configuration but the way the waterblock handles the reflection appears not to take a hit on the frames per second. At least on my system I placed 30 waterblock in the same scene all at different angles and all on screen at once and no noticeable hit on the frames per sec.

So what I need is either

1 someone that has a better understanding of what the updateReflection function is doing than me
Or
2 me not under the influence of pain meds.

Or possibly both.

I will continue to try and develop this but no promises. I am willing to show my code on this if someone wants to take a whack at it.

If anyone has a better way to do the "Tardis" effect I would love to see it.

Recent Blog Posts
List:05/31/08 - DayOfWar Six Degrees Of Freedom Camera System
05/26/08 - DayOfWar Player Controls
05/08/08 - DayOfWar more Asteroids
05/05/08 - DayOfWar Moons/Asteroids
04/28/08 - DayOfWar Oceans
04/07/08 - DayOfWar SixSidedSpheres 2nd try
04/07/08 - DayOfWar SixSidedSpheres
02/22/08 - DayOfWar is a Finalist.

Submit ResourceSubmit your own resources!

Nick Eaket   (Aug 14, 2007 at 19:17 GMT)
Looking cool

Maybe shaders could do the same thing. Now I don't know if shaders could make portals, but if they can it might be easier than hacking the waterblock.

Bobby Leighton   (Aug 15, 2007 at 03:08 GMT)
I think your best solution to your problem would be to attempt a camera hack/re-write for your needs. For example a camera positioned viewing your object while the area you have for your "Portal" is for viewing like watching a TV. This is how it is done in other engine's i have worked with, I think that's how we did it with the Unreal Tournament Mod we did. Ill look up some info on it, and it may be possible with shaders, i will have to look at the HLSL ref. on MSDN to be sure:) Ill check in later to see your progress as this is something I will have to do in my development also later on:) On second thought, shader would definitely lend a hand if its not a complete solution altogether. Like the water rendering is done through shaders and C++ code together....

Trace Kern   (Aug 15, 2007 at 06:06 GMT)
Another possible idea is to get a hold of the folks who made Garry's Mod for Half Life 2, and see if they know how the portals in the HL2 engine work.
Those portals not only create viewable 'holes' but these dynamic creation holes can actually be traveled through.

If anyone has played the game Prey, this is another similar concept. If you can figure out how Portal (Based on the HL2 engine) and Prey work, then you might be able to reverse engineer or re-engineer it for TGE.

Gabriel Notman   (Aug 15, 2007 at 20:03 GMT)
What you want to be looking at here is scene graphs. With a good understanding of such, effects which were so well demonstrated in 'Prey' are quite simple.

I am not an expert on such, but I will attempt to explain the concepts.

If you look back at earlier 3d games which were mainly indoor. You have a map/level which is split up into zones each of which are separated by portals. Torque has an implementation of this for its interiors, and includes portals between inside outside etc (and possibly zones with the interiors, I'm not sure).

When the scene is being rendered, its starts in its current zone, and render everything which falls within the viewing volume. It also tests each of the portals of the existing zone to see if they fall at least partially within the viewing volume (frustum), if they do it then draws the zone on the opposite side of the portal and may repeat this process recursively.

Now the interesting thing happens when you apply and transformation at the portal. Basically when the render loop goes to render the next zone an transform is applied to the camera first. Normally this is null, so the camera continues to view in a straight line which makes sense geometrically, and is what you see when you look through the windows or doorways in the interiors in torque.

But if you do apply a transform at the portal you can create all sorts of interesting effects. You can scale, orientate and even translate the camera. So if you were to translate the camera to a complete different location, you can be rendering a view into another room (of any size). Or you can orientate the camera onto itself and point to the original zone, which will give you a mirror effect. The possibilities are vast, as demonstrated by 'Prey' and other games.

The same can also be applied to the movement of the control object (player, vehicle etc), so that when the player intersects the portal their position is affected by the transform, and so instantaneously tele-porting them to the new location.

Hope this helps,

Gabriel

Bill Vee   (Aug 15, 2007 at 23:58 GMT)
I have some progress to report but not much.
Another video.

As close as I am getting to this it amazes me that someone else hasn't already got this done.
As you can tell from the video it will show the view from a moving objects point of view but inverted.
Now I didn't even intend to make it reference a moving object and update in real time.
I created a script function to "setViewObject" so I could type it from the console and I placed a aiwheeled vehicle to just show movement in the scene but when I type the function into the console I made a mistake and passed the object ID of the aiwheeled vehicle instead of a object I placed in the scene to use as a "camera". Imagine my surprise when the portalblock started showing the view from the buggy.

My point is if I can get this far and still on pain meds and not really not knowing what I am doing with the original waterblock code why hasn't someone figured this out before me.

The only reason I started messing with it is my laptop is all I have access to right now from my bed and it doesn't have the hardware installed that my main PC has. Mainly the right graphics card.

Like I said before if someone wants to take this up from here I would gladly show my code so far.
This and my surgery really got me side tracked on my game.
Edited on Aug 16, 2007 00:11 GMT

Benj   (Oct 20, 2007 at 21:58 GMT)
ive been working out the math in my head of how to make a portal effect like this for awhile, but havnt written the code yet... the way i was gonna do it was have a plane, which would be the portal, and render that to the stencil buffer, then render the exit view using the stencil.

i haven't tested my math but, what i figured was something like this....

make a offset matrix, which would be the players matrix multiplied by the 1st portals inverse matrix.

then render at the offset multiplied by a rotation matrix that rotates by 180 degrees on the Z multiplied by the 2nd portals matrix.
Edited on Oct 21, 2007 19:59 GMT

You must be a member and be logged in to either append comments or rate this resource.