Placing Image Objects on the Board

In this post, under the section Tiled’s Objects and Board’s Logical Positions, point out that the positions for Tiled’s Objects  are set in orthogonal space, as though we were viewing things from top-down. There are no convenience features in the Board plugin that will translate this, so, like previously, I had to come up with a computation that will translate orthogonal coordinates to the desired isometric view.

The function inside C2.

The gist of it is this: In orthogonal, X means X and Y means Y. To get to a point, it is p=(x,y).

In isometric space, a movement along X is perceived as a movement in both X and Y, ie the point goes from upper-left to lower-right. Again, for every X movement in orthogonal space, there is a X and Y movement in isometric space. Therefore, you have to get the directions in isometric space for X and Y.

When you get the X and Y axis vectors, you multiple your unit movement with those vectors.

The uox and uoy are the values I refer to as the isometric unit vector for X and Y axes, respectively. We don’t use uox or uoy directly, because there are actually 2 components. In uox and uoy, there are the X and Y components:

uox_x # how much iso x movement from ortho x
uox_y # how much iso y movement from ortho x 
uoy_x # how much iso x movement from ortho y
uoy_y # how much iso y movement from ortho y

Then it’s important to know the unit value of the orthogonal values; we want to get a ratio of movement: how far between fixed tile sizes are we trying to pinpoint?

So the orthogonal X and Y are divided by the tile’s height, which is done because Tiled actually does it this way (the post linked above explains this).

ux = in_x/TileH
uy = in_y/TileH

Then the final bit is to add up how much movement did a ortho X affect iso’s X and Y, and how much did ortho Y affect iso’s X and Y.

out_x=(ux * ox_x) + (uy * oy_x)
out_y=(ux * ox_y) + (uy * oy_y)

This allows me to place Objects as though they were tiles on the Board. Of course, the placing of Tiles/Chess components on the Board is still being done using the Board’s functions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s