Mythruna
April 24, 2024, 03:13:00 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Rotation...  (Read 17643 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« on: April 24, 2012, 12:55:35 PM »

Things have been a little quiet around here lately so I decided to do a slightly more technical blog post on what has been going on in Mythruna development.

Many of you have seen the sun pictures but really that was just a fun side-track to avoid some different, more tedious, coding.  The sun thing started out as a player insistence to "fix it" and my goofing around with the light scattering filter that jMonkeyEngine includes be default.  I got light scattering to look kind of neat from certain views but a) it was expensive and b) there was no good way to determine when to turn it off.  If you were deep in a mine and looked up toward where the sun should be then you still got this weird scattering effect.  Still, after turning it back off again, the plain yellow circle sun looked pretty boring.  So I fixed that a different way.

The real project that I've been working on since well before the last release was "autogenerated buildings".

Prior to the 0417 release, I spent some time writing the "block pack" API and converting many of the existing block types over to block scripts.  All of the new block shapes are done in block-script.  Many of the old groups have been completely converted (like Stone) or partially converted (like Wood).  In some future release, this block script support will be exposed more formally as pluggable block packs.  (A user could add new block types right now but the game has no good way to deconflict block type IDs when new versions of the game come out so it would mess up your worlds.)

I thought this change was going to be necessary to do what I really wanted to do: which was have an easy way to determine when one block is the rotation or reflection of another block.  Turns out that it mostly wasn't but it was still a useful conversion... especially since it let me quickly add over 100 new block types for the last release.

Last night, after much tedious coding, I got the block transformation thing working as far as I've tested.  This means that if I have a stone ramp that rises to the north, I know which blocks would be a 90 degree rotation, which blocks would be a "mirror" of it in the x or y plane, which a 180 degree rotation, etc..  This is not necessarily as simple as it sounds because the block types themselves have no idea.  Furthermore, a stone ramp is symmetrical along one axis... so a mirroing along one axis is the same ramp but a mirroring on the other is a 180 degree rotation.  The corners and pillars are not symmetrical at all so a mirroring is a 90 degree rotation right or left (depending on axis).

This sort of transformation is important for generated buildings because it lets me break building templates into sections and reuse the sections in various ways.  I can rotate and mirror whole assemblies of blocks.  This allows me to take one building corner and flip it or rotate it to use as another building corner, and so on.

Mirroring was necessary because some building sections will have a definite front and side.  So while it might be ok to use the left side of a peaked roof as the right side... it wouldn't look right rotated.  Where as some sections or corners could be freely rotated without issue.

There is still a LOT of work to do before I have real generated buildings... and even more to do for generated towns and cities... but the rest of the work is slightly more fun.  Things like creating building parts and testing them out in different building templates is a more creative process and even the mistakes are sometimes fun to explore.

If anything cool comes out of it over the next week or two then I will post pics.
Logged
ayoriceball
Donators
Jr. Member
***
Posts: 99


Control Magic


View Profile
« Reply #1 on: April 24, 2012, 03:16:42 PM »

 Cool

You make it sound so easy Tongue
Logged

From Bay12Forums
Don't dwarven ladies know they're beautiful the way they are? They don't need to starve themselves to look like those elven bitches.
I have a skin, a potato has a skin, therefore, I'm God
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #2 on: April 24, 2012, 03:36:41 PM »

Last night to test I was using a building corner template I made... a first floor of a kitchen with a chimney.  When I had rotation working, I put four corners together to make one really odd looking house:



When the full templating is working, there will be routines to figure out how the second floor gets merged with the first that will leave that tall chimney intact.

It is a little surreal to walk around inside that, though.  Round the corner, there's a fireplace.  Round the corner, hey, deja vu, another fireplace... and on and on.
Logged
FutureB
Donators
Hero Member
***
Posts: 512


RAWR


View Profile
« Reply #3 on: April 24, 2012, 04:43:27 PM »

hehe looking good paul :]
Logged


Say the opposite of these words:
1)Always.
2)Coming.
3)From.
4)Take.
5)Me.
6)Down.
Moonkey
Hero Member
*****
Posts: 1587

This is probably a picture.


View Profile
« Reply #4 on: April 25, 2012, 07:26:31 AM »

Knowing that you are still working hard gives hope to all that you are not slipping away from coding. Hehe
Logged

Mythruna: Don't you dare read any posts I made before 2014.
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #5 on: April 28, 2012, 06:09:12 PM »

Making a little progress on the "random buildings" stuff...  This may actually work. Smiley

Here are three dumbly random buildings using only two different building parts.


Even with just two parts, rotated and mirrored, with random (and stupid) part selection, it generates some interesting floor plans.

I have about 15 sample parts total for first floor, second floor, and roofs layouts that I will use as I continue.  I'm pretty optimistic right now just based on how well that two-part test turned out.

Still lots of work to do and some rules to put in place, etc. but it's kind of a promising start so far.
Logged
FutureB
Donators
Hero Member
***
Posts: 512


RAWR


View Profile
« Reply #6 on: April 28, 2012, 08:35:37 PM »

i see some good develpoment happening :] keep working on the random generation :]
Logged


Say the opposite of these words:
1)Always.
2)Coming.
3)From.
4)Take.
5)Me.
6)Down.
Ghelmaron
Donators
Jr. Member
***
Posts: 76


View Profile
« Reply #7 on: April 29, 2012, 12:07:03 AM »

Looking good so far.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #8 on: April 29, 2012, 12:30:28 AM »

Some more goodies.  The generation is still operating completely random... so it frequently makes buildings without doors and stairs... and I only have a small handful of random sections, only one roof style, etc... and still:





It inspires me to make more parts.  Maybe I'll take a pic of the separate parts that are randomized to make those just to show you have few of them there are.  And each new part adds a lot of variation because it can be used in a few different ways, rotated, flipped, etc.
Logged
FutureB
Donators
Hero Member
***
Posts: 512


RAWR


View Profile
« Reply #9 on: April 29, 2012, 12:36:15 AM »

i cannot comprehend how you make those randomly generated XD
Logged


Say the opposite of these words:
1)Always.
2)Coming.
3)From.
4)Take.
5)Me.
6)Down.
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #10 on: April 29, 2012, 12:46:55 AM »

i cannot comprehend how you make those randomly generated XD

Part of me would like to leave it magic but my plan is that modders end up making their own building templates and I've designed the whole system around that.  So I will open the kimono a little.

This is a simple building template that is put together from just four corners (other template types will have other configurations but this is simple).  It expects the pieces to be a certain size and as long as the follow certain conventions, they will generally fit together well.

These buildings are generated by making a first level randomly choosing from one of five corner pieces that look like this, front side:


Back side:


In general, the lower level requires the most parts because it must have at least one door tile and at least one stairs tile.  Also, this is more likely where you have special parts like the kitchen (far left in the from the back pic).

Contrast that to the second floor which only has these three different tiles:


It will need more to have more complicate internal rooms but this works for now... especially since the algorithm is still stupid about how it joins up doors.

And finally, there are only two different roof pieces and that's only because the insides are different:


The neat thing is that I just make these in the blueprints editor and export them using a special admin tool.  So then I can incorporate the raw blueprints into my building templates as part of the random sections.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #11 on: April 29, 2012, 12:48:35 AM »

Also, while I only generated two levels and a roof these tiles would have supported generating one level on up to however many.  I may randomize the floor count next just to play.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #12 on: April 29, 2012, 12:50:00 AM »

Also note: all of these buildings are oriented the same way, basically, just for testing.  They can be freely rotated to any one of the 90 degree variations.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #13 on: April 29, 2012, 01:00:07 AM »

Exact same parts except this time I randomize the number of floors.


It could randomly go one more level up but it just didn't happen in this particular set.

And because there are no second floor stair sections yet, it is guaranteed to be impossible to get to the upper levels without building some by hand.  Still it's neat.
Logged
FutureB
Donators
Hero Member
***
Posts: 512


RAWR


View Profile
« Reply #14 on: April 29, 2012, 01:20:19 AM »

i still dont understand Tongue hehehe but i like how theres those difernt types of corner bits which all match up
Logged


Say the opposite of these words:
1)Always.
2)Coming.
3)From.
4)Take.
5)Me.
6)Down.
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!