• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
This is a little side-project I've been working at for a wee while:

8b7df66d9c.jpg


Behold- procedurally generated thatch hovels for your filthy peasant tenantry!

It ain't much to look at right now, but this is the result of a simple java application I've been putting together. The program, in a nutshell, is a elementary demonstration of how custom architecture can be generated from rudimentary bits and pieces of imported geometry. I won't bore you with the details of implementation (-unless you really want that-) but I'm hopeful this might help out with the development of a future majesty sequel in several ways.

* 1.* Random architecture (naturally) allows a greater diversity in building appearance, helping to offset the monotony of large settlements without placing excess pressure on the content team.
* 2.* The approach allows simultaneous generation of building interiors and even separate rooms within the floorplan, thus (in theory) permitting ease of prying into your denizens' private lives!
* 3.* Since the buildings are generated on a tile-by-tile basis, by the same principles a building can easily be sliced up into separate pieces for purposes of physics simulation, which brings me to (last but not least)...
* 4.* Full terrain integration. Fog of war, cover/lighting/visibility and other terrain effects can apply easily within such buildings, making them essentially well-fleshed-out aspects of the landscape. In other words, you needn't maintain an artificial distinction between 'indoor' and 'outdoor' areas.

Of course, the approach isn't without it's weaknesses- irregular, non-linear architectures (such as those for the temples to Krolm/Fervus, and things like trees or boulders,) wouldn't easily be reproduced by this technique- moreover, good results require a pretty tight understanding between the content and programming teams, to make sure that the right architecture can be coded for each building set, and that art in turn is produced in the proper format for each. But at minimum, I think there's a broad class of buildings that could benefit substantially from just such a touch of individual personality.

The technology itself isn't very fancy- it's essentially identical to random-level generation you'd get in a variety of old-school CRPGs- nothing much you couldn't get 20 years ago. But... to my knowledge, nothing similar has been done in the RTS/Sim field, and I think it could help set majesty apart from future competitors. (Heck, think of it as a cheap way to hop on the Spore bandwagon :p ).
Finally, I still have to add a lot of bells and whistles such as nicer texturing (and normal correction,) doors/windows/chicken-sheds/eaves-and-porticos. They'll be coming along later (with luck.) I'm sure the professionals, at any rate, could make a much nicer job of things.

So. If you have any questions about the code itself, or want to sample the source yourself, PM me and I'll send you along a copy. And let it never be said I'm just here to moan and criticise!

I am also here to feed my ego.


Alfryd
 
Last edited:

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
Thanks. :cool:
It should be easy enough to substitute different bits and pieces for the walls/roof/texturing, so, yeah, slum shacks ought to be possible. The problem would be making them ramshackle enough... ...I was thinking the elven bungalow might be an interesting challenge.
Very cool.
How much coding and tweaking was required to get the results you posted?
The rendering and import of geometry is handled by the java-client code I was working on a while back, but the procedural elements... I suppose that took me 3 weeks, or about 20-25 man-hours.
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
0a9877ef6f.jpg


This is a somewhat clearer version, but you can also see some of the potential hickups- random chimneys stuck over random doors, the whole lego-brick syndrome thanks to roof deformation. Still, they used to look like maya stepped pyramids, so I guess that's something... :rolleyes:

It'll probably be a while before I have any more updates. Any suggestions?
 
Last edited:

unmerged(83127)

Private
Aug 29, 2007
10
0
You probably already thought of it, but religious and racial themed buildings. Especially with the racial buildings. Gnome hovels were just as randomized as houses in Maj 1, and Bungalows I guess wouldn't be too far behind. As for settlements, I think that would be a little trickier because these are dwarves. Perhaps the idea could be that random features for a dwarven settlement can come with their own bonuses, if you catch my drift

O and a definate improvement of cottages from first posting to latest posting
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
Problem with gnomes hovels is that they're too randomised- it's very difficult to come up with an overall 'toolkit' to replicate their look-and-feel. I thought bungalows might be a good 'next step' since there are 3-4 different elvish structures in the game, which gives me good examples to work from, and they have relatively regular geometry. The temple to Agrela is probably doable now.
The trouble with the temples to Dauros/Lunord/Krypta is that they have a formal architectural pattern which you can only make modest variations on. They're not impossible, it would just take a bit of extra work at coding. The next 'step up' would be the wizards' guild/towers. I guess.
 

unmerged(79717)

Is this esoteric?
Jul 4, 2007
350
0
www.heroesofardania.net
Alfryd said:
This is a somewhat clearer version, but you can also see some of the potential hickups- random chimneys stuck over random doors, the whole lego-brick syndrome thanks to roof deformation. Still, they used to look like maya stepped pyramids, so I guess that's something...

It'll probably be a while before I have any more updates. Any suggestions?
Well from the looks of it you will have to start adding building regulations to your pseudo-random constructions. That's part of the reason we have building regulations in R/L (to prevent people from building unsound buildings).
The first rule is no doors opening up directly in to fireplaces. :p
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
Well from the looks of it you will have to start adding building regulations to your pseudo-random constructions. That's part of the reason we have building regulations in R/L (to prevent people from building unsound buildings).
The first rule is no doors opening up directly in to fireplaces.
Yeah... might want to look into that.
*scratches chin thoughtfully*

Oh- I forgot to mention another potential benefit of this approach- quite aside from physics-based destruction of such structures, you can also perform tile-by-tile construction animations of these buildings- actually have your peasants scuttle from corner to corner, piling stone or daubing wattle until the structure is built or repaired. And of course, the order of construction would be unique for each building! (Now put that in Havok's pipe and smoke it.)
 

unmerged(83127)

Private
Aug 29, 2007
10
0
I'm guessing that it could be possible to have it not be randomized and customized. A little daring proposition is to have a seperate editor, not the map editor, but an architecture editor. Here, we could make our own buildings, with our own styles and more importantly functions.

As in add this building armor, or those extra housing slots, this arrow tower, these siege gaurds (close range anit-melee guards like boiling water, falling rocks ect.), this bit of inventory shop, higher hitpoints, larger or smaller size, or less of all the aforementioned (and non-mentioned) features in favor of lower overall price.

Could probably be a bit of a headache for implementation, but its an idea...
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
Remember that the temples all have an origin for their building design, so there shouldn't be as much variation in them anyway.
Great work though Alfryd. How long did it take you?
As mentioned, about 20-25 hours over 3 weeks. (Don't expect any major further developments in the near future, though... ...still have bugs to iron out...)

I'm guessing that it could be possible to have it not be randomized and customized. A little daring proposition is to have a seperate editor, not the map editor, but an architecture editor. Here, we could make our own buildings, with our own styles and more importantly functions.
I think it's likely enough there will be tools available for that sort of thing anyway- I mean, there's going to be a map editor, so between that and some custom models/textures, it should be possible to put something together.

I remember when the Building Architect came out for SimCity 3000, when what I really wanted was a way to stick 4 2d-images together to create an isometric sprite. Then I could create whatever building I liked in photoshop... But yeah, I guess that if Paradox/1C were to do another sequel with this included, then a building editor could piggyback on the essential technology easily enough. You could skip the random-generation bit entirely, I guess, but it's not that much extra work in comparison...
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
Well, essentially the algorithm goes through 3 different phases. Phase 1 consists of generating a floorplan. Step 2 consists of attaching predefined, imported geometry to that floorplan in successive layers (in this case, 1 for the walls and 2+ for the roof.) Step 3 consists of final deformations to that geometry (for instance, adding the curve to the roofing tiles.)

The cottages essentially start out as tree structures- they have a central stem which 'branches out', thinning naturally to give the appearance of extensions and side-wings. Any area covered by these extensions are masked out on a fixed grid representing the floorplan. In essence, that's phase 1. The trick involved is getting the right parameters for branching- where to branch, how often, when to prune, and so on. (In this case, I prune pretty early.)
After that, you take each tile within the ground level floorplan, check for neighbours, and assign geometry accordingly- it's essentially the same as adding 'feathering' between different terrain types on an RTS map, but in 3D. A similar process applies for roof tiles, except that after each pass, the area is shrunk by one tile, and the geometry raised, to create a 'pyramid' layout. That's phase 2.
Finally, I deform the roof using a simple height function for each layer of geometry to give it a convex curve. (The surface normals also have to be adjusted, which is something I haven't perfected yet- you can see the different layers easily in the 2nd shot.)
I'd zip up the code and send it to you later, but I'm tired atm... PM me tomorrow. I'll put up some of the code then anyway.
 

unmerged(83445)

Sergeant
Sep 4, 2007
86
0
Thanks' for indulging me, Alfryd. I was very intrigued by this idea when you suggested it earlier in the year. Looking forward to seeing how far you take this. Let me know if you want/need a modeller to help you with some content. I'm pretty familiar with modelling in segments like this, did it a lot for Dungeon Siege, and for another game engine I'm doing with a friend.

I'd like to see the code, but no rush on that, my access is pretty limited at the moment. I can pass you along a nice FTP next time if you need it. I've been working on a project of my own this past year (turned based rpg built ground-up in Adobe Flash/Air) , I'll be sure to pass it over once I feel it's worthy of your scrutiny :p.
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
http://home.graffiti.net/alfryd:graffiti.net/Sov.zip

That should be a zipfile of all the code and libraries related to the java client. The code specific to procedural generation is the sov.gen package.
So running:
java -cp .:jogl.jar:gluegen-rt.jar sov.test.CompTest
...within the base directory ought to do the trick.
I'm afraid the code isn't outstandingly well-commented at the moment, but get back to me if you have any problems and I'll work on it.

I'm pretty familiar with modelling in segments like this, did it a lot for Dungeon Siege, and for another game engine I'm doing with a friend.
You worked on Dungeon Siege? I thought that game had a very interesting approach to continuous environments. I'd be thrilled to have your help, but right now, this is only a prototype, so... y'know, don't hold your breath. :p

Again, the basic technology is simple enough- essentially, you take the techniques used to create random levels in something like DiabloII, and just apply them on the scale of a single building.

I've been working on a project of my own this past year (turned based rpg built ground-up in Adobe Flash/Air) , I'll be sure to pass it over once I feel it's worthy of your scrutiny.
Mmm... Flex. :)
 

unmerged(83445)

Sergeant
Sep 4, 2007
86
0
Alfryd said:
http://home.graffiti.net/alfryd:graffiti.net/Sov.zip

That should be a zipfile of all the code and libraries related to the java client. The code specific to procedural generation is the sov.gen package.
So running:
java -cp .:jogl.jar:gluegen-rt.jar sov.test.CompTest
...within the base directory ought to do the trick.
I'm afraid the code isn't outstandingly well-commented at the moment, but get back to me if you have any problems and I'll work on it.
My thanks', I'll give it a go this weekend.

Alfryd said:
Again, the basic technology is simple enough- essentially, you take the techniques used to create random levels in something like DiabloII, and just apply them on the scale of a single building.

Simple enough, yes, but I think you could get a really nice tech demo of what could be if you keep pushing your idea. Randomized decorations and such, I think, are where the method will really pay off visually (you can already see how adding the door and chimney really helped sell the effect in your 2nd image compared to the first)

You worked on Dungeon Siege? I thought that game had a very interesting approach to continuous environments. I'd be thrilled to have your help, but right now, this is only a prototype, so... y'know, don't hold your breath. :p

I dabbled in modding both the first and second one. Never did anything serious, but learned about modeling for games from it. I met Hassat in the Beta of DS2 actually..I agree with the continuous environments. I also liked just how much emphasis they put on abstracting everything from an 'object oriented' point of view.

I'm just idly offering if you're looking. No rush or anything, i'll be around when or if you need me.

Looking forward to some updates when you get around to it.
 

Alfryd

...It's nice up here!
3 Badges
Jul 9, 2007
2.031
13
  • Crusader Kings II
  • Majesty 2
  • 500k Club
...(you can already see how adding the door and chimney really helped sell the effect in your 2nd image compared to the first)
Yeah... about that... I actually cut that out of the most recent version (which also uses a different model atm...) Should be easy enough to fix, though the code can only import milkshape models right now. But yeah, I'll let you know once I have something more substantial by way of an update.
 

unmerged(83445)

Sergeant
Sep 4, 2007
86
0
Well I've perused your source, but haven't tried compiling it. I'm not overly Java competent and notoriously lazy to boot. I take it all the actor, terrain, gui, etc stuff is from the other Majesty Java project you abandoned?

My friend and I are doing something similar to this but simpler for a space RTS we are making. We are using a bunch of premade nodes that I modeled to generate space platforms (think like starcraft) that float above a planet and serve as kind of 'floating islands' for the gameplay to take place on.

Looking forward to that update. Do you use aim or msn by the way? Not that i'm on it much these days, but if so, I can pm you my addy.