Same bridge-model different lenghts - how did they do that

Started by
7 comments, last by Paradigm Shifter 11 years ago

Hi

I have played a game (Sid Meier's Railroads) and a few days ago I installed it again to relieve some fun memories.

While I was playing I noticed that when my railroad crossed rivers or a ravines then the game would create a bridge and it is this part which have me puzzle:

The bridges were never too short no matter how wide the gap were the bridges just got longer to neatly (I dare say) fit the gap.

If anyone wants to bother having a look then there is a tons of screenshots on google.

Now to my question:

How was this made ?

My own guess is (and I'm not a programmer, which is why I'm asking you !) that the developers made the bridges in three segments:

1. a start segment

2. a middle segment which is expandable

3. an end segment

Here is another thing I don't understand:

How the the program knows:

1. how many middle segments to add

2.how pick the most suitable type of bridge for a particular gap

http://www.gbase.de/uploads/ci/shots/Sid-Meiers-Railroads!_b_55738.jpg

http://storeimages.impulsedriven.com/product_gfx/04xx.jpg

http://tjstatic.com/multimedia/2011/07/sid-meiers-railroads-pantalla-1.jpg

I hope someone would like to enlighten me.

Advertisement

If The Bridge was layed in in segments as the span got longer or shorter, then you would Notice a repetative visual sequence.

Most likely what the programmers di was to "Scale" the model image to fit the scene. To help you visualize this Consider the following..

Model Bridge > <____> ScaleX1.25 <_____> , ScaleX1.50 <______>, SscaleX2.0 <________>

See it getting Longer ?

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!

Its segments. You can blatantly see in the second image you linked to. The two short ends arches are identical to the ends of the long arch in the middle. There's just three sections to this model, either end and the middle bit and the middle bit is probably quite a narrow section that repeats over and over to get the desired length.

Scaling a single model would not even remotely produce the effect this software demonstrates.

It's the multiple-mesh version of sprite slicing. Define endcaps or corners that don't scale, and then a center region that scales or repeats as necessary.

To get perfect fit, you could place the two endcaps, and then calculate the world-space distance the bridge needs to fill, and create repeating elements that have a small scaling range to let them fit any dynamically-sized gap.

Or you could skip the scaling part and just clip the ends of the bridge into the terrain a little bit. There are several solutions depending on how you've designed the "world" to work.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

Disclaimer: I don't know WTF I'm talking about !

Hi

First of all: Thank you all for taking your time to reply

@Poigahn

It is hard to give a comment on your reply as I'm not sure which of the images you're refering to, but my best guestimate is that you're refering to the yellow brick-like structure.

@Aardvajk

You also seem to have set your sight on the yellow brick-like structure.

@BCullis

Thank you for the link - I'll admit I get a little dissapointed when I discovered it was about Flash, so I did a search, but in vain as I couldn't find any site which could privide me with an explanation I was able to comprehend (I don't blame you, but instead my mom and dad !)

Anyway, since you all seem to somewhat agree on how the yellow brick-like structure was made (and I have to agree too), I would then like to point your attention the the truss bridge found in two of the images.

This is not made with the same technique as you have described in the above.

My guess is that this bridge is made from a set of predefined rules:

(psudo code)

While laying tracks

If encounter a depression (ravine or river)

Then start with a steel truss bridge with three bridge segments (ie. a start, middle, and end segment) to close the gap - did it work ?

if yes then continue to lay track

else

Then start with a steel truss bridge with three bridge segments (ie. a start, 2 x middle, and end segment) to close the gap - did it work ?

if yes then continue to lay track

else

Then start with a steel truss bridge with three bridge segments (ie. a start, 3 x middle, and end segment) to close the gap - did it work ?

if yes then continue to lay track

else

Then start with a steel truss bridge with three bridge segments (ie. a start, 4 x middle, and end segment) to close the gap - did it work ?

if yes then continue to lay track

else

Then start with a steel truss bridge with three bridge segments (ie. a start, 5 x middle, and end segment) to close the gap - did it work ?

if yes then continue to lay track

else

add an "elastic" bridge segment and when there is enough left add another steel truss

(psudo code END)

There are most likely a few more parameters, but the one I just described in my psudo code is the most obvious, based on what I can see in the images.

Does anyone of you have anything to add (I could be the case that I have gotten it all wrong, which certainly wouldn't be the first time !)

(I don't blame you, but instead my mom and dad !)

Oh, God.

I'll admit I get a little dissapointed when I discovered it was about Flash, so I did a search, but in vain as I couldn't find any site which could privide me with an explanation I was able to comprehend

The flash tutorial was just a handy example of what I went on to describe in the rest of my post. Fixed-size "cornerpost" elements of a visual object, filled in with scaling-friendly (or in the case of meshes, repeating-friendly) filler elements, so that you can fit any arbitrary dimension requirement.

Which is what your pseudocode does, kind of, only it wouldn't be quite so ...voluminous. Just write an algorithm that looks at the distance you need to cover, determine how many repeating elements it will take to fill that gap, and place them.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

Which is what your pseudocode does, kind of, only it wouldn't be quite so ...voluminous. Just write an algorithm that looks at the distance you need to cover, determine how many repeating elements it will take to fill that gap, and place them.

Disclaimer: I don't know WTF I'm talking about !

Hi

Thank you for your reply.

As I read and understand your algorithm it would continue to add middle segments until it had nearly closed the gap and just slap on an "end" segment - if this is true then some of the bridges would look rather strange and really long - some of them might even end up defying every book that been written about load-bearing capacity in bridge spans due to their huge distance between their pylons !

In the first pic you posted they split up a long span into more than one bridge section, with a small bridge followed by a gap followed by a larger one. There is a column at the end section of each bridge. You can do that to add more columns to a bridge. There's no reason columns can't go down into the river you are crossing.

Note that the bridges aren't always straight either, it looks like they are following a spline which complicates things a bit more (you have to place the bridge section on a trapezium like shape rather than a rectangle).

EDIT: You probably don't want to have new columns destroying existing buildings, but since it is a Sid Meier game, I will recall my anecdote about how I built some buildings in one of my cities in Civ IV which already contained the pyramids, and the pyramids moved afterwards, over a river no less ;)

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement