Coding bridges
Moderator: Graphics Moderators
Coding bridges
I just learnt how to code bridges, and I must say it's a royal pain in the behind, because I'm unable to find sufficient information on how the bridge layouts work. "various middle parts", as stated in the wiki isn't actually very informative
Is there information available on how the different bridge pieces are ordered behind one another? This would really help me re-encoding most of the default bridges, because I'm only replacing the maglev ones. The default bridge tables might also be useful (if in human readable (NFO) format).
Thanks,
FooBar
Is there information available on how the different bridge pieces are ordered behind one another? This would really help me re-encoding most of the default bridges, because I'm only replacing the maglev ones. The default bridge tables might also be useful (if in human readable (NFO) format).
Thanks,
FooBar
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Coding bridges
Check this one (or some of the follow-ups): http://lists.ttdpatch.net/ttdpatch/200310/msg00227.html
HTH
regards
Michael
HTH
regards
Michael
Re: Coding bridges
Thanks, Michael.
At least this bit of information should prove of any use:
Actually, the scheme as posted above doesn't make sense on the suspension bridge. In the image below, the last option from the scheme above should apply. The numbers on the bridge refer to the numbers in the scheme. Problem is: equal numbers do not imply equal bridge parts. I guess I have to make some dummy sprites, code it all up and see what happens.
At least this bit of information should prove of any use:
EDIT:Marcin Grzegorczyk wrote:As far as I can figure out from the code, the bridge layout *internally*
always is like shown below, where numbers are internal 'part' numbers
(L2 bits 3..0) and '-' is an ending:
-- if the length of the mid-part is equal to 0
-0- if the length of the mid-part is equal to 1
-0(23)1- if the length is an even number
-0(23)4(32)1- if the length of the mid-part modulo 4 is 3
-0(23)252(32)1- if the length of the mid-part modulo 4 is 1
(parenthesized parts repeated as many times as needed)
For uniform-looking bridges all parts (or all parts except 0 and 1)
simply look the same.
Actually, the scheme as posted above doesn't make sense on the suspension bridge. In the image below, the last option from the scheme above should apply. The numbers on the bridge refer to the numbers in the scheme. Problem is: equal numbers do not imply equal bridge parts. I guess I have to make some dummy sprites, code it all up and see what happens.
- Attachments
-
- Naamloos-6.png (14.81 KiB) Viewed 5290 times
Re: Coding bridges
The correct bridge part order, has gor some errors, the correct one in my understanding is:FooBar wrote:Thanks, Michael.
At least this bit of information should prove of any use:EDIT:Marcin Grzegorczyk wrote:As far as I can figure out from the code, the bridge layout *internally*
always is like shown below, where numbers are internal 'part' numbers
(L2 bits 3..0) and '-' is an ending:
-- if the length of the mid-part is equal to 0
-0- if the length of the mid-part is equal to 1
-0(23)1- if the length is an even number
-0(23)4(32)1- if the length of the mid-part modulo 4 is 3
-0(23)252(32)1- if the length of the mid-part modulo 4 is 1
(parenthesized parts repeated as many times as needed)
For uniform-looking bridges all parts (or all parts except 0 and 1)
simply look the same.
Actually, the scheme as posted above doesn't make sense on the suspension bridge. In the image below, the last option from the scheme above should apply. The numbers on the bridge refer to the numbers in the scheme. Problem is: equal numbers do not imply equal bridge parts. I guess I have to make some dummy sprites, code it all up and see what happens.
-- if the length of the mid-part is equal to 0
-0- if the length of the mid-part is equal to 1
-0(23)1- if the length is an even number
-0(23)4(23)1- if the length of the mid-part modulo 4 is 3
-0(23)253(23)1- if the length of the mid-part modulo 4 is 1
Maybe Marcin Grzegorczyk made a typo...
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Coding bridges
AFAIR, it was noticed and corrected already in the follow-ups of Marcin´s original message (from 2003, BTW ) .thgergo wrote:Maybe Marcin Grzegorczyk made a typo...
regards
Michael
Re: Coding bridges
I thought I'd read those, but appearantly missed the one with the real information. Reversing the (32) in (23) would indeed make more sense.michael blunck wrote:AFAIR, it was noticed and corrected already in the follow-ups of Marcin´s original message (from 2003, BTW )
EDIT:
I think I've got it figured out now. Thanks for the help guys! I've got my first transrapid bridge coded now, and the re-enstatement code for the wooden bridge finished. 12 more to go
When finisihed, I'll share all code which just rebuilds the default bridges at the wiki. It's just not an actual fun job to write down sprite numbers, convert to hex and put 'em in a different order in the bridge tables.
Re: Coding bridges
I updated the wiki page and added information on the layouts and a piece of example code on how the suspension bridge is coded.
Re: Coding bridges
That wiki page looks nice by now:) Great work And readable, understandable, than the previsious version.FooBar wrote:I updated the wiki page and added information on the layouts and a piece of example code on how the suspension bridge is coded.
Re: Coding bridges
Thanks, thgergo!
I think I'll also add a list of bridge IDs. The ID order isn't difficult, but a list is always easier than figuring stuff out yourself, especially if one only wants to replace just one bridge. Or the stats of just one bridge for that matter.
As soon as I've figured out the recolour stuff, I'll probably add some more on that too. I already found some information in 'your' bridge renewal topic which might be useful.
I think I'll also add a list of bridge IDs. The ID order isn't difficult, but a list is always easier than figuring stuff out yourself, especially if one only wants to replace just one bridge. Or the stats of just one bridge for that matter.
As soon as I've figured out the recolour stuff, I'll probably add some more on that too. I already found some information in 'your' bridge renewal topic which might be useful.
Re: Coding bridges
FINALLY!
I just finished recoding all default bridges. I was quite the ordeal putting everything together, but I'm willing to share the NFO code with whoever likes to use it. The file attached below contains every bridge, every tracktype and every recolouring as necessary.
The NFO code is licensed under the Creative Commons Attribution-Noncommercial 3.0 Netherlands license
http://creativecommons.org/licenses/by- ... nl/deed.en
EDIT:
Since 2010/07/29, the code attached below is also available under GNU GPL v2 licence
http://www.gnu.org/licenses/gpl-2.0.html
EDIT2:
As of 2011/06/15 you may also use this code in your GNU GPL v3 projects.
I just finished recoding all default bridges. I was quite the ordeal putting everything together, but I'm willing to share the NFO code with whoever likes to use it. The file attached below contains every bridge, every tracktype and every recolouring as necessary.
The NFO code is licensed under the Creative Commons Attribution-Noncommercial 3.0 Netherlands license
http://creativecommons.org/licenses/by- ... nl/deed.en
EDIT:
Since 2010/07/29, the code attached below is also available under GNU GPL v2 licence
http://www.gnu.org/licenses/gpl-2.0.html
EDIT2:
As of 2011/06/15 you may also use this code in your GNU GPL v3 projects.
- Attachments
-
- default_bridges.txt
- Licensed under CC BY-NC NL or GNU GPL v2.0/v3.0
- (72.74 KiB) Downloaded 246 times
Last edited by FooBar on 15 Jun 2011 09:17, edited 2 times in total.
- minime
- Transport Coordinator
- Posts: 339
- Joined: 18 Jan 2004 10:02
- Skype: dan.masek
- Location: Prague, Czech Republic
- Contact:
Re: Coding bridges
This would have been much easier to read had you used escape sequences:
or even instead of
Code: Select all
\dx000009F2 \dx000009F6 \dx000009F8 \d0
Code: Select all
\dx9F2 \dx9F6 \dx9F8 \d0
Code: Select all
F2 09 00 00 F6 09 00 00 F8 09 00 00 00 00 00 00
Re: Coding bridges
well foobar, or someone ... if i (or purno/mark)provide you with the sprites, could you make/replace the monorail sprites/bridges for the 2cc set?
Re: Coding bridges
Somehow I managed to learn how to think in hex and little endian. For me F2 09 00 00 is as easy to read as \dx000009F2.minime wrote:This would have been much easier to read ...
But yes, I have to agree that adding 03208000 to 000009F2 is copy/paste wise a lot more easy than adding 00 80 20 03 to F2 09 00 00
And, in case of NFORenum, I probably should have used \d(2546 52461568 +), where 2546 is just the plain decimal sprite number, and 52461568 the value to add for colour translation.
Come to think of it, out of all options, I picked the most difficult one
It should be adviced that you'll break compatibility with the Transrapid Track Set if replacement monorail bridges if not all replacement bridges are included in one set. So I recommend creating one big track set containing the transrapid tracks, monorail tracks and metro tracks. In that case, one can do whatever you like with bridges and such.DJ Nekkid wrote:well foobar, or someone ... if i (or purno/mark)provide you with the sprites, could you make/replace the monorail sprites/bridges for the 2cc set?
Then your question: I'm currently short in time, but still willing to help you with the bridge code. If either one of you could supply the physical sprites and the real sprite NFO data (just the realsprites with sizes and offsets set correctly are fine, I'll ActionA/GRM them myself), I can do the bridge code relatively quickly, after which I pass the code back and either one of you can do the final alignment (which is as any alingment controlled through the realsprites, so not a difficult task, but it takes a lot of time).
I'm also willing to do everyting, but then you'll have to wait until I'm finished with the TTDPatch release of the Dutch tramset.
Re: Coding bridges
I once drew a concrete metro bridge, but it looks fugly. Sorry for the topic chance, but perhaps I can create a competition for a bridge which looks like ordinary elevated rail used in several big cities? No need to have different bridges for metro I think. Same applies to transrapid tracks. Question is, can we code a metro and transrapid bridge while leaving all ordinary rail bridges alone?
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Re: Coding bridges
Yes, as long as all custom bridges are contained in one GRF.Purno wrote:Question is, can we code a metro and transrapid bridge while leaving all ordinary rail bridges alone?
Re: Coding bridges
But can multiple bridge GRFs be combined? These days barely anybody uses the default TT bridges...
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Re: Coding bridges
Unfortunately no.Purno wrote:But can multiple bridge GRFs be combined?
One can replace bridges on a per bridge basis, but has to replace ALL different track types of that bridge simultaneously.
Let's say you want to replace the tubular maglev bridge only. In the NFO, you can replace that particular bridge easily, but have to recode the other three tracktypes. Without the recode, the tubular bridge does not have graphics any more for the other tracktypes.
Now let's load our new grf over, lets say, the total bridge replacement set. Now we end up with our new maglev bridge, the default tubular bridge for the other tracktypes and all other bridges from the total bridge set.
Imagine what would happen if you replace all maglev bridges and load those over the total bridge set[0]. The last bridge set must contain ALL bridges you would like to use in your games.
[0] You end up with you new maglev bridges, all other default bridges and no total bridge renewal set bridge at all.
Re: Coding bridges
Sounds complicated. But if I understand correctly we're stuck with two options:
- Or we make our own complete bridgeset
- Or we ask an exisiting bridge set to support our metro and transrapid tracks
Is'nt it?
- Or we make our own complete bridgeset
- Or we ask an exisiting bridge set to support our metro and transrapid tracks
Is'nt it?
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Re: Coding bridges
I try still hard to allowing set allocation for bridges like stations, but my current code doesn't work yet...
Re: Coding bridges
Do you advice to wait with trying to code a workaround GRF till you got a working feature, or do you expect it'll take long enough a (temporary) workaround is useful?
Contributor to the The 2cc Set and Dutch Trainset. Inventor of the Metro concept. Retired Graphics Artist.
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Download TT | Latest TTDPatch | OpenTTD | OpenTTDCoop | BaNaNaS: OpenTTD content system | 2048² OTTD scenario of the Netherlands
GRF Codec | GRF Crawler | GRF Maker | Usefull graphics & tools sites | NML Documentation Wiki | NFO Documentation Wiki
All my graphics are licensed under GPL. "Always remember you're unique, just like everyone else."
Who is online
Users browsing this forum: Google Adsense [Bot] and 77 guests