Difference between revisions of "NFO Foundations"

From TTWiki
Jump to navigationJump to search
m (11 revisions)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  +
{{NFOTutorial}}
   
 
The fundamental files that control your new graphics are the .nfo and the .pcx file. The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.
'''''How to get started on .nfo editing'''''
 
 
=NFO Files=
 
 
The fundamental files that control your new graphics are the .nfo and the .pcx file.  The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.
 
   
 
==To get started==
 
==To get started==
   
To draw a new train, you first need a base from which to start working.  Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics.  Basically, you follow these steps:
+
To draw a new train, you first need a base from which to start working. Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics. Basically, you follow these steps:
 
# Extract TTD's trg1r.grf (or trg1.grf for the DOS version or ogfx1_base.grf when using OpenGFX)
 
# Extract TTD's trg1r.grf (or trg1.grf for the DOS version or ogfx1_base.grf when using OpenGFX)
 
# Look through trg1r.pcx (TTD) or ogfx1_base.grf (OpenGFX) for a vehicle similar to the one you're going to make
 
# Look through trg1r.pcx (TTD) or ogfx1_base.grf (OpenGFX) for a vehicle similar to the one you're going to make
Line 18: Line 15:
 
==1. Extract TTD's trg1r.grf / OpenGFX's ogfx1_base.grf==
 
==1. Extract TTD's trg1r.grf / OpenGFX's ogfx1_base.grf==
   
First of all, you need to download [http://www.openttd.org/download-grfcodec|grfcodec] and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:
+
First of all, you need to download [http://www.openttd.org/download-grfcodec grfcodec] and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:
   
  +
<pre>cd C:\TTD
<pre>-+cd C:\TTD &nbsp; &nbsp; &nbsp; +-<span style='color:grey'>(change to your TTD folder)</span>
 
  +
grfcodec -d trg1r.grf</pre>
   
-+grfcodec -d trg1r.grf &nbsp; &nbsp; &nbsp; +-<span style='color:grey'>(decode trg1r.grf; use trg1.grf for the DOS version of TTD)</span></pre>
+
Obviously, change <tt>C:\TTD</tt> to point to your TTD directory. If you're using the DOS version of TTD, use <tt>trg1.grf</tt> instead of <tt>trg1r.grf</tt>.
   
 
This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.
 
This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.
   
You can also use [http://www.divxland.org/ttd/grfwizard.htm|GRFWizard] with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.
+
You can also use [http://www.divxland.org/ttd/grfwizard.htm GRFWizard] with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.
   
 
==2. Look through trg1r.pcx / ogfx1_base.pcx==
 
==2. Look through trg1r.pcx / ogfx1_base.pcx==
   
You now open trg1r.pcx from the sprites folder. &nbsp;There are many graphics programs to view and edit .pcx files.
+
You now open trg1r.pcx from the sprites folder. There are many graphics programs to view and edit .pcx files.
   
Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. &nbsp;So you go looking for its graphics in trg1r.pcx. &nbsp;For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). &nbsp;Write down those numbers. &nbsp;For example, this is what it might look like:
+
Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. So you go looking for its graphics in trg1r.pcx. For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). Write down those numbers. For example, this is what it might look like:
   
{picture file=img/wiki_up//sh125.png}
+
[[File:sh125.png]]
   
 
==3. Copy the corresponding data from the .nfo file into your own file==
 
==3. Copy the corresponding data from the .nfo file into your own file==
   
So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example &quot;mytrain.nfo&quot;.
+
So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example "mytrain.nfo".
   
Now, copy and paste the first three lines beginning with &quot;//&quot; to your mytrain.nfo file. &nbsp;While they may look like comments, they are actually important.
+
Now, copy and paste the first three lines beginning with "//" to your mytrain.nfo file. While they may look like comments, they are actually important.
   
In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. &nbsp;In the example above, we'd find the lines with numbers 2941 to 2948. &nbsp;Copy those eight (or however many) lines to your mytrain.nfo file as well.
+
In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. In the example above, we'd find the lines with numbers 2941 to 2948. Copy those eight (or however many) lines to your mytrain.nfo file as well.
   
 
==4. Encode and decode again your own file==
 
==4. Encode and decode again your own file==
   
Now we want to make our own .grf file. &nbsp;Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7.
+
Now we want to make our own .grf file. Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7 (nforenum can do that for you).
   
 
At this point, your .nfo file should look something like this:
 
At this point, your .nfo file should look something like this:
   
 
<pre>// Automatically generated by GRFCODEC. Do not modify!
 
<pre>// Automatically generated by GRFCODEC. Do not modify!
 
 
// (Info version 6)
 
// (Info version 6)
 
 
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
 
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
 
0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
 
&nbsp; &nbsp;0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
+
1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
 
2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
 
&nbsp; &nbsp;1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
+
3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
 
4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
 
&nbsp; &nbsp;2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
+
5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
 
6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
 
&nbsp; &nbsp;3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
+
7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7</pre>
 
&nbsp; &nbsp;4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
 
 
&nbsp; &nbsp;5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
 
 
&nbsp; &nbsp;6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
 
 
&nbsp; &nbsp;7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7</pre>
 
   
 
Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:
 
Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:
   
<pre>-+grfcodec -e mytrain.grf +-<span style='color:grey'>(encode your mytrain.grf file)</span>
+
<pre>grfcodec -e mytrain.grf
  +
grfcodec -d mytrain.grf -p 2</pre>
 
-+grfcodec -d mytrain.grf -p 2 +-<span style='color:grey'>(decode your mytrain.grf file again)</span></pre>
 
   
Leave off the &quot;-p 2&quot; if you're working with the DOS graphics instead of the Windows graphics.
+
Leave off the "-p 2" if you're working with the DOS graphics instead of the Windows graphics.
   
 
==Good job!==
 
==Good job!==
Line 89: Line 76:
   
 
Once you're ready, go on to the [[TheFirstVehicle|next section]].
 
Once you're ready, go on to the [[TheFirstVehicle|next section]].
  +
[[Category:Tutorials]][[Category:GRF Tutorial]]

Latest revision as of 11:17, 29 January 2019

The fundamental files that control your new graphics are the .nfo and the .pcx file. The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.

To get started

To draw a new train, you first need a base from which to start working. Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics. Basically, you follow these steps:

  1. Extract TTD's trg1r.grf (or trg1.grf for the DOS version or ogfx1_base.grf when using OpenGFX)
  2. Look through trg1r.pcx (TTD) or ogfx1_base.grf (OpenGFX) for a vehicle similar to the one you're going to make
  3. Copy the corresponding data from the .nfo file into your own file
  4. Encode and decode again your own file

Now to look at these steps in a bit more details. If you de-compiled OpenGFX's file, use the appropriate filenames instead in the subsequent text.

1. Extract TTD's trg1r.grf / OpenGFX's ogfx1_base.grf

First of all, you need to download grfcodec and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:

cd C:\TTD
grfcodec -d trg1r.grf

Obviously, change C:\TTD to point to your TTD directory. If you're using the DOS version of TTD, use trg1.grf instead of trg1r.grf.

This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.

You can also use GRFWizard with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.

2. Look through trg1r.pcx / ogfx1_base.pcx

You now open trg1r.pcx from the sprites folder. There are many graphics programs to view and edit .pcx files.

Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. So you go looking for its graphics in trg1r.pcx. For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). Write down those numbers. For example, this is what it might look like:

Sh125.png

3. Copy the corresponding data from the .nfo file into your own file

So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example "mytrain.nfo".

Now, copy and paste the first three lines beginning with "//" to your mytrain.nfo file. While they may look like comments, they are actually important.

In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. In the example above, we'd find the lines with numbers 2941 to 2948. Copy those eight (or however many) lines to your mytrain.nfo file as well.

4. Encode and decode again your own file

Now we want to make our own .grf file. Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7 (nforenum can do that for you).

At this point, your .nfo file should look something like this:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
 0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
 1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
 2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
 3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
 4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
 5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
 6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
 7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7

Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:

grfcodec -e mytrain.grf
grfcodec -d mytrain.grf -p 2

Leave off the "-p 2" if you're working with the DOS graphics instead of the Windows graphics.

Good job!

Now you have your own mytrain.grf file with the corresponding mytrain.nfo and mytrain.pcx files. We'll use this as a base for making these graphics TTDPatch compatible.

Note that you can't yet take your mytrain.grf file and put it in TTDPatch's newgrfw.cfg file yet, because it doesn't have the necessary information to allow TTDPatch to know what to do with it.

However, you can go ahead and edit the graphics in mytrain.pcx to your liking and make them look like your train.

Once you're ready, go on to the next section.