OPENTTD Sprite Editor / Generator

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

Moderator: Graphics Moderators

User avatar
mr_worf
Engineer
Engineer
Posts: 41
Joined: 02 Aug 2007 15:41
Location: South Wales, UK

OPENTTD Sprite Editor / Generator

Post by mr_worf »

Hi,

I've been working the last few days on an application that will allow us to make sprite generation for openttd a little easier.

The basic idea is to drag and drop finished blender renders onto the panels and use a mouse to move them to the correct x/y_offs position. Currently I have the ability to remove/add/delete tEXt chunks from the pngs and the ability to load vehicle tiles onto the sprite panels and move them about with the mouse. Other things that need to be done are trimming of pngs, tar generation etc etc.

I'm also planing for it to generate the all the nessesary sprites for each zoom level.
Attachments
spritegenerator.jpg
spritegenerator.jpg (65.04 KiB) Viewed 13321 times
Quotomatic
"There are 10 types of people in this world.. Those who know binary and those who don't." - Anon
"Bleep Bleep" - Leonard Nemoy
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

great! where did you write it in?

C# i guess? check out my posting in the .blend thread. the source code contains trimming functions
User avatar
Ben_Robbins_
Tycoon
Tycoon
Posts: 1234
Joined: 20 Nov 2005 01:56
Location: Abu Dhabi, UAE

Re: OPENTTD Sprite Editor / Generator

Post by Ben_Robbins_ »

Awesum, anything to get rid of the tedious alignment work will be really helpful.
Ben
User avatar
mr_worf
Engineer
Engineer
Posts: 41
Joined: 02 Aug 2007 15:41
Location: South Wales, UK

Re: OPENTTD Sprite Editor / Generator

Post by mr_worf »

Yes its all C#, trimming functions you say? ill have a look at that!
Quotomatic
"There are 10 types of people in this world.. Those who know binary and those who don't." - Anon
"Bleep Bleep" - Leonard Nemoy
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

also my python script can handle mutiple zoom levels, maybe we can adjust our tools to make a easy sprite conversion procedure?
User avatar
mr_worf
Engineer
Engineer
Posts: 41
Joined: 02 Aug 2007 15:41
Location: South Wales, UK

Re: OPENTTD Sprite Editor / Generator

Post by mr_worf »

Yep, i wasnt aware of the python script u made!( its such a massive thread) But anything that can be done to stream line the process is good news for us, I totally agree with you.
Quotomatic
"There are 10 types of people in this world.. Those who know binary and those who don't." - Anon
"Bleep Bleep" - Leonard Nemoy
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

great! have you thought about a solution to handle mask images?
User avatar
mr_worf
Engineer
Engineer
Posts: 41
Joined: 02 Aug 2007 15:41
Location: South Wales, UK

Re: OPENTTD Sprite Editor / Generator

Post by mr_worf »

Its possible to overlay lots images ontop of one another in the spritepanel control they can be moved individually, some logic would need to be added to save the offsets for the masks, ill need to investigate how masking coordinates differ from a normal sprites, would it be possible to attach them to a sprite so they share the x_offs?
Quotomatic
"There are 10 types of people in this world.. Those who know binary and those who don't." - Anon
"Bleep Bleep" - Leonard Nemoy
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

mr_worf wrote:Its possible to overlay lots images ontop of one another in the spritepanel control they can be moved individually, some logic would need to be added to save the offsets for the masks, ill need to investigate how masking coordinates differ from a normal sprites, would it be possible to attach them to a sprite so they share the x_offs?
as I understand it the masks do not need an offset. Their size is equal to the corresponding image. But their image format is somewhat special. png8, I believe. Something C# does not support out-of-the-box
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: OPENTTD Sprite Editor / Generator

Post by GeekToo »

Very nice work Mr_Worf,

Every tool that can help to make the 32bpp graphics creation process easier is very welcome !
User avatar
mr_worf
Engineer
Engineer
Posts: 41
Joined: 02 Aug 2007 15:41
Location: South Wales, UK

Re: OPENTTD Sprite Editor / Generator

Post by mr_worf »

I was also thinking about the app generating some sort of manifest which would group each sprite set and contain details on what sprite direction they represent etc . similar to a project file in VS or Jbuilder it could be loaded and saved and compiled into a tar or continue to be tweaked.

I better get cracking..
Quotomatic
"There are 10 types of people in this world.. Those who know binary and those who don't." - Anon
"Bleep Bleep" - Leonard Nemoy
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

I tried to get C# save to 8 bit png, but the results are disappointing to say the least. by default c# will not save anything other than 32 bpp. With other libraries I get diffrent results variing from gray images to errors :P

I'm down to writing png files myself or forcing ottd to accept gif files :P
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Re: OPENTTD Sprite Editor / Generator

Post by Sacro »

CS-SDL might have the required functions for PNG loading.
We Am De Best

Host of ThroughTheTube site
User avatar
Teemes
Engineer
Engineer
Posts: 68
Joined: 19 Mar 2008 21:01

Re: OPENTTD Sprite Editor / Generator

Post by Teemes »

Wow, that is looking very promising indeed! :shock: Even just the ability to align and pngcodec sprites by point-and-click would be really helpful. Any chance of you releasing a "feature-incomplete-pre-alpha" of some sort for us to play around with :wink: ?
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

Ok got the mask gif files working now, dirty hack but working :P

[EDIT] I updated the files to include support for rename.txt and correct company colors. The screenshots are not updated.

I'll explain the procedure in two posts using the attached file demo.blend.

When you open demo.blend you will notice 6 cubes, three on each side. Look at the python window and change
the line RootPath= "c:\\ottdrender\\" to a directory more appropriate. Hit Alt-p. The script will render 4 frames * 3 zoomlevels * 4 angles = 48 images. The filename will be something like <name of the blenderfile>_<frame nr>_<layer nr>_z<zoom level>.png

After a while the specified directory will contain a lot of image looking like screenshot-2.

Think that are enough images? No, we still need the mask images. Back to blender, edit the material for the middle cubes (the blue ones) to be shadeless. In the python script, change the lines

Code: Select all

mode ="normal";
#mode = "mask";
to

Code: Select all

#mode ="normal";
mode = "mask";
Hit alt-p again, and 48 more images should be rendered in the directory. See screenshot-3. That's it for this step.
Attachments
Screenshot-2.png
Image of the rendered images
(131.65 KiB) Downloaded 403 times
Screenshot-3.png
Image of the rendered images including mask images
(140 KiB) Downloaded 339 times
demo_blend.zip
Archive with the blend file
(198.46 KiB) Downloaded 332 times
Last edited by brupje on 24 Mar 2008 21:49, edited 2 times in total.
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

Next step, converting the images to something usefull in ottd. You will need .net installed for this to work!

Create in the output dir a file rename.txt. This file should contain 4 lines of text for each image.

Code: Select all

filename
GRF id
offset x
offset y
for example

Code: Select all

demo_1_6
1234
-10
-30
This file will enable the utility to rename the files correctly and assign the offsets by calling pngcodec.

Download blender_convert.rar and extract the files to a directory. Go to command prompt (start -> run -> cmd). cd to the specified irectory. Execute the following command:

Code: Select all

blender_convert <path to your rendered images>
for example blender_convert c:\ottdrenders\demo\

When the program is done, you will have even some more images! 48 to be excact, empty images will not be converted. See screenshot-5. All images are put in the output directory.

That's it. Copy the files to the correct location and you are done :)
Attachments
Screenshot-5.png
Screenshot of the end result
(231.13 KiB) Downloaded 339 times
blend_convert.rar
convert program, including source
(1.15 MiB) Downloaded 273 times
User avatar
Teemes
Engineer
Engineer
Posts: 68
Joined: 19 Mar 2008 21:01

Re: OPENTTD Sprite Editor / Generator

Post by Teemes »

@brupje:

as said in the other thread, a big THANKS for your Blender Python script. However, I've run into problems using your blender_convert tool. Screenshot of error attached. A quick internet search indicates that it may be a problem caused by a recent (Nov 07) Microsoft security update for .net, which changes the way certain unicode characters have to be adressed (then again, maybe not. I can hardly code... :wink: )
It also causes an exception, code: 0x0434f4d.

Can you look into this problem? I'm really intrigued by the description of the tool you gave, would make sprite generation much faster!
Attachments
error.png
error.png (23.3 KiB) Viewed 11666 times
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

Teemes wrote:@brupje:

as said in the other thread, a big THANKS for your Blender Python script. However, I've run into problems using your blender_convert tool. Screenshot of error attached. A quick internet search indicates that it may be a problem caused by a recent (Nov 07) Microsoft security update for .net, which changes the way certain unicode characters have to be adressed (then again, maybe not. I can hardly code... :wink: )
It also causes an exception, code: 0x0434f4d.

Can you look into this problem? I'm really intrigued by the description of the tool you gave, would make sprite generation much faster!
I was not able to reproduce the problem, but I probably did find the code causing it. You can try the attached executable/source to see if it works for you.
Attachments
blender_convert.rar
(1.16 MiB) Downloaded 240 times
User avatar
brupje
Transport Coordinator
Transport Coordinator
Posts: 288
Joined: 03 Oct 2006 07:17
Location: The hague, Netherlands

Re: OPENTTD Sprite Editor / Generator

Post by brupje »

Can somebody explain to me how the offsets in the PNG files are used? They don't seem to fit?
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: OPENTTD Sprite Editor / Generator

Post by GeekToo »

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 24 guests