sidebar features
sidebar content

Go Back   Blender Artists Forums > Game Engine > Game Engine Resources

Reply
 
Thread Tools
warwickallison warwickallison is offline
Member
 
Join Date: Aug 2009
Posts: 15
Hello all (my first post, so I'll say that)...

I've implemented working and visually-correct Portals in BGE. As far as I can tell, they look like and work like Portals in Valve's awesome game of that name. Any object will transport (smoothly) through them automatically, preserving (but re-orienting) linear and angular momentum. The Portals themselves can be moved and reoriented as you please.

Basically the implementation uses VideoTexture.ImageMirror and a little maths. I'm no mathematician, so it took a few hours to get right, so I thought I'd save you all the trouble.

The script is in the attached blend file. You can use it in your own projects under this license:

Arrow-key around and enjoy "thinking in portals".

Attached Images
File Type: jpeg Portals.jpeg (130.9 KB, 489 views)
Attached Files
File Type: blend VideoTexturePortals.blend (382.6 KB, 1406 views)

Last edited by warwickallison; 19-Aug-09 at 03:12. Reason: CC licensing
#1   Old 16-Aug-09, 07:11   
Reply With Quote


Sim88 Sim88 is offline
Member
 
Join Date: Aug 2006
Posts: 1,504
Sweet! you should post this in resources. And maybe my thread of bge demos (se sig). Awesome work!
............................................
Here is my thread for BGE demo files
#2   Old 16-Aug-09, 08:00   
Reply With Quote
Mentalturkey's Avatar
Mentalturkey Mentalturkey is offline
Member
 
Join Date: Jan 2009
Location: Perth, Australia
Posts: 329
Looks awesome, but doesnt work for me
#3   Old 16-Aug-09, 13:21   
Reply With Quote
vitorbalbio's Avatar
vitorbalbio vitorbalbio is online now
Member
 
Join Date: Nov 2008
Location: Rio de Janeio - Brasil
Posts: 483
Amazing Work!!!
Fantastic! xD
............................................
Starats Studio! Brasil tb tem Blendero!
Blog: http://obalbio3d.wordpress.com/
Ruínas2.0 : http://blenderartists.org/forum/showthread.php?t=152668
"O Blender não é mt carismático mas.... "
#4   Old 16-Aug-09, 13:41   
Reply With Quote
IAmThisGuy IAmThisGuy is offline
Member
 
Join Date: Feb 2008
Location: Saskatchewan
Posts: 650
OH MAN!! That's just plain awesome.
............................................
Saskatchewan. Easy to draw, hard to spell.
I live in a rectangle.
#5   Old 16-Aug-09, 18:14   
Reply With Quote
OTO OTO is offline
Moderator
 
Join Date: Mar 2002
Posts: 3,858
Your first post is much more interesting/valuable than my 3,000!
Great work, bravo!!
#6   Old 16-Aug-09, 19:42   
Reply With Quote
Captain Oblivion's Avatar
Captain Oblivion Captain Oblivion is offline
Member
 
Join Date: Jan 2006
Location: MA (USA)
Posts: 1,773
Very nice!

now if only the physics engine were more exposed to python, the portals could be placed in walls and solid objects...
............................................
God kills a kitten every time someone makes a pointless thread

Balsa man and sulfur girl make a perfect match
#7   Old 16-Aug-09, 21:51   
Reply With Quote
warwickallison warwickallison is offline
Member
 
Join Date: Aug 2009
Posts: 15
Quote:
Originally Posted by Mentalturkey View Post
Looks awesome, but doesnt work for me
Check:

Blender version 2.49a. Portals require ImageMirror from VideoTexture module. Another "interesting" thing I do is call scene.addObject on an object in the current scene (to create the temporary copy so objects are half in two places at once while transitioning through portals). As I understand it, that wasn't always permitted.

GLSL. Does any GLSL work for ou? That's probably required (I only tested with it on - I'm interested in game creation).

Otherwise, what sort of problem do you get? I might be able to guess the cause with more info. Any error in the console window?
#8   Old 16-Aug-09, 23:37   
Reply With Quote
warwickallison warwickallison is offline
Member
 
Join Date: Aug 2009
Posts: 15
Quote:
Originally Posted by Captain Oblivion View Post
if only the physics engine were more exposed to python, the portals could be placed in walls and solid objects...
In Valve's game, portal placement is quite restricted (for gameplay reasons I suspect, more than engine constraints).

But given similar constraints, I think it would be possible to implement "portalable-wall" objects just using the current APIs:

1. Make all portalable walls just be Ghost boxes.
2. At startup, use a script to generate a matrix of small Invisible solid static "blocker" objects coincident with the portalable walls
3. When a blocker object touches a portal, hide (or just disableRigidBody) it until the portal goes away

The effectiveness would depend on the resolution of the blocker objects, which you would need to trade-off against performance.

Portals could be forced to only occur at the grid positions of the blocker objects, so there would be no "gaps".

The blocker objects would also double as portalgun impact detectors. Unlike the portals in Valve's game, portal projectiles could then even travel through portals (a game mechanic I always thought was sadly missing from Valve's game).

Hm... this doesn't really sound all that hard to implement. I'm working on something else of which portals are just a minor part (and more restricted than those in Valve's game), otherwise I would have just talked myself into doing it!

Last edited by warwickallison; 17-Aug-09 at 00:56.
#9   Old 17-Aug-09, 00:10   
Reply With Quote
mcguinnessdr mcguinnessdr is offline
Member
 
Join Date: Mar 2008
Location: right here
Posts: 663
I found out about portal just a few weeks ago, and have been thinking of ways to do it in blender. Looks like you have the same problem that I couldn't figure out, it doesn't work to well if the camera goes through the portal. Other than that, great job!
............................................
I am a Christian
#10   Old 17-Aug-09, 02:45   
Reply With Quote
Minifig's Avatar
Minifig Minifig is offline
Member
 
Join Date: Sep 2008
Location: America, Central time.
Posts: 2,971
Awesome!
This is so much better than a silly teleportation system.
............................................
This is my sig.
Feel free to use my texture repository: http://www.cdupload.com/browse/Minifig/3913_FKSa1
Please don't call me mini.
#11   Old 17-Aug-09, 02:55   
Reply With Quote
Captain Oblivion's Avatar
Captain Oblivion Captain Oblivion is offline
Member
 
Join Date: Jan 2006
Location: MA (USA)
Posts: 1,773
The blocked up walls solution will work in a pinch, but it's tough on resources and the collision for portals would be wonky (not round, and wouldn't fit perfectly around the portal)
As long as these portals are used like the ones in Prey (fixed to objects or positions, not dynamically created) they will be fantastic.

In terms of collision, it might be feasible to use a boolean modifier once the realtime-collision updating is implemented (in 2.49b, if I'm not mistaken) However you would need a boolean modifier on each portalable wall for each portal that could be in the scene. Still pretty damn resource heavy.
............................................
God kills a kitten every time someone makes a pointless thread

Balsa man and sulfur girl make a perfect match
#12   Old 17-Aug-09, 04:00   
Reply With Quote
warwickallison warwickallison is offline
Member
 
Join Date: Aug 2009
Posts: 15
Quote:
Originally Posted by mcguinnessdr View Post
it doesn't work to well if the camera goes through the portal
My use of it doesn't have a first-person camera, so I've not looked into that problem.

But I imagine it would particularly be a problem of resolution - you'd need to have a very high resolution on the VideoTexture. Maybe you could hide that with an excuse for a filter ("light get's blurred by quantum effects when passing through a portal"). ;-)
#13   Old 17-Aug-09, 04:49   
Reply With Quote
warwickallison warwickallison is offline
Member
 
Join Date: Aug 2009
Posts: 15
Quote:
Originally Posted by Captain Oblivion View Post
The blocked up walls solution ... collision for portals would be wonky (not round, and wouldn't fit perfectly around the portal)
Computer games are all about faking it. Add blockers around the portal, scaled to fill gaps to the wall blocks, plus whatever extra mesh for the portal (if you want them round). This would solve both the wonkiness near the portal and the resource costs (the blocks could be much lower resolution in this case).

The more I think about it, the more this "blocked up walls" solution corresponds to the constraints in Valve's Portal game. Makes me wonder if their game constraints are not perhaps similar engine constraints.
#14   Old 17-Aug-09, 04:58   
Reply With Quote
Captain Oblivion's Avatar
Captain Oblivion Captain Oblivion is offline
Member
 
Join Date: Jan 2006
Location: MA (USA)
Posts: 1,773
I believe their portals are hard-coded, using direct access to the physics engine- they cut a section into the wall wherever the Portal is placed (at least, that's what the design documents for the game Portal was based on said, and it's the same people who made Portal)
I think they might have actually used a method to split up the objects between portals, too, so if the portal was on a shallow wall objects wouldn't bump into the other side. (for example, portals can be placed on very thin panels, and long objects can still pass through them without issue)
............................................
God kills a kitten every time someone makes a pointless thread

Balsa man and sulfur girl make a perfect match
#15   Old 17-Aug-09, 05:40   
Reply With Quote
otto riis's Avatar
otto riis otto riis is offline
Member
 
Join Date: Jan 2007
Location: The Big Apple
Posts: 556
Very cool setup you've got going here, it even handles the infinite depth very well (when you're looking down the tunnel). However one thing I noticed was when you set up two portals face to face, and start making the ball go faster and faster through them, the ball eventually starts to hop, I think it is cause by collision with the bottom of the box portals, still a very nice demo
............................................
---Finished Projects: Castle II "Transport" II Asian Temple II Gallardo II Corridor 3 <-- click
---Foc. Crit./W.I.P.: Golden Gate Bridge II Subway II Picture II Beach House II Skyscraper(s) <--click
Favorite work combination: Blender+Indigo
Sublime Lime tastes like Lime ...
#16   Old 17-Aug-09, 14:01   
Reply With Quote
Minifig's Avatar
Minifig Minifig is offline
Member
 
Join Date: Sep 2008
Location: America, Central time.
Posts: 2,971
May I use this in a game that I'm making?
I can reference you however you like...

It's called Space Laser Battles (Name WIP)
It is similar to asteroids, and the portals work very well for the sides of the screen!
Attached Images
File Type: jpg Battle.JPG (57.3 KB, 47 views)
Attached Files
File Type: blend SpaceLaserBattles.blend (488.5 KB, 66 views)
............................................
This is my sig.
Feel free to use my texture repository: http://www.cdupload.com/browse/Minifig/3913_FKSa1
Please don't call me mini.

Last edited by Minifig; 20-Aug-09 at 14:14.
#17   Old 17-Aug-09, 23:31   
Reply With Quote
Sim88 Sim88 is offline
Member
 
Join Date: Aug 2006
Posts: 1,504
I still expected much more excitement, like 2-3 pages of "yeaahhh!!!!", portals have been wished for a lot here.
............................................
Here is my thread for BGE demo files
#18   Old 18-Aug-09, 15:52   
Reply With Quote
cray's Avatar
cray cray is offline
Member
 
Join Date: Dec 2008
Location: France
Posts: 547
You are right, Sim88.
That release is amazing.

Warwickallison, congratulations
............................................
Portfolio : www.aandria.com
My contribution : Third person Template
#19   Old 18-Aug-09, 16:49   
Reply With Quote
Captain Oblivion's Avatar
Captain Oblivion Captain Oblivion is offline
Member
 
Join Date: Jan 2006
Location: MA (USA)
Posts: 1,773
Minifig- if you use the portals for your game, I recommend wither showing them (it would be cool to see the game repeating infinitely in all directions) or dramatically simplify the math (since I'd imagine the sides of the screen can't rotate, you don't need to account for that)
............................................
God kills a kitten every time someone makes a pointless thread

Balsa man and sulfur girl make a perfect match
#20   Old 18-Aug-09, 16:56   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 12:56.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists