NML Help

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
TrainLover
Engineer
Engineer
Posts: 107
Joined: 01 Jul 2015 15:03

NML Help

Post by TrainLover »

I'm trying to learn NML, but I do not exactly understand what to do with the spriteset, what are the coordinates that are to be wrote inside the spriteset box?
[ 0, 0, 8, 18, -3, -10]
[ 16, 0, 20, 16, -14, -7]
[ 48, 0, 28, 12, -14, -6]
[ 96, 0, 20, 16, -6, -7]
[ 128, 0, 8, 18, -3, -10]
[ 144, 0, 20, 16, -14, -7]
[ 176, 0, 28, 12, -14, -6]
[ 224, 0, 20, 16, -6, -7]
Where does one get these values?
Developer of North American Passenger Liveries: viewtopic.php?f=26&t=87228
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML Help

Post by Alberth »

By pure magic, educated guesses, or counting pixels, see also https://www.tt-wiki.net/wiki/NMLTutoria ... pritegroup

The first 4 numbers are x/y and width/height pixel coordinates in your image files, to make NML know which area of the image displays the vehicle you want to display. The latter two numbers are offsets in displaying the image, so you can put the train exactly at the track, or the RV at the right side of the road.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NML Help

Post by NekoMaster »

The first two numbers for each line is the Top left corner of the blue area you put your sprites in from what I found. This is based on the location in the entire image/sprite sheet.

So if your Top-left pixel is say, 32 and 96, that would be where the pixel at 32x and 96y in your image editor. Thankfully GIMP shows the coordinates where your mouse is.

The offsets seem to be about the half way point/middle of your sprite.

It might help if you standardize your sprite sheet like they did with the 2cc Train set except for special cases like very long vehicles where you may need a larger sprite sheet.

Heres an example I tried to clean up a little to help

Code: Select all

// [left_x,    uppr_y,   width, height,  offset_x,  offset_y]
   [     1,         1,       8,     36,        -3,       -15] // North Facing ^
   [    10,         1,      29,     25,       -22,       -14] // North East /
   [    33,         1,      48,     16,       -33,       -12] // East Facing ->
   [    66,         1,      29,     25,       -14,       -18] // South East \
   [    86,         1,       8,     36,        -3,       -20] // South Facing v
   [    98,         1,      29,     25,       -14,       -18] // South West /
   [   121,         1,      48,     16,       -16,       -12] // West <-
   [   154,         1,      29,     25,        -4,       -13] // North West \
Also the width and height is the size of the blue area you put the sprites in. You'll know what I mean when you look at a sprite sheet.

You can see what I mean if you load up my sprite sheet for an EMD Model 40 in an image editor

EDIT : I accidentally provided a template for a long 12/8 vehicle, but you'll see either way what I mean.
Attachments
The first top most pixel is 0x 0y in gimp
The first top most pixel is 0x 0y in gimp
DIESEL_EMD_MODEL_40.png (2.15 KiB) Viewed 2336 times
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
User avatar
TrainLover
Engineer
Engineer
Posts: 107
Joined: 01 Jul 2015 15:03

Re: NML Help

Post by TrainLover »

So, are most spritesets compatible with the 2cc set for code?
Developer of North American Passenger Liveries: viewtopic.php?f=26&t=87228
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NML Help

Post by NekoMaster »

TrainLover wrote:So, are most spritesets compatible with the 2cc set for code?
Not really, but you can get the source code for the 2cc Train Set and use the sprite sheets from and the template code to get started with.

EDIT : YOu can get downloads for nightlies and source code from here, any version with Source code available should be good enough to start with

http://bundles.openttdcoop.org/2ccts/?C=M&O=D

Also, in case you didn't know, winrar or 7zip should be able to handle tar/tar.xz files.
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML Help

Post by Transportman »

TrainLover wrote:So, are most spritesets compatible with the 2cc set for code?
No, each set can use a different system for templating sprites. The 2cc set uses one template for all vehicles with length 1-8, while the Dutch Trainset has separate templates for each length. But if you grab the code and templates from a single set and stick to them, you should not have to worry about it.

If you develop your own template, it is a one time setup, although it does cost quite some time. I do advise to at least try it once, just to get a feeling for what is happening.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: NML Help

Post by TadeuszD »

A few years ago I published my train template:
viewtopic.php?f=68&t=66813

This template is optimized against graphics glitches (i.e with tunnel portals, brigdes and stations).
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest