Hallo Everyone,
I am using Skorpios Tilesets for my Dungeon Keeper Project.
So he ask me to share my Ideas with this Project and the Coders here, he suggest to post it in the Code Area, so thats what I am going to do in this Thread. As a very thankful gesture to Skorpio and to this amazing Project you have here!
I think my Idea is a good an simple solution and will work in every Programming Language (My Project is written in Java).
The Basic Idea:
Every Tile has 8 Neighbors. So you Could just check the Neighbors and do complicated if-then-else Code. Or you just develop a Code that identificates every Tile in an easy way to use it inside an algorithm:
As you can see every Neighbor has a Number. These Number represent the Position in a 8-Bit Binary Code.
So the Tile in the Example shown has no Neighbor. So that Code would be just
00000000.
So in the First step you have to rename every Tile Skorpio has Build (or in My Case i just rename them in Blender an re-export them):
- b
The Tile in this Picture has the code
10000011. Because he has 3 Neighbors. one at Position 0, 1 and 7. (Remember you Read Binary Code from Right to Left).
So you have all the Tiles in an easy-to-use Binary Code:
- drt
The Selected one has the Code
00111110. The c is just an identifier later in the alogrithm that there are several alternatives with the same Binary Code. So what you can see is the Filename. All the Files are already created in the correct Binary Code.
So all you have to do is to check the neighbors, calculate the code, concat it to the File-Adress-String and then Load the File which has the matching Binary Code!In my Solution all the Objects for one Szene are Loaded over an .XML File with the XML-Parser we created. (To ensure that also people without programming skill can use our 3d support).
So the Code for that is:
- xml
The "?" in the modelpath-url show my Program that there has to be an Calculation done before loading the Model.
I have a Dataholder for every Object in the Szene in Java with Propertys.
I save the Neighborhood Property in the Data-Representations of the Objects in Java.
The Neighborhood Property are set when I load the map and "recalculated" every time one of the neighbors changes. (Like destroying a wall by IMP or something). Its pretty fast an efficient.
The Class to Load the 3d Objects use this Property to Find the correct Tile in the Folder.
You also need an exception handler after calculating the algorithm.
Normally there would be 2^8 = 256 different Tiles.
There are less (47 or something) because several cases are the same with the tilesets of Skorpio.
You have to set the position of the corners 0, 2, 6 and 4 to zero if they don´t have at least one direct neighbor. (for 0 pos 7 and 1, for 2 pos 1 and 3 and so on...).
The result is than this (in the first 2 pictures you can see the neighborhood value):
Hope it helps you, i will post more examples or pictues if needed.
- Flipflop
PS: sorry for my bad english .)