View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1neo72  Members

Posted 18 March 2013 - 05:40 AM

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:

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://storeimages.impulsedriven.com/product_gfx/04xx.jpg

I hope someone would like to enlighten me.

### #2Poigahn  Members

Posted 18 March 2013 - 06:24 AM

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 !!

### #3Aardvajk  Members

Posted 18 March 2013 - 08:10 AM

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.

### #4BCullis  Members

Posted 18 March 2013 - 09:26 AM

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)

### #5neo72  Members

Posted 18 March 2013 - 03:25 PM

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 !)

### #6FLeBlanc  Members

Posted 18 March 2013 - 03:43 PM

Oh, God.

### #7BCullis  Members

Posted 18 March 2013 - 04:58 PM

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)

### #8neo72  Members

Posted 20 March 2013 - 06:53 PM

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

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 !

Posted 20 March 2013 - 07:08 PM

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 ;)

Edited by Paradigm Shifter, 20 March 2013 - 07:15 PM.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.