Sign in to follow this  
AlgorithmX2

Physics and Planet-oids

Recommended Posts

I'm trying to come up with a plan of attack for this, but so far all my solutions just seem to have to many downs sides, so I was wondering if anyone else has some wisdom to share with me on the subject. Here is the basics of what I'm trying to do,

[b]Game Overview:[/b]
I'm using bullet to simulate physics, and I'm creating a kinda of space flight game, where you can travel from planet to planet, the planets are not nearly as large in game as say the earth, think large asteroids it might take a two - four minutes to fly around one. You can land, and take off, and do some things out of ship, like talk to shop people, and look for things in enemy bases, and some out of ship combat.

[b]Scale:[/b]
The problem is I've got a decent number of these say 10-16 and they will likely each have a friendly base / enemy base with a some stuff going on on each one, I intend on supporting single player, as well as up to 8 Player Client Hosted games.

[b]My Plan:[/b]
So the best of my solutions I've come up with is based on selective simulation. where if a player is near a planet I can simulate AI and everything, but if no one is near by I can pull all the objects from the physics simulation and stop the AI, as for each planet-oid I was thinking of creating a large set of convex objects mapping from around -6m below lowest surface detail to the physical surface of the planet-oid, in chunks, I am thinking of doing this with a data level detail ( which is probably 2-4 points per meter ), and then using geometry shaders or pre-processing to smooth the surface for presentation, so it will be a hollow sphere, so that the bounding boxes of the individual chunks do not over lap to much.

[b]My Thoughts:[/b]
The downside is see to this, is that I will have a huge number of static convex objects for each planet-oid to do collision against, to pair this with the fact that I want to have a decent number of simulating bodies as well I just see that this might get out of hand very quickly, especially if all 8 players are on different planets so I need to simulate 8 planet-oids at the same time. I considered not simulating things to far away, but the size of my planets in my opinion is actually a down side on this, as if you on the other side of the planet your not that far way, and the enemies still might want to come after you, same as you approach the planet, they might send guys to intercept you be for you arrive.

Do you think this kinda of setup will work or am I missing something, or do I need to make changes for this to be feasible?

Does anyone have any suggestions or experience with something similar that you might mind lending?

Thanks for any input.

Share this post


Link to post
Share on other sites
[quote name='AlgorithmX2' timestamp='1313439986' post='4849541']
I'm trying to come up with a plan of attack for this, but so far all my solutions just seem to have to many downs sides, so I was wondering if anyone else has some wisdom to share with me on the subject. Here is the basics of what I'm trying to do,

[b]Game Overview:[/b]
I'm using bullet to simulate physics, and I'm creating a kinda of space flight game, where you can travel from planet to planet, the planets are not nearly as large in game as say the earth, think large asteroids it might take a two - four minutes to fly around one. You can land, and take off, and do some things out of ship, like talk to shop people, and look for things in enemy bases, and some out of ship combat.

[b]Scale:[/b]
The problem is I've got a decent number of these say 10-16 and they will likely each have a friendly base / enemy base with a some stuff going on on each one, I intend on supporting single player, as well as up to 8 Player Client Hosted games.

[b]My Plan:[/b]
So the best of my solutions I've come up with is based on selective simulation. where if a player is near a planet I can simulate AI and everything, but if no one is near by I can pull all the objects from the physics simulation and stop the AI, as for each planet-oid I was thinking of creating a large set of convex objects mapping from around -6m below lowest surface detail to the physical surface of the planet-oid, in chunks, I am thinking of doing this with a data level detail ( which is probably 2-4 points per meter ), and then using geometry shaders or pre-processing to smooth the surface for presentation, so it will be a hollow sphere, so that the bounding boxes of the individual chunks do not over lap to much.

[b]My Thoughts:[/b]
The downside is see to this, is that I will have a huge number of static convex objects for each planet-oid to do collision against, to pair this with the fact that I want to have a decent number of simulating bodies as well I just see that this might get out of hand very quickly, especially if all 8 players are on different planets so I need to simulate 8 planet-oids at the same time. I considered not simulating things to far away, but the size of my planets in my opinion is actually a down side on this, as if you on the other side of the planet your not that far way, and the enemies still might want to come after you, same as you approach the planet, they might send guys to intercept you be for you arrive.

Do you think this kinda of setup will work or am I missing something, or do I need to make changes for this to be feasible?

Does anyone have any suggestions or experience with something similar that you might mind lending?

Thanks for any input.
[/quote]
You should work with level of detail(LOD) for AI and physics. In fact, when no player is around a planetoid, it is nevertheless likely that some kind of simulation is still going on, but on an other level. On the lowest level only the economy of a planetoid is simulated and a simple sphere simulates the whole planetoid, on the highest level individual npcs are simulated and the surface is very detailed.

Further on I would subdivide your planetoids into chunks or tiles, take a look at the following image:

[img]http://uploads.gamedev.net/monthly_08_2011/post-112074-0-84133200-1313471595_thumb.jpg[/img]
It shows a cube subdivided by [url="http://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface"]catmull-clark[/url] algorithm in blender. With this approach you can easily divide each "cube" face into tiles and you only simulate and load tiles which are near a player. No need to simulate the whole planetoid when the player can only interact with less than 1%.

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1313471747' post='4849710']
You should work with level of detail(LOD) for AI and physics. In fact, when no player is around a planetoid, it is nevertheless likely that some kind of simulation is still going on, but on an other level. On the lowest level only the economy of a planetoid is simulated and a simple sphere simulates the whole planetoid, on the highest level individual npcs are simulated and the surface is very detailed.

Further on I would subdivide your planetoids into chunks or tiles, take a look at the following image:

[img]http://uploads.gamedev.net/monthly_08_2011/post-112074-0-84133200-1313471595_thumb.jpg[/img]
It shows a cube subdivided by [url="http://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface"]catmull-clark[/url] algorithm in blender. With this approach you can easily divide each "cube" face into tiles and you only simulate and load tiles which are near a player. No need to simulate the whole planetoid when the player can only interact with less than 1%.
[/quote]

Thanks for you feed back, your right about the economy there will generally always be some form of simulation even if its just economy / quest management things like that but those are not very expensive cpu/gpu wise because they are fairly passive, only requiring changes every so often.

I think the issue I see with using the "Tile" method is that the planet-oids are pretty small, so if your on one side of the planet, there might be enemies being dispatched by the enemy base on the other side, if I say put the 15% ( estimated visible area of planet-oid when on surface ) of the planet-oid into the physics system, when I simulate the distant AI I would have to use a simplified version of the planet-oid ( say a simple sphere which would be virtually 'free' in comparison to the real surface ), I for see some nasty glitches if you suddenly force a tile into the physics engine ( when you move to a previously unloaded section ) where there are already enemies traveling in that area as it might get them stuck in the terrain.

I guess I could detect this kind of stuff and try to compensate for by moving them manually when a tile loads, but I see it being one of those things that that is never quite right, creating the effect of enemies suddenly teleporting into view, or similar.


Does this make since? or did I miss-understand something in your suggestion?

As for the detail level, I can always adjust, I just want to aim for as high quality as I can, and then I can scale it back once I get there to a good level for performance. I just want to have some confidence that I won't put in a huge amount of time only to need to start over because it looks absolutely terrible when I get to that point, time is the most valuable resource after all.

Share this post


Link to post
Share on other sites
[quote name='AlgorithmX2' timestamp='1313515241' post='4849929']
I think the issue I see with using the "Tile" method is that the planet-oids are pretty small, so if your on one side of the planet, there might be enemies being dispatched by the enemy base on the other side, if I say put the 15% ( estimated visible area of planet-oid when on surface ) of the planet-oid into the physics system, when I simulate the distant AI I would have to use a simplified version of the planet-oid ( say a simple sphere which would be virtually 'free' in comparison to the real surface ), I for see some nasty glitches if you suddenly force a tile into the physics engine ( when you move to a previously unloaded section ) where there are already enemies traveling in that area as it might get them stuck in the terrain.
[/quote]
In my game I can attach/detach a npc from the physics simulation (btw. using bullet too). When the player is not around, I detach the npc and let them move only on a waypoint system. When the player comes near, I attach it to the simulation, take the closest waypoint, project the npc on the ground and let him go on. When you are not using some kind of waypoint system, the npcs could move on a grid optional with a altitude.

[quote name='AlgorithmX2' timestamp='1313515241' post='4849929']
I guess I could detect this kind of stuff and try to compensate for by moving them manually when a tile loads, but I see it being one of those things that that is never quite right, creating the effect of enemies suddenly teleporting into view, or similar.
[/quote]
When done right you will avoid poping artifacts. Take a look at L4D , they spawn 100s of zombies right next to you and you never see a single zombie poping up.

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1313517104' post='4849938']
[quote name='AlgorithmX2' timestamp='1313515241' post='4849929']
I think the issue I see with using the "Tile" method is that the planet-oids are pretty small, so if your on one side of the planet, there might be enemies being dispatched by the enemy base on the other side, if I say put the 15% ( estimated visible area of planet-oid when on surface ) of the planet-oid into the physics system, when I simulate the distant AI I would have to use a simplified version of the planet-oid ( say a simple sphere which would be virtually 'free' in comparison to the real surface ), I for see some nasty glitches if you suddenly force a tile into the physics engine ( when you move to a previously unloaded section ) where there are already enemies traveling in that area as it might get them stuck in the terrain.
[/quote]
In my game I can attach/detach a npc from the physics simulation (btw. using bullet too). When the player is not around, I detach the npc and let them move only on a waypoint system. When the player comes near, I attach it to the simulation, take the closest waypoint, project the npc on the ground and let him go on. When you are not using some kind of waypoint system, the npcs could move on a grid optional with a altitude.

[quote name='AlgorithmX2' timestamp='1313515241' post='4849929']
I guess I could detect this kind of stuff and try to compensate for by moving them manually when a tile loads, but I see it being one of those things that that is never quite right, creating the effect of enemies suddenly teleporting into view, or similar.
[/quote]
When done right you will avoid poping artifacts. Take a look at L4D , they spawn 100s of zombies right next to you and you never see a single zombie poping up.
[/quote]

I kinda like the idea of using a waypoint system calculated from the real geometry, this would allow me to keep the npcs out of the ground and when I load a tile, I can simply move them from the waypoints into real space, without any need for additional calculation. I could also do basic distance checks on enemies when they are using the waypoints so they don't bunch up.

I just need to be careful about when/how I move them from the physics simulation to the waypoints, I could possibly add temporary nodes to the waypoint list to allow then to transition smoothly if necessarily, or snap them into it, I might need to do some testing with this.

This would also scale very well, allowing for larger planets and smaller planets, with some tweaking on how dense the waypoint grid is.

Thank you very much for the idea, I believe with this I can find a good balance in my implementation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this