The Daily Click ::. Forums ::. Klik Coding Help ::. 3D isometric to 2D mmf coordinates conversion.
 

Post Reply  Post Oekaki 
 

Posted By Message

Robbert



Registered
  19/06/2003
Points
  420
13th March, 2006 at 20:57:27 -

There seems to be a problem with my array, but I don't see what it does wrong...

I have an editor that writes strings to the array indexes. I use a 2d array (so z-dimension is 1).
In this editor I can give coordinates a texture:

0,0 / 1,0 / 2,0 are grass
0,1 / 1,1 / 2,1 are sand
0,2 / 1,2 / 2,2 are water

that is basicly the array that should look something like this:

0 1 2
0 grass sand water
1 grass sand water
2 grass sand water

So this is the array. I save this as Appdrive$ + Appdir $+"texturemap.arr"

Now in the engine I try to load it. The same file.

A loop runs through all the cells in the grid:

On loop "array"
+ String At XYZ(index_x,index_y,index_z) = "gras":

Create object grasstile and set it to the converted values of index_x and index_y and index_z etc...

But it does not recognize the strings that are in the array! It only does its work when String At XYZ = "". So it only reacts to an empty string. This makes my array worthless. Does anyone have an idea where I could be wrong?





 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
13th March, 2006 at 21:04:51 -

Ah I found it! The flat array begins with z as 1, while my loop starts at z as 0.

 
Hey mates, I'm Iglo yeah =P!

RedHades



Registered
  25/05/2003
Points
  108

Has Donated, Thank You!
14th March, 2006 at 02:27:16 -

Now I've been tweaking my Isometrics transform with excellent results.
And I also got my grid based collision engine to work with smooth movements and sliding on walls. The math is done only in 2D for now but adding the 3rd dimension in the process shouldn't be too much trouble. Entering narrow passages is a bit difficult though. But I have a few different ideas on how to work it out.

Early into this project, I though that using Tigerworks' Iso Grid 2 extension wouldn't work since the type of movement it handles isn't what I was looking for.
But while trying to build my isometric editor today, I had another look at it.

I must say that I should have gone with this extension from the start. Not for the movements it does, but because it's a good 3D array that can store multiple values in each of its cells, and has the 3D addressing features that I need. It also has lots of useful functions that can handle some of the position conversion I need. To think that I cracked my skull open trying to figure out complex equations, while that this extension handles them easily.

Iso Grid 2 is so good it would be an insult not to use it, for anything related to isometrics.

 
<0> ReDhAdEs <0>

Robbert



Registered
  19/06/2003
Points
  420
14th March, 2006 at 14:26:52 -

Could you post a screenshot or a file of the game here soon?

I would like to see at what point you're at.

 
Hey mates, I'm Iglo yeah =P!

RedHades



Registered
  25/05/2003
Points
  108

Has Donated, Thank You!
15th March, 2006 at 04:32:32 -

Sure.

Now those are still WIP and not very optimised, but here you go anyways:

http://www3.sympatico.ca/pysavard/MMF/IsoWorld.cca
My 3D to 2D coordinates conversion formula is finished.
I needed to give my 3D cube a fixed size and have it relate well to dimensions of my isometric tiles. Since I have isometric diamond tiles of 32x64, I figured it would be best to have 3D cubes of 16x16x16 unites. This turned out great and lead to simplifying my original equations. Now I divide and multiply by 2 instead of using cos() and sin() with weird float values. And I got rid of the shaky movement at the same time.

http://www3.sympatico.ca/pysavard/MMF/3D_IsoEditor.cca
My new 3D isometric editor. This is to fill the 3D array with collision cells. The blue cubes are only to represent the content of the array, not to act as collision objects.
But the basics of the editor are there, though lots of things are running constantly without really being needed. I still need to add a load and save features. The IsoGrid2 extension can easily take care of this.

I'm moving on to merging the 3D collision process with all of this, and then I have a "special" layer sorting idea that I want to try out.

Image Edited by the Author.

 
<0> ReDhAdEs <0>

Robbert



Registered
  19/06/2003
Points
  420
15th March, 2006 at 22:35:50 -

Nice. The Isoworld.cca reminds me of Excessive speed game, that controls.

But the 3D array... if you want to create a world of 300x300x40 it takes up more than 10 mb. And that's only one map! Even if it's empty. What are you doing about that?

My solution:

For the map a 2d array that loads the standard arrays. So the map is 300x300x1 and on every cell you could write "river_side" which is an array that contains the tiles for the side of a river (with dimensions of 1x1x40)...

40 is just the max number of z of the map. I don't know why. I might make it bigger, but we'll see.

 
Hey mates, I'm Iglo yeah =P!

RedHades



Registered
  25/05/2003
Points
  108

Has Donated, Thank You!
16th March, 2006 at 01:13:01 -

No, I dont intend to do such a large array. This goes in the same idea of not doing your entire mmf game in only one huge frame.
I intend to make it a room-by-room kind of game, with each frame being a room or an area. Kind of like the dongeons in zelda.
I will load one array per room. And I'll add some scrolling in the editor to edit larger areas.

I still have no idea what game to do with this. Probably an action game with puzzles, again taking zelda as an exemple.
I'm mostly interested in the challenge of programing and isometric engine and share it with the comunity.

 
<0> ReDhAdEs <0>

Robbert



Registered
  19/06/2003
Points
  420
17th March, 2006 at 10:54:26 -

I am planning to use this engine for a Real Time Strategy game. It's simply the best genre

So I cannot use rooms, it is a large outdoor zone But I found a solution... Oh, and I need your opinion to this one:

The layering of all the objects.

 
Hey mates, I'm Iglo yeah =P!

RedHades



Registered
  25/05/2003
Points
  108

Has Donated, Thank You!
17th March, 2006 at 14:31:46 -

Since you are making a ground landscape, it might be along these line:
For each moving objects, make sure that they each have their own Z height in an alterable value.
Then set a second alterable value to the object's screen Y position plus it's Z value.
Then use the layer extension to sort the objects using the second alterable value of the object.

Does it make sens?

 
<0> ReDhAdEs <0>

Robbert



Registered
  19/06/2003
Points
  420
18th March, 2006 at 19:20:26 -

Yes. Thanks.

 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
19th March, 2006 at 16:00:10 -

Hm I need your vision on this one:

I need big outdoor levels. The ground has an average height of 16. When the map is 200x200 it needs 200x200x16 "tile-blocks", that are all active objects.

This was done by a loop. It began with 0,0 (being the top cell) and went to 0,1 / 0,2 / 0,3 till it reached the Y-border. Then it did "Set Y to 0 and Set X to X+1. It switched to the next X-row. When both the Y and X values were at its border the loop did this: "Set X to 0. Set Y to 0. Set Z to Z+1". It moved to the level above to do the same thing again.

In every step of the loop, after the active object is placed at the right spot, the active objects turns into a backdrop object and the active object is destroyed. This is because when you have a big map (like 200x200x16 but even with much smaller maps) the game cannot handle all the active objects being generated in such a pace. The game gets stuck.

At first sight, the playfield is right. n,n,0 (the bottom cell) is in front of 0,0,0. But 0,0,1 is in front of n,n,0... which is not right! If a have a high tree at n,n,0 it would be overlapped by 0,0,1. That is not right.

So I need to generate the tile blocks in a different way. Not by the coordinates, but by it's screen Y coordinate. So 0,0 is layer 1 / 1,0 and 0,2 are layer 2 / 2,0 , 1,1 and 0,2 are layer 3 et cetera. But I can't seem to find a way to do this. Any idea?

 
Hey mates, I'm Iglo yeah =P!

RedHades



Registered
  25/05/2003
Points
  108

Has Donated, Thank You!
19th March, 2006 at 18:43:07 -

That's the big problem with isometric.
You can only make your ground area as backdrop object, and maybe your topmost walls, because they are "flat".
But for any OBJECT that has a height and width like a tree, or that hovers in the air like a platform, you need to keep them as active objects and limit their number.

Why are you making your world by a big loop at runtime?
Other than maybe having a random world feature, I dont see why you couldn't place your backdrop tiles yourself in the MMF frame editor.

Also, I should warn you that you are openning a big can of worms here.
MMF has some bugs with bigs loops, and it has other display bugs when pasting a large amount of active objects into the background from inside a large loop.
I had such trouble in the past and I didn't find any workarounds.

 
<0> ReDhAdEs <0>

Robbert



Registered
  19/06/2003
Points
  420
20th March, 2006 at 09:03:59 -

Well, I am not creating the map in MMF myself, because I want the game to have a level editor. So the map is built from a loaded array.

And I tried looping with big areas but they don't really give problems. As long as you do "on loop mainloop: create active object" and then immediately "add backdrop and destroy active object" it's not a big deal.

 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
21st March, 2006 at 22:15:30 -

Ah I made it possible. But with large areas the game still gets stuck (not really, but you'll have to wait for some time)

is there an extension or a way to have a loading bar which displays the progress of your loop?

If not, i'll have to look for a different way But I have the time

 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
22nd March, 2006 at 21:40:45 -

Hm that's not a bad idea I guess.

So instead of running 1 big loop of 100 steps, I'd have 10 loops of 10? When a loop is completed add 10 (%) to the counter?

 
Hey mates, I'm Iglo yeah =P!
   

Post Reply



 



Advertisement

Worth A Click