Big 3D landscapes

Started by
17 comments, last by wodinoneeye 15 years, 8 months ago
I'm making a game where is a huge spaces. The problems are (on the server): 1. There are some elementary physics (vehicles are boxes with elementary processing) and the lanscape is not a height array (there can be walls etc). So it's hard to implement integers. 2. double is too big for coordinates (big traffic and clients need floats or integers). 3. float for global coordinates loses accuracy. 4. World has not equal density (somewhere we have big lakes, and somewhere there are a lot of people on 10x10 meters area). So divide the world for 1x1 km ranges sometimes big (500 people in area, sometimes very small (for empty lake we need about 16 areas). 5. World is not flat. There are some caves, or subway lines so tunnels are under the world surface, but from these tunnels we need not see the surface actions. 6. Maybe these empty lakes/fields can be overcrowded. Some guys created a party in a field and there are hungreds of people but expected 10. 7. And there can be not linked locations (houses). When I'm inside I don't want to interract with the outside world. I know that all of these points can lead to answer "It cannot be implemented" so maybe you can advice to strike smth off the list? Or it's real to implement? Then how?
VATCHENKO.COM
Advertisement
Nothing is impossible, you just have to find the right way to go about it. Most effects in computer games are close approximations rather than exact models, anyway.

1. From what I've seen (mostly ODE, and I might not have got this 100%) the physics can be split into the World, the objects in the world, and the connections between objects. The world is any static parts of the physics simulation, so if the player, or NPCs cannot knock down buildings, the walls and so on would be part of the world. In a more direct answer to your question, use bounding boxes for your walls and buildings as well as the objects that move around. The reason for using bounding boxes in the first place is to keep the collision code simple, so use a simplified version of your scene data for checking collisions against.

2. When you say "big" traffic, do you mean "lots" of traffic? Try and be realistic here. If you're not working for a big company, and you can't guarantee to get some serious exposure for your game, there is no guarantee that your game will have "big" traffic, so don't worry too much about this right now. If you're worried about minimising the data passed between client and server, look into compression techniques. Remember, ZIP is your friend :)

3. This one I can't really help you with. Perhaps, using doubles for the math, then converting to floats later, when the error margin isn't so great?

4. I have yet to see a game with "equal density". Sounds like you've already answered this one yourself, but if you're still not sure, I recommend Googling Quadtrees.

5.The world, indeed, is not flat. In regards to this point, you're now looking at Culling techniques. Again, use Google.

6. From this, I'm thinking you want to make an MMORPG? I'm also of the opinion you have not made another (simpler) game before this? It's not impossible (look at any MMORPG on the market, and you can have crazy numbers at single locations) but if this is your first game, it may well be impossible to do AT THE MOMENT. Build up your experience on something like a Tetris clone, or Breakout first.

7. If the location is not linked, simply don't tell the rest of the game whats happening in the location.

All in all, as I mention in point 6, it looks like this type of game is currently out of your reach. Now, that doesn't mean you will never be able to do it, just that you probably can't right now. Try a simple puzzle game first, and in 2D, before jumping into something this ambitious
> mostly ODE
No, no, no... Most of physics laws are not in my game. I don't use friction, joints, many contacts. It's enough:
1. If person stays on the ground and the angle is less than 40 degrees - he continues to stay. If more - begins to slide.
2. Quite the same with the cars but the angle is different. There are no 4 contacts for wheels and checks for smart collisions. It's a sphere like the person.

> The world is any static parts of the physics simulation
Many objects became static. If person stands on the ground and doesn't move - it becomes static.

> using bounding boxes in the first place
Yes, I do.

> When you say "big" traffic, do you mean "lots" of traffic
I mean that I can use even 128 bit for each x, y, z, but why? And compression is not good in my place. It can do only computers...

> doubles for the math, then converting to floats later
If you make "float a = 0.f; float b = 10000.f; a += 0.0001f; b += 0.0001" you will be surprized. When you will make b -= 10000.f then abs(b - a) will be a lot!
The same is to store integers and use double for math - everywhere are conversions (maybe useless).

> 4. I have yet to see a game with "equal density"
But other games usually make an array with NxN kilometers which means equal density.

> Googling Quadtrees
Quadtrees are good in offline games. How will this work in online when you can't use float (as global offsets), double is too big, integer is bad. I supposed to use zones offsets as integer, inside there are long positions.

> 5.The world, indeed, is not flat
But quite all the games do that (Wow, lineage). They are not good when under surface there is another one surface.

> From this, I'm thinking you want to make an MMORPG
Why all the people think about MMORPG all the times? There are MMOFPS, MMORTS and other... And I made about 3 MMO games before so don't advise easier:)

> 7. If the location is not linked, simply don't tell the rest of the game whats happening in the location.
What to do with the quadtree? Do I need to make about 10 quadtrees?
VATCHENKO.COM
point 3:
In our recent mmo we use floats for coordinates without any problem.

1.00f == 1 meter.

(pos = vec, rotation = quat -- all floats)
www.ageofconan.com
So make your MMO world larger than 500x500 km, or 500000.f, 500000.f. Yes, many people make MMO like non-MMO: there is one small town (or many towns that separated to non-neighbour locations), players online = max 20. In this case I don't need even to break the world to zones/locations or use trees...
VATCHENKO.COM
i think that you will find that 500kmx500km is more than sufficient.

Wow has an estimated size of 200 sqaure miles.

But if you already know for a fact that using floats will cause you problems because the numbers used are very small or very big, then ignore my suggestion :)
www.ageofconan.com
It seems that WoW doesn't use floats as global coords. Maybe double - so yes... Because float when reaches 10000 make objects to move randomly...
VATCHENKO.COM
1. Then use floats.

2. Use floats with a 3-byte grid index. Grids are world partitions with a set size, and are arranged in a 256x256x256 cube. If each grid were 50km wide, the world's width would be 12800km, which is about the diameter of the earth. Unless you have objects moving past grid boundaries, the server can ignore the grid index. When sending object positions to the client, you only need to send the grid index for the object if it in a different grid than the client who is being sent the message.

3. See above. 50km should be enough accuracy. Should the object go past 50km from the centre of the grid, it gets moved to the closest grid and the position recalculated.

4. Welcome to one of the PITA of MMORPG developers. If your would is continuous (which by your requirements I assume it is) you'll need a way of allowing objects to interact with each other on different grids anyway. Hence, the grid system should be used for storing coordinates only. For player interactions you'll need a much more dynamic system for load balancing.

5. Again, grid solution, and don't send the clients information about things that it can't see (this is a general multiplayer rule).

6. See 4.

7. Reserve some grids for houses. When you "enter" the house, teleport to the new grid. If you make sure the houses are solid (i.e. you can't enter/leave them except by teleporting through the doors), you could have all of the houses side by side in a couple of grids and they wouldn't be able to interact with each other.


So you'll need a fixed grid scene-graph with more specific scene graph structures for the actual geometry. And then the worlds best load balancer, which doesn't actually exist. And a supercomputer or two to keep track of all the data.

Good luck :D
Why do I need a super computer? Server must handle about 2000-5000 users. Every object's update is a simple process (no hard physics equation, only one or two contacts per object, and it's impossible that every of 2K users perform a hard acrobatic tricks).

And what do you advise about visibility? Yes, I have such grid, but how to define whom do I see, who can see me? And if nobody saw me before I need to send an information about me first. Also there is some static objects that cannot inform dynamic objects that "we are here".
VATCHENKO.COM
You can split the world into non-equal-sized areas.

Also, doubles don't have to be too large for transmission. You can transmit doubles compared to some reference point, and only change the reference point in effect when the player moves more than a kilometer.

You can also use 32-bit ints with fixed point. Over 500 kilometers, you will get 1/10th of 1 millimeter of resolution, which ought to be enough for most position values.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement