The International Simutrans Forum

PakSets and Customization => General Resources and Tools => Tools => Topic started by: Ashley on June 01, 2009, 02:49:23 PM

Title: Script for Simutrans-style sprites from 2D vehicle drawings
Post by: Ashley on June 01, 2009, 02:49:23 PM
Curious.

I've just been looking at the deluge of spammy posts Budapest was making (in the Recyle bin now thankfully).

I wonder if it'd be possible to write a script that could take those flat, diagramatic views of vehicles and turn them automatically into Simutrans-style sprites. They'd need quite a bit of touching up of course, to fix graphical oddities, but I think it would probably do a lot of the grunt work of creating a new vehicle fairly automatically.

From the looks of it (especially for the buses) there are views of all 4 sides. The roof would in most cases be fairly easy to extrapolate too. Then all you'd need to do is clean them up, touch up the details/player colour and add headlights etc.

I wonder what the copyright issues would be in doing this kind of thing as far as the original source images go?
Title: Re: Script for Simutrans-style sprites (from: Critica.............)
Post by: Spike on June 02, 2009, 02:43:31 PM
Quote from: Timothy on June 01, 2009, 02:49:23 PM
I wonder if it'd be possible to write a script that could take those flat, diagramatic views of vehicles and turn them automatically into Simutrans-style sprites.

With a bit of manual work (cutting the textures from the picturees) and a programmable raytracer like Blender or Povray this should be possible. I've made at least one vehicle long ago just by rendering textures onto a plain box. It worked surprisingly well and with some manual finetuning it was rather good actually.
Title: Re: Script for Simutrans-style sprites (from: Critica.............)
Post by: IgorEliezer on June 02, 2009, 03:56:06 PM
Once BudaT made this that topic for "critica", I think it'd be better we discuss about this new tool in a new topic (or split this one). How about?  :)

EDIT: Done! :D
Title: Re: Script for Simutrans-style sprites (from: Critica.............)
Post by: Spike on June 02, 2009, 03:58:04 PM
Quote from: IgorTekton on June 02, 2009, 03:56:06 PM
Once BudaT made this post for "critica", I think it'd be better we discuss about this new tool in a new topic (or split this one). How about?  :)

Good idea.
Title: Re: Script for Simutrans-style sprites (from: Critica.............)
Post by: IgorEliezer on June 02, 2009, 04:07:12 PM
I did.

The former topic is here: http://forum.simutrans.com/index.php?topic=2370.0

And I hope Timothy gives a better topic title and can erase that "(from: Critica.................)" from there.
Title: Re: Script for Simutrans-style sprites (from: Critica.............)
Post by: vilvoh on June 02, 2009, 04:10:24 PM
imho, would be possible to carry out this with Python and Blender...you may guess the object shape using image procesing algorithms (i.e. border detection) and then you apply the texture to a blender object you've created. You even can render it from python, too. It could be a Blender plugin...

Note: A possible project name could be paper2obj or drawobj
Title: Re: Script for Simutrans-style sprites from 2D vehicle drawings
Post by: Ashley on June 02, 2009, 04:56:52 PM
If the images have a common background colour this can be detected and removed, with edge detection used to align the textures on the sides of the plain box. You could even use the edge detection more extensively to produce a tighter-fitting box (e.g. if you detect that a bus has a sloped front from the side view, you can make the front have the same profile in the model you produce, same idea for the sides...)

The alignment could be done automatically, and the dimensions of the object entered seperately to give the correct scale. Then you just need to draw the textures onto the mesh created automatically and render it. Would be a very interesting project, could likely be done using python and pyopengl/PIL.
Title: Re: Script for Simutrans-style sprites from 2D vehicle drawings
Post by: VS on June 02, 2009, 05:12:29 PM
All interesting ideas. Some minimal input would be required in preprocessing phase - I can imagine just telling the user to fill empty space with fuchsia and removing labels etc. would shave off lots of difficulties. Then... what? Cutting apart the picture into discrete fragments of connected texture is piece of cake. Hard is understanding what goes where. Perhaps an assumption could be made that no curves are involved and sides are absolutely flat. The user can then dissect these texture pieces further with straight lines to get the "orthogonal" primitives. Interactively select sides to form the profile, then the rest is just like wrapping a toilet paper on the profile. Have user add hints and map onto the thing. Done.