[SOLVED] Objects existing in 2 worlds at same time?

Post Reply
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

[SOLVED] Objects existing in 2 worlds at same time?

Post by paulggriffiths »

I wish to use bullet, but am wondering if an object can exist in 2 worlds?
I have multiple portals and each portal contains a world.
I wish to have objects move from world tro world so at some time I need the object to exist in two worlds at the same time, or even more worlds bcause the object may span many worlds if the portals are very close together.

Any advice? Can it be done?

Thanks.

Heres some screenshots of my render engine showing my portals implimentation:

Image
Image
Image
Image
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by benelot »

Hello,

A bullet physics world prevents adding an object to multiple worlds. I think when you travel through your portal, your object just switches out of one world and into the other. So at some point, it is out of both worlds. If you look at games like Valve´s Portal, you will realize that you are always only in one physics world. If you really need it that an object can be present in multiple worlds through your portals, you might be better off taking just one physics world and if you surpass the border of a portal, you apply the appropriate forces you would expect at the other world to your object. Maybe I need more context here: What is your main benefit of multiple worlds? What changes from one to the other?
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by paulggriffiths »

benelot wrote:What is your main benefit of multiple worlds? What changes from one to the other?
Being inside a portal and being behind a portal are two different worlds existing in the same space so need multiple physics worlds. Hope you nderstand can't have just one physics world.

I may have to create a "ghost" object/s, one for each world and if an object collides with a object in one world then update the position of the other "ghost object/s too.
But may have a problem if the updated ghost object/s then collide with an object due to it's new position, don't want to end up in some strange infinite loop.

Can't simply switch worlds as the the object may go though multiple portals if the object is large such as a car or truck and the portals are close together.

I'm creating an applications and games engine and don't know what programmers are going to impliment so need to cater for most posibilities.

-------

For those that are interested in my portals implimentation, it's all done in a single render pass, no rendering individual portals contents to an offscreen buffer and rendering the texture to the portals entrance.

The engine is a differed renderer, was not sure if could do portals with deferrerd rendering but turns out it can be done.

Lights and shadows can enter and leave the portals and even span multiple portal too.
If im correct this is new technology?

I'm also creating a 3D GUI system, Windows, Scrollbars, Buttons ect. All in 3D, portals are a requirement as don't want to render to the sides or behind the 3D windows but do want the contents to be scrollable and even have objects such as characters and models pop out of the 3D windows for an interesting presentation.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by benelot »

Maybe you can solve your problem with collision flags instead of different physics worlds. Because what you want to control is in fact if two objects collide or not. So if an object passes through your portal, it gets the collision flag of the world behind it and loses the collision flag of the world before it as soon as it is completely through the portal. An object going through multiple portals at the same time would have all collision flags of all worlds it is currently in. I only see one problem with this, but also your approach (if an object within multiple worlds was possible). The problem is that an object (let us say it collides with things of world 1) that is partly through the portal (which goes to world 2) would hit an object that is behind the portal, but did not go through the portal (this object also collides with things of world 1). The object behind the portal just went around the portal and is now behind it. To do it correctly, your physics object then would have to be transferred to the other world in parts and that could be very hard. How do you handle this situation anyway? What does happen if you go behind a portal and pass it? Is entering from the front and the backside the same thing?
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by paulggriffiths »

benelot wrote:How do you handle this situation anyway? What does happen if you go behind a portal and pass it? Is entering from the front and the backside the same thing?
From behind the portal has a back to it. Nothing should pass into the portal from behind.

Collision flags seem a good idea as could have many portals, and having many physics worlds would take up memory and slow down the system.
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by paulggriffiths »

Won't be able to use collision flags as can't "set to all" as sometimes portals ocupy the same space. Shame that is.
Unless objects can have multiple collision flags?

Edit:
Just looked at collision flags and can set multiple: http://www.bulletphysics.org/mediawiki- ... _Filtering so should be good.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by benelot »

You switch from one filtergroup to another. So you can have multiple groups that only collide among themselves.
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by paulggriffiths »

Can't use collision flags as can only have up to 15 different flags and my engine can easily have more than 15 portals, though there are other ways described
in the link above so should be ok.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Multiple worlds: Objects existing in 2 worlds at same ti

Post by benelot »

Yeah, flags are faster than other methods, but if you need more, you take another method to solve your problem. I am happy that you found a way!
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: [SOLVED] Objects existing in 2 worlds at same time?

Post by paulggriffiths »

Just thought I would share some more screenshots of my portals.
The portals are near complete(thank god! It's extremely complicated to implement and I'm extremely tired.) so soon be including the bullet physics.
I also need the bullet physics for mouse picking as I'm also creating a 3D GUI system, that's what the smiley faces are about, the beginning of 3D buttons.

My graphics engine is for both applications and games. It's a deferred renderer with multiple lighting and multiple shadows(both entering and leaving the portals which I believe is a world first?) with normal and parallax mapping.
The complete image is completed in just 3 renders, the shadows, the geometry and finally the lighting.
I've spent about 2 months on it so far which is pretty good as integrating all the different technologies is time consuming, most of it spent on the portals.

Not too sure how hard it's going to be including the bullet physics as each portals scene is in a different world space so there's going to be a lot of translating objects into the same world space to check for collisions. Wish bullet physics had a world space changer but I don't think so(hint... as virtual reality is a buzz right now, different scenes may require different world spaces.)


Image

Image

Image
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: [SOLVED] Objects existing in 2 worlds at same time?

Post by benelot »

What should your world changer do? I think all you need is removing from one world and adding to another world?
paulggriffiths
Posts: 21
Joined: Tue Jan 31, 2017 11:21 am

Re: [SOLVED] Objects existing in 2 worlds at same time?

Post by paulggriffiths »

benelot wrote:What should your world changer do? I think all you need is removing from one world and adding to another world?
Yes, I think I got it wrong. I was thinking if a portal is rotated by 90 and so is the scene and objects within it then would need to change back the orientation to check for collisions.
I was very tired when thinking this and posted this thread online.

Thanks anyway.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: [SOLVED] Objects existing in 2 worlds at same time?

Post by benelot »

Your portals look great btw! At some point you maybe can showcase it in the other bullet subforum, which is made for this. Do you have a video of your first person character passing through the portals?
Post Reply