• Welcome to SC4 Devotion Forum Archives.

[Programming] Tile Engine

Started by Nique, September 01, 2009, 10:15:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nique

The main problem with "let's build at all angles" .. is.. how to identify pieces of empty land? And also, how to identify 'buildings'. In SC4, everything was based on the tiles (quads). (grid, buildings, roads.. everything was identified by the origin of the object, and in what tile ID it was positioned in.
Proudly developer of

croxis

I would assume the same way real time strategies games handle base building.

Nardo69

Why not doing the same nut with a smaller grid? 16m*16m is way too big given that one single lane has a width of 2,50-4,5m

Make a small grid - e.g. 1m length- and you'll have the flexibility of almost "building in all Angels" together with the convenience of a grid.

tomkeus

Quote from: Nardo69 on September 02, 2009, 04:30:59 AM
Why not doing the same nut with a smaller grid? 16m*16m is way too big given that one single lane has a width of 2,50-4,5m

Make a small grid - e.g. 1m length- and you'll have the flexibility of almost "building in all Angels" together with the convenience of a grid.

We have to differentiate two things about tiles. One thing is construction grid. It has already been mentioned in other topics (check Core disagn topic) that, most likely, we'll implement freeform building at all angles so as construction is concerned grid is unnecessary. But we need grids to simulate certain things, like air pollution, land value, desirability, traffic noise. So here we have to be careful about how we discretize space. Too small tiles: too much computation time. Too big tiles: low accuracy.

If we're to go for 10x10km maps (although it would be interesting to examine possibility of non square maps) or 100 square kilometers map, and use 1m tile, that would give 10 million tiles which is extremely expensive to compute. 10m Tiles reduce this number 100 fold, 15 m tiles 225 fold, while still giving adequate precision. Average building lot size is of the order or 10-20m.
#define TRUE FALSE /*Happy debugging suckers*/

MTT9

Just a little question here... ()what()

When you say "let's build at all angles", you really mean all angles? Because i can't image rendering every possible angle for every single biulding. I think that 32 angles would give the player enough flexibility but still keep the renders and modells light enough.

This is what i mean by 32 angles:


I'm right or i'm too stupid to understand?
You can call me Matt

Nique

#5
No, the buildings you want on the specific angle is a low quality 3d model. Once you've agreed the current angle / position.. and you are done.. the rendering phase starts.

So, with this technique you can build on all angles ;)

You can read more about this technique in the core topic (http://sc4devotion.com/forums/index.php?topic=8737.0)
Proudly developer of

Genocidicbunny

So, the way I see it, actually plopping down buildings at any angle is fairly easy, the hard part is when you have an empty lot and want to put a building in it, but the lot is already surrounded by several others. Well, why not have the new building snap to ts neighbors, or, if the player wishes to override said snap-to, the building's footprint is then compared to the empty lot's footprint. If a collision occurs, then the building is unplaceable.

As for traffic, pollution and other simulations, why stick to a grid. Let each lot affect the overall value based on its own footprint. After all, every lot can be made to know what area it takes up and then how it contributes to land value, traffic, pollution in its vicinity. Have the value feather out from the footprint.

Another way is to simply overlay a grid on top of the map and then have each value calculated within that grid. This way, while having free placement, we also have a much simpler calculation for the different statistical data we need. The grid does not even need to be too small. 1mx1m is pretty damned tiny, and most lots would contain 100's of these little tiles which, when combined have just the same effect. Therefore, we should most likely stick with a 10x10m tile for the calculation grid. Its a more round number, and for a 10x10km map, we do not have too many tiles.

Additionally, for some of the statistics we can take a different approach. Things such as land value are generally, in the real world, on a block-by-block basis. You do not see a highly desirable piece of land right next to a slum. On the other hand, it may be right accross the street ( Sunnyvale downtown in CA has something like this, for an example close to me. There are pretty run down, old houses and right across the steet a new high value commercial district is being built).
As such, we may be able to define a maximal area for a block, to make sure a player cannot cheat the system by creating huge blocks with one high-valued building and lots of low-valued ones. We then take this block, calculate its average value and apply the entire block as a tile. This should serve to minimize the number of tiles we need to calculate values for, although the tradeoff here is that we would require a pretty efficient blocking algorithm. One way to do it that I see is to take a block of buildings, one surrounded by roads on all sides and calculate its area. If its less than the maximum for a single block, we go ahead and use that block as is, otherwise its divided in half and again the comparison takes place.

Hopefully I make more sense than I did all of this morning.

Atomius

In my project Atocity i use grids for placement, but for cellular automata-esque effects such as desirability i use collision_circle, a useful function in GML which creates a 'footprint' area for a development, power plant etc. This is find way better than using CA style grid effects, and allows for precision control over the affected areas limitations. I imagine in C or Python or whatever there would be some method of replicating the collision functions in GML.

Freeform placement at any angle is certainly possible and a great idea, and grids are not really necessary for effects such as desirability. The map would illustrate the position of affects such as crime by scanning at regular intervals for an affect footprint e.g it would scan a grid of points over the map and where a point had a collision with say a crime affected region it would return true for that etc

Another advantage, though one that is difficult to understand how to go about implementing to me at any rate, of not having a grid for placement, is transport networks could be made to follow smooth curves rather than snapping to a grid and having purely graphical diagonals. For instance a building could snap diagonally to a diagonal road of any angle. However this would necessitate a plastic nature in the road for curves (like bendable model railroad track), something hard to imagine with graphics. Diagonal road could of course be created by placement at any angle but would form odd connections. Thus with regards to transport one can see freedoms but limitations and problems with not using a grid and i can't foresee a solution myself.

Terrain is another area. The LOD of terrain would have to be better than in Simcity 4 one would imagine, but this is not so difficult to understand. Whereas transportation, requiring smooth transition between pieces... Seems harder to put into a freeform building environment without grids.

An example is a curved road. How would one go about making a curved road?

LucaPdor

Well... have you ever thought about GPS maps' databases data structure?

I think that if the transportation network is divided in small parts, every effec is achievable...
Let's do an example:
just have a standard road tile.
You could in theory split it in, let's say, 5 parts. You can have the sides, two lanes, and the center piece.

Assuming this, an avenue would be just a greater road, composed of 9 pieces:
from left to right: side, lane, center piece, lane, median, lane, center piece, lane, side.

Each piece would be rendered separately.

This structure could be finally applied to a GPS-like map, in witch you have vectors that indicate the segments of road start and end 3d points, and various tags, listing the pieces of whitch the network is composed.

This could lead to endless opportunities!  :thumbsup:
I'm going to study a bit on this and post something more detailed sooner or later...

Luca
semel in anno licet insanire

Atomius

well if theres some way of making a curved road, or a road at any angle meet with another at any angle then i'd be happy

croxis

I was thinking of a gps/openmaps implementation would be the best.  I haven't done any serious searching but if you know of any good code or documentation I would love to check it out.

Nique

Quote from: Atomius on October 01, 2009, 02:39:04 PM
well if theres some way of making a curved road, or a road at any angle meet with another at any angle then i'd be happy

Please download the TROPICO3 demo (free, just google for it) and see a very basic way of curved roads. I think we should take that kind of mechanism for our game too.
It's very very basic inside Tropico, but we could extend it with more features
Proudly developer of

tomkeus

Quote from: Nique on October 01, 2009, 06:39:20 PM
Please download the TROPICO3 demo (free, just google for it) and see a very basic way of curved roads. I think we should take that kind of mechanism for our game too.
It's very very basic inside Tropico, but we could extend it with more features

Played Tropico, loved it but I don't think that kind of road laying is very good idea.

Did you hear about our ideas of construction layer?

If we implement construction layer, laying down roads would be more similar to using CAD software.

I had in mind something similar to RailSimulator

http://www.youtube.com/watch?v=j7Ouywecq24

So, no splines. We have straight segments, circular arcs for curves and clothoids (Euler spirals) for transition curves, just like in real road engineering.
#define TRUE FALSE /*Happy debugging suckers*/

JoeST

Copperminds and Cuddleswarms

Atomius

my dial up connection/slow pc wouldn't allow me to download tropico i'm afraid, but if there is a method for curved roads then i'm for the idea 100 percent. It's something i've wanted since i first played simcity 2000 in 2003

Djohaal

Quote from: Nique on October 01, 2009, 06:39:20 PM
Please download the TROPICO3 demo (free, just google for it) and see a very basic way of curved roads. I think we should take that kind of mechanism for our game too.
It's very very basic inside Tropico, but we could extend it with more features

Have you played black and white 2? It's curved roads system is by far the best I've seen. When you drag it draws a spline and every so often it "snaps" on the terrain, allowing for drawing on any shape. To undo it you would just backtrack on the spline you drawed and it'd erase. It is very similar to cities XL's, but with more resolution. Doing interesections on that kind of thing would be hell though. Perhaps an implementation of it for rural/dirt roads? ;)