News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Modular Buildings

Started by The Hood, January 01, 2012, 08:01:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

The Hood

Some of you will be aware of wlindley's innovative new way of creating attractions and factories by combining 1x1 tiles of images together to form larger buildings (e.g. http://forum.simutrans.com/index.php?topic=4454.msg82006#msg82006).  I think this idea has loads of potential but in order to make the most of it I'd like to suggest an extension request in order to make it easier to create these sort of objects and also (hopefully) to reduce the size of the resulting pak files.

I had the basic idea when I was messing around with the images to see if I could make any good looking combinations myself using the same graphics wlindley had already produced.  In order to do this quickly without writing and re-writing lots of dat file code, I decided to make each image into a separate 1x1 attraction building and then used the map editor to place and arrange them how I wanted.  This worked very well and was very easy to do!  However, the resulting "buildings" of course remained several attractions next to each other, and the building placement routine currently has no way of forcing buildings next to each other in an arranged pattern.  So I had to spend a long time coding up long list of image references in a dat file (especially for the asymmetrical buildings requiring 4 rotations).  The many image references required also lead to a very large pak file at the end! A lot of work for a neat concept!

So here's the idea:
1) have a new type of object "BuildingModule".  A BuildingModule is a 1x1 object with all the graphical properties of a 1x1 building.  Its dat file would be defined with a name, dims (=1,1,1; 1,1,2; or 1,1,4 depending on rotations) and image references in the same way as for city buildings or 1x1 attractions/factories.  However the BuildingModule would never be built on its own.
2) Alongside this, allow a second method for defining multitile buildings (factories, attractions, townhalls, any others?) as well as the current image definitions.  Perhaps this could be toggled in the dat file with an isModular=1 tag.  The building dat would be largely the same as present, with all the usual information on passenger level and industry inputs/outputs etc, but instead of defining images, the dat would define pointers to BuildingModule objects e.g.


dims=2,2,4
module[0][0]=BuildingModule1,0
module[0][1]=BuildingModule2,0
module[1][0]=BuildingModule1,1
module[1][1]=BuildingModule3,0


Note that each "object" pointer only uses two parameters, east and north position from the first tile.  Height, snow, animation detail would all be taken from the BuildingModule pointed to.

Rotations are a little more complicated: I would not envisage multiple rotations in the new module reference as the game would know which 1x1 module is placed on which tile, so when the map is rotated the images are in the correct place (as it is essentially a group of 1x1 objects).  However the building would need to know which rotation of the BuildingModule to use in each orientation.  This is what the numbers after the comma are intended to represent.   "0" means use the 0 rotation definition from the BuildingModule reference (which would be the default), "1" would mean 1 etc.  When the map is rotated, the rotations would be recalculated in the same way that current building rotations are handled.

This is the end of the basic suggestion - I hope it would not be too hard to program and I really think it would open up the possibility of creating a large set of consistent buildings for much less graphical work, a worthy goal in my opinion. However I haven't got the programming skill to realise this or even comment on its suitability.

Finally if the basic suggestion were to be implemented, it could also open the way for some further extensions:

1) Random elements within multitile buildings.  A good example would be a cathedral.  Say there were 3 different BuildingModules for different types of tower/spire.  The building dat could define a basic plan, but the tile where the tower goes (2,2 in this example) could have three references (the third parameter here is for each of the three possible BuildingModules to use, and the last number on each line is the chance weighting to use that image instead of the others):


...
module[2][2][0]=Tower1,0,100
module[2][2][1]=Tower2,0,50
module[2][2][2]=Spire,0,75
...


This would allow greater variation of attractions/factories but without requireing lots of different objects.

2) Have an in-game editor which allowed people to create their own buildings of a certain type from the BuildingModules (harder!)

Hope this piques the interest of someone with coding skill!

Isaac Eiland-Hall

If something like this is going to be worked on, it might be re-used to make European-style blocks work (multi-story buildings around a central plaza, taking up a full block)...

Milko

Hello

I have seen the modular buildings that Windeley has made ​​and I found them very interesting. I believe that this extension is very useful. This request will be taken into consideration?

Thanks
Giuseppe

wlindley

This could probably be coded into makeobj, without changing the .pak format at all... right?