Page 1 of 1

Coding trucks with trailers

Posted: 06 May 2009 15:04
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 3264 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...

Re: Coding trucks with trailers

Posted: 06 May 2009 16:41
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.

Re: Coding trucks with trailers

Posted: 06 May 2009 18:54
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 3200 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

Re: Coding trucks with trailers

Posted: 06 May 2009 19:01
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 :-(

Re: Coding trucks with trailers

Posted: 06 May 2009 19:16
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?

Re: Coding trucks with trailers

Posted: 06 May 2009 19:51
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.

Re: Coding trucks with trailers

Posted: 06 May 2009 19:52
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

Re: Coding trucks with trailers

Posted: 07 May 2009 13:40
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 3032 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

Re: Coding trucks with trailers

Posted: 07 May 2009 18:43
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 :)

Re: Coding trucks with trailers

Posted: 09 May 2009 07:49
by Cudar
I think now that I'll draw the truck, without the semi-trailer, how andythenorth said.