Coding trucks with trailers

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
Cudar
Engineer
Engineer
Posts: 101
Joined: 05 May 2008 16:06
Location: Debrecen, Hungary
Contact:

Coding trucks with trailers

Post by Cudar »

Hello to everybody!

I know, you are very good in coding. I have a guide for GRFMaker that describes how to encode articulated buses, and trucks with trailers. That's very good, but I don't know how to make a truck like this:
Image
Firstly I thought it's easy to make, but than I started thinking about that how appears the trailer behind the cab of the truck in the game, and the trailer how covers the other part of the truck. When the truck is turning, how will it look?
image.PNG
image.PNG (4.59 KiB) Viewed 3259 times
I don't understand how to draw it, and how to code... Do you help me? For the Romanian Road Vehicles set, that now has five buses and a truck done, but I can't code and draw this truck...
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Re: Coding trucks with trailers

Post by Uwe »

This is indeed not easily solvable. We have the same problem with the German road vehicles, and without drawing tricks the result will look like your third picture. The truck will be drawn over the semitrailer, which looks quite bad. As a workaround I did the back part of the truck (the area which is covered by the semitrailer in the second picture) in transparent blue . This still does not look exceptionally well on slopes or during turning, but most of the time the trucks are going straight on, so to me this would be acceptable. If anyone has a better solution, I'd be interested to hear about it.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Coding trucks with trailers

Post by andythenorth »

Cudar wrote:Firstly I thought it's easy to make, but than I started thinking about that how appears the trailer behind the cab of the truck in the game, and the trailer how covers the other part of the truck. When the truck is turning, how will it look?
It's a very difficult problem with no ideal solution. I haven't solved it to my satisfaction in the HEQS RV set, so I have only been drawing trucks that don't need to do this.

George has been trying some very complex but impressive things with the new version of Long Vehicles.

Zephyris solved it in eGRVTS by using the solution above - don't draw the back of the tractor unit (see attached). It looks fine.
egrvts_articulated.png
egrvts_articulated.png (15.81 KiB) Viewed 3195 times
So there's no simple solution for new grf authors, and the game engine fundamentally needs to draw things this way - I can't see that changing. :(

However the solution of not drawing the back works well in most situations.

cheers,

Andy
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: Coding trucks with trailers

Post by AndersI »

Cudar wrote:I have a guide for GRFMaker that describes how to encode articulated buses, and trucks with trailers.
Where did you get that? Or did you write it yourself? Can you make it public, if so? I tried a forum search on "articulated grfmaker" but didn't find anything relevant.

I'm trying to collect all available info about GRFMaker here, so you're welcome to share any small example projects you can spare :-)
but I don't know how to make a truck like this...
If there is a way to know which way the truck and trailer bends, it should be possible by drawing the back part of the undercarriage in the trailer sprite, but there would be a lot of sprites, and a lot of code. But I can't think of any other way right now :-(
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Coding trucks with trailers

Post by DJ Nekkid »

A possible solution might be to have the 1st part be, lets say 6/8ths long, but it's coded to be 4/8ths long, and this way the graphics might overlap in a satisfactionary way?
Member of the
ImageImage
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: Coding trucks with trailers

Post by XeryusTC »

Isn't it possible to let the boundingbox of the truck only encapsule the cabin and not the part that the trailer rests on, that way you will always get proper drawings I think. It might not work at all though, it kind of depends on how much the sprite sorter likes it.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Coding trucks with trailers

Post by andythenorth »

AndersI wrote:If there is a way to know which way the truck and trailer bends, it should be possible by drawing the back part of the undercarriage in the trailer sprite, but there would be a lot of sprites, and a lot of code.
I believe there is a callback to measure the angle of rotation between adjoining parts of an articulated vehicle. I think George is using it in LV 5. Using this will be complex and add a lot of work.

DJ's idea might work. Worth a try.

The solution of not drawing the chassis for the tractor unit is proven to work.

cheers,

Andy
User avatar
Cudar
Engineer
Engineer
Posts: 101
Joined: 05 May 2008 16:06
Location: Debrecen, Hungary
Contact:

Re: Coding trucks with trailers

Post by Cudar »

AndersI wrote:Where did you get that? Or did you write it yourself? Can you make it public, if so? I tried a forum search on "articulated grfmaker" but didn't find anything relevant.

I'm trying to collect all available info about GRFMaker here, so you're welcome to share any small example projects you can spare :-)
No, I didn't made the tutorial, it's made by gl2, one of the GRFMaker's creators. The problem is that it is in Hungarian, and it needs to be translated to English. If I have time, I will try to translate it...
andythenorth wrote:It's a very difficult problem with no ideal solution. I haven't solved it to my satisfaction in the HEQS RV set, so I have only been drawing trucks that don't need to do this.

George has been trying some very complex but impressive things with the new version of Long Vehicles.

Zephyris solved it in eGRVTS by using the solution above - don't draw the back of the tractor unit (see attached). It looks fine.
Csatolmány:
egrvts_articulated.png
egrvts_articulated.png [ 15.81 | Megtekintve 190 alkalommal. ]


So there's no simple solution for new grf authors, and the game engine fundamentally needs to draw things this way - I can't see that changing. :(

However the solution of not drawing the back works well in most situations.

cheers,

Andy
Yes, Andy, I thought this too to be a solution, and if I will not have any idea, I think I will make it so. But I was thinking again (I'm thinking too much :) ), and now I have an idea...
I have two examples in GRFMaker. An example with articulated buses, and an other with a loco, which is articulated too. So I thought, that if we could do that the truck to be articulated, but not to turn like it needs it would be good. Because I would make the truck in three parts, so:
the three parts
the three parts
parts.PNG (2.11 KiB) Viewed 3027 times
The first part would be the cab, the covers both the semi-trailer and the trailer, the second is the trailer, that covers the semi-trailer, and the last is the semi-trailer, that don't covers anything. The semi-trailer stays on his place, while the trailer is moving normally. This is a good plan? Can the GRFMaker do that?
And here is the two example in GRFMaker:
steam.zip
Articulated bus and loco
(3.99 KiB) Downloaded 204 times
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Coding trucks with trailers

Post by andythenorth »

Cudar wrote: The first part would be the cab, the covers both the semi-trailer and the trailer, the second is the trailer, that covers the semi-trailer, and the last is the semi-trailer, that don't covers anything. The semi-trailer stays on his place, while the trailer is moving normally. This is a good plan?
I think it's similar to what George has done in LV5, but I can't remember. My advice: download LV5 test from the thread in the OpenTTD graphics forum, and see if George has any advice, he's quite friendly :)
Can the GRFMaker do that?
No idea, I can't use GRFMaker on the Mac. I had to learn to code raw nfo, which was a headache, but now I understand a lot better and have a lot of control over what I want to do :)
User avatar
Cudar
Engineer
Engineer
Posts: 101
Joined: 05 May 2008 16:06
Location: Debrecen, Hungary
Contact:

Re: Coding trucks with trailers

Post by Cudar »

I think now that I'll draw the truck, without the semi-trailer, how andythenorth said.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 5 guests