• Advertisement
Sign in to follow this  

Open Worlds

This topic is 2343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm creating a video game that I'd like to be an open world game similar to how Assassin's Creed: Brotherhood does it. I don't want it to be procedurally generated, like in Minecraft. I want it to be a predefined map that gets loaded as the player moves around. This is going to be my first major game and I need some insight on how I should approach this. Below are some things that I know I'm gonna use in my game (some might not be related to this, but you never know...):

  • C++
  • OpenGL
  • SDL
  • Glut
  • GWEN
  • Bullet Physics Engine
  • Custom Engine
  • Boost (for python scripting support, etc.)I'm trying to make the game cross-platformable with minimal code changes (making it easier to update).

    Thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
It begins with the word 'streaming' and ends with the word 'chunks'.
Seriously though, that's a very big question - which will have a whole load of variables depending on what game you're making and what kind of system you're looking for. Read up some on streaming geometry and that should get you started - later on feel free to ask some more directed questions.

Share this post


Link to post
Share on other sites
Yeah, the reason I asked is because there really isn't a simple answer. It's more like a soup of solutions. LOD terrain/models is one aspect. Then you have to break the work up into various chunks and continuously load the chunks around the player.

Share this post


Link to post
Share on other sites
Yeah, chunks are pretty much the "solution"; think of you player as moving across a grid in the world, at any given time you'll need a selection of chunks loaded around them.

The details depend on the game and gets complicated as you increase the distance the player can see in the world, which also brings it's own fun of depth buffer precision too

Share this post


Link to post
Share on other sites
Alright, so chunk streaming seems the way to go... So can anyone give me some insights as to how to setup a chunk streaming system? I did a web search on both streaming chunks and chunk streaming and all the results are related to web development (mostly ASP.NET).

Share this post


Link to post
Share on other sites
Also, do I have to use a chunk streaming compatible file format for anything that I'd like to stream? Or do I just make the map, then break it up into pieces (separate files) then put them all in something like a *.pk3 file?

EDIT: Do you think (or know) the boost library (boost.org) would have something for chunk streaming...?

Share this post


Link to post
Share on other sites
Here's a good write on the system which alot of games use.

http://www.gamasutra...data_baking.php

They build the asset for the desired platform then dump it as a binary blob, which is then read in at runtime and they fix up the pointers where needed. It's tricky to get right but once you have the system in place it's very robust.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Whatever the "chunk" is depends on your game. It could be groups of local entities, blocks of 2D or 3D maps, node graphs of AI, or whatever.

There is no out-of-the-box system for "chunk streaming", because "chunks" are a concepts that are game or application-dependent, and "streaming" just means moving the data from one place to another (whether it's from one computer to another computer over a network, or from disk file to RAM, or from one part of your program to another part), there is no library that can ever possibly cover all the solutions.
There are libraries for streams, there are libraries for networking, there are libraries for file loading, there are libraries for 3D modelling or whatever.

"Chunk streaming" isn't an answer to a problem, it's the name of the problem, and how you go about solving that problem is up to you. But rest easy, it's not a complicated problem! wink.gif

If in your case a "chunk" is a segment of terrain data, then all you have to do is have your world broken up into equal size chunks (They don't even have to be equal size chunks, but for simplicity's sake, let's assume they are), and figure out what chunk the player is currently on, and what chunks are around the area the player is currently on, and load them all.

[size="1"]chunkstreaming.png

The size of a chunk completely depends on whatever works for your game. It could be a mile wide, or only a dozen feet.
How the chunk is loaded depends on what custom or non-custom file type you make your chunk.
How near a chunk has to be to be loaded into memory again depends on the needs of your game (and even the current gamestate... looking through binoculars might require even more distant chunks to be temporarily loaded and then discarded).

Also, just because a chunk is loaded does not mean you need to display it (only display the ones in the direction the player is looking), and just because it's visible/not-visible does not mean you have to (or don't have to) do collision detection on it (only do collision checks with the objects immediately around the player, which is a much smaller radius then the player's sight. Also, just because an object is not visible, doesn't mean you skip doing collisions, or the player could walk through walls by walking backwards).

Honestly, streaming chunks is absurdly simple. Currently, you load a texture or sound file when it's needed, and unload it when it's unneeded. Well, you can just as easily load a chunk of an area when it's needed, and unload that when it's no longer needed.
The hard part is loading the chunks fast enough to be "seamless" (no lag spike [size=2]or game pause [size=2]when crossing chunk boundaries).

Share this post


Link to post
Share on other sites

So I'm creating a video game that I'd like to be an open world game similar to how Assassin's Creed: Brotherhood does it. I don't want it to be procedurally generated, like in Minecraft. I want it to be a predefined map that gets loaded as the player moves around. This is going to be my first major game and I need some insight on how I should approach this. Below are some things that I know I'm gonna use in my game (some might not be related to this, but you never know...):
  • C++
  • OpenGL
  • SDL
  • Glut
  • GWEN
  • Bullet Physics Engine
  • Custom Engine
  • Boost (for python scripting support, etc.)I'm trying to make the game cross-platformable with minimal code changes (making it easier to update).

    Thanks in advance for any help.



Years ago there was a document from a dev of a old time (16 bit) game that used chunks but had them of irregular size (not just fixed grid blocks) and I remember that they mentioned having to renormalize coordinates to be relative to the current chunk (or several if the players was near a boundry). Even with 32bit and 64bit floats if your world is large enough you may have to do something like this.

Anyway one thing you may want to look into is LOD (level of detail) where if you want scenery in the remote distance (for nice visial effect) that the chunks or zones have mor ethan one representation -- a lower detail that preserves the shape but lacks closeup detail and likely the NPCs and their behavior script executions. As a player moves the far edge of the window of chunks/zones loads ahead but the most distance ones are smaller/simpler data sets which may be 'upgraded' to the full detail when the player get near enough.
You may have more than just 2 level of detail (LOD) especially if you have scenery to the horizon (or far enough anyway) and that furtest detail is mainly just the terrain contours of sufficient detail. The advantage is you load a smaller block of data for an area you may not go to leaving more memory/processing resources for the very near 'chunks'.

If you have AI driven 'significant' NPCs which can travel across your world (versus local 'furniture' NPCs who stay in their own chunks) they will need to have a bi-modal behavior logic -- full detail with all interactions expected to be seen by the player and a second 'generalized' behavior where they dont go thru all the finely detailed actions (and animations)and interact with the far chunks in a simpler but still logical way (simulating what they would do matching the content of those chunks -- ie pathfinging in a cruder network of nodes that represent larger steps but with correct cost weights)

"Celluar Automata" might be something to investigate to do some of this 'generalized' behavior, where objects may be factions with areas of effect around them which can effect spawn patterns for 'local' NPCs for on-the-fly generated 'encounters' (and the temper/flavorings of those areas) 'Influence Maps' would be another subject to investigate.

'Some of your terrain (open country) can still be procedurally generated (using a array of coefficients and regeneration) -- but usualy the seed data for the large areas would be hand created for cohesion/required terrain patterns for the game scenario. The high detail areas and unique location will have to be made by hand (again for cohesion of the scenes where the player will most notice them). You still can use templates to create local populations (so they can change as the plot procedes) and have the behaviors likewise be adjusted.


Unfortunately these operating systems dont like 'load on the fly' from disks and this game sounds like there is no server on a seperate machine.
You may have to contrive some way to justify the freezes/delays while chunks are loaded if the world is large enough that it wont fit all in memory.
If teh projects expected target is in a time when the Flash disks are expected to be on most machines that delay effect may (hopefully) be alleviated.

Share this post


Link to post
Share on other sites
Alright, did some searching around for games that use open worlds. Found L.A. Noire. That is exactly how I'd like my game to be, open world, AIs who drive around and walk around, etc. I'd also like night and day sequences (my game is an open world driving simulator similiar in concept to GTA:SA).

Btw, I understand the concepts you guys are explaining, but I have no clue as to how I would implement it in C++...

Share this post


Link to post
Share on other sites

Btw, I understand the concepts you guys are explaining, but I have no clue as to how I would implement it in C++...


That's the fun part. Figuring it out. Honestly, we can't hand you a solution, because the solution is different for every game. The concepts are generally the same, but the devil is in the details. Do you know how to make a simple game yet? i.e. load a level, characters, objects, and handling all of that?

Share this post


Link to post
Share on other sites
I also can't hand you a solution because it would get me in trouble at work ;)

But yeah,. what wodinoneeye said is very important; you WILL need to renormalise coordinate spaces across the world. This applies to ANYTHING in the world which uses floating point numbers, so not just rendering but physics as well.

Rendering wise failure to do so will lead to increasingly bad rendering artifacts as you move further away from (0,0,0) in the world. For example in our game the first thing to go was shadow map rendering as we lost too much z-precision and that was only once you traveled ~1,000m or so in the world (where 1m = 1.0f) You could improve that at the cost of fine detail if you used a different scale, but the point is we ended up renormalising every 1/4 of a chunk, so about ever 250m or so, in order to keep rendering precision high enough. (The number seem right anyway... I'm working from memory and I've been to sleep a few times since the code was written ;))

Share this post


Link to post
Share on other sites

[quote name='jsvcycling' timestamp='1316446713' post='4863376']
Btw, I understand the concepts you guys are explaining, but I have no clue as to how I would implement it in C++...


That's the fun part. Figuring it out. Honestly, we can't hand you a solution, because the solution is different for every game. The concepts are generally the same, but the devil is in the details. Do you know how to make a simple game yet? i.e. load a level, characters, objects, and handling all of that?
[/quote]

I've made 2D games in the past (mostly written in Java) but this is gonna be the first 3D game I write. I'm guessing that you're gonna tell me to take it slowly and start with a simpler concept for a 3D game... right?

Share this post


Link to post
Share on other sites
Hey, found this http://gritengine.com/, did a quick overview of it, looks pretty good. It's specially designed for open world games. What do you guys think as a starting point...?

EDIT: It depends on Bullet Physics Engine, Lua, and OGRE. I'm already using Bullet (for Physics) and Lua (for scripting) and building a custom engine around OGRE shouldn't be too hard.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement