realbasic-games
[Top] [All Lists]

Re: Dynamic 2D Isometric Terrain

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Dynamic 2D Isometric Terrain
From: William Squires <wsquires at satx dot rr dot com>
Date: Sun, 26 Jun 2005 09:32:03 -0500
Cc:
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <BEE19255 dot 8EEA%seth at johnfinley dot com>
This sounds like a perfect example of when to use an array (matrix) transform (basically, like a filter in Photoshop), where the contents in the array are treated as pixels. Try googling for (("filter" Or "matrix transforms") And ("code" or "algorithm")) and see if that helps. Basically, given an input matrix 'A', and the desired output matrix 'O', you apply a matrix transform as:

O = A x T

where 'T' is the transformation matrix, and if the dimensions of A are square, then T and O are square also, and have the same size (N x N). If A is not square, then you have to watch out, since matrix multiplication is not defined unless 'T' is the correct size, too. Namely, if 'A' is an M x N matrix, (M rows and N columns if I remember my Linear Algebra correctly...), then 'T' has to have N rows in order to perform the multiplication. So if 'T' is an N x P matrix, then O will be an M x P sized matrix (I think...) :) It sounds like what you need is a smoothing, or anti-aliasing, filter. Set the middle tile in the matrix to '4' like you did in the example, then apply the filter, and it'll 'smooth' the pixels between it and the outer edge.
  HTH!

On Jun 24, 2005, at 9:35 AM, Seth Duke wrote:

I have been working on a 2D Isometric Terrain system that mimics the old
SimCity 2000 terrain system.

Getting pieces to line up and connect properly has not really been a
problem.

The issue I am trying to iron out know, is making the terrain editable in
real-time.

I settled on a Matrix that represents the level of any tile on the board,
where the lowest possible tile is 1.

Example - 7x7 tile grid:

1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1

When say the center tile is raised to level 4, the output should become

1 1 1 1 1 1 1
1 2 2 2 2 2 1
1 2 3 3 3 2 1
1 2 3 4 3 2 1
1 2 3 3 3 2 1
1 2 2 2 2 2 1
1 1 1 1 1 1 1

So far, I have achieved this "slinky" effect by taking the raised tile and setting the heights of each outer ring to one less than the raised tile,
etc, etc.

What I can't seem to layout mathematically is taking in to account other
tiles in the area that may have already been raised.

ex: Given the previous raised state, I raise the tile to the right of the
center one to 4 as well. Its output should look like this:

1 1 1 1 1 1 1
1 2 2 2 2 2 2
1 2 3 3 3 3 2
1 2 3 4 4 3 2
1 2 3 3 3 3 2
1 2 2 2 2 2 2
1 1 1 1 1 1 1

Is there a known formula for this kind of matrix transformation? Where every matrix(x,y)'s value directly effects all surrounding values do produce a
smooth transition/staircase effect?

Doing google searches for various matrix types and examples have not turned up much. It just seems like this would be a formula that is sitting in the
matrix section of some math book. I would like to rule out the possible
availability of such a formula before I go beating my head against the wall
calculating it myself.

Thanks,
-Seth
--
<http://realopen.org>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


William H Squires Jr
wsquires at satx dot rr dot com dot nospam <- remove the .nospam

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>