Jump to content
Eternal Lands Official Forums
Sign in to follow this  
Torg

Map Tiles

Recommended Posts

Does anyone know how to convert from the actor, or in-game coordinate systems to that of the map file?

 

I'm working on some code for NEW_SOUND that checks the tile being walked on to vary the sound based on the surface, but I'm having troubles getting the right tile.

 

My understanding is that actor x_pos and y_pos are half the in-game coords (so multiply them by 2)... and the map system *seems* to be in-game divided by 6, but I'm not completely sure because it doesn't work correctly (although it seems close).

 

If this is correct, how do you deal with rounding errors??

 

Help!!...

Share this post


Link to post
Share on other sites

If it's just actors, you could use their [xy]_tile_pos. Apart from that, tile coordinates seem to be int(2*scene coordinates).

 

The number 6 is the factor between height map tiles and groundtiles: each ground tile (supposedly 3x3 m) is contains 6x6 height map tiles (50x50cm).

Share this post


Link to post
Share on other sites

I'm not sure which coordinatess you're talking about, but this is what's usually used (at least by map-makers):

 

Click the height-map button (stairs),

Click the clone button (the two cubes),

Click somewhere on the floor,

 

And you should get your X/Y Coordinates on the bottom-left of your screen.

I hope that helps.

Share this post


Link to post
Share on other sites
If it's just actors, you could use their [xy]_tile_pos.

Dangit!! I should have remembered [xy]_tile_pos. I got confused some other time sending the wrong coords because of that. Thanks mate!

 

Apart from that, tile coordinates seem to be int(2*scene coordinates).

It would have to be more than that because IP is a 32x32 map, and the tab-map says its top right is 192x192.

 

The number 6 is the factor between height map tiles and groundtiles: each ground tile (supposedly 3x3 m) is contains 6x6 height map tiles (50x50cm).

Yeah, I was reading the code trying to convert between all the systems and my brain just imploded.

 

I'm not sure which coordinatess you're talking about, but this is what's usually used (at least by map-makers):

 

Click the height-map button (stairs),

Click the clone button (the two cubes),

Click somewhere on the floor,

 

And you should get your X/Y Coordinates on the bottom-left of your screen.

I hope that helps.

Yeah, I noticed that just going through the map makers section of the forums. The conversion I actually wanted was between scene coordinates (or grid coordinates in the editor) and map tiles... so a 32x32 map, is actually about 192x192 coords large I think (thinking of IP).

Share this post


Link to post
Share on other sites

Yes, the coordinates in EL are fun. A 32x32 map:

*) contains 32 x 32 groundtiles

*) has 192 x 192 possible actor positions (ignoring unwalkable positions)

*) is drawn in OpenGL xy-coordinates (0.0,0.0) - (96.0, 96.0)

 

I wouldn't be surprised if there are even more coordinates than this, but these are the ones I can think of :omg:

Share this post


Link to post
Share on other sites
Dangit!! I should have remembered [xy]_tile_pos. I got confused some other time sending the wrong coords because of that. Thanks mate!

Ok... well that didn't work.

printf("\nActor Pos: %f, %f - Tile: %d, %d\n\n", pActor->x_pos, pActor->y_pos, pActor->x_tile_pos, pActor->y_tile_pos);
gives...
Actor Pos: 51.000000, 75.000000 - Tile: 102, 150

Something tells me [xy]_tile_pos isn't being handled correctly in the timers thread (from the header comment), or whereever it happens.

 

I'll go back to [xy]_pos / 6 as that is likely to be more stable (as in [xy]_tile_pos should probably be fixed).

 

My next question is how do I deal with rounding errors? Is the remainder of [xy]_pos / 6 just dropped, or would it round normally (.4 down, .5 up)??

 

I wouldn't be surprised if there are even more coordinates than this, but these are the ones I can think of :omg:

Well there are height-maps, which I would say technically are a seperate coord system because they are calcuated independantly from what I can gather. They just happen to match the actor position coord system (I think).

Share this post


Link to post
Share on other sites

/me's confused

 

[xy]_tile_pos gives you the height map tile the actor is standing on. If you want the ground tile, then yes, you'd have to divide that value by 6. But why would you want that?

 

Oh wait, to determine the surface you're walking on. Well, in that case you can simply drop the remainder. However, you're going to run into interesresting problem when the actor's not actually standing on the ground tile, for instance when crossing a bridge. There might not even be a ground tile when large 3D objects are covering the ground, like in mountain ranges.

Share this post


Link to post
Share on other sites
[xy]_tile_pos gives you the height map tile the actor is standing on. If you want the ground tile, then yes, you'd have to divide that value by 6. But why would you want that?

 

Oh wait, to determine the surface you're walking on. Well, in that case you can simply drop the remainder.

Hmmmm ok. It just seems to act a little strange. Sometimes when I'm walking on dirt it says grass, and sometimes when I'm on grass it says dirt (when they are close). I'm guessing that is somehow due to rounding errors. Meh, I'll commit it anyway and people can look around and see what happens. Maybe someone will notice a pattern.

 

However, you're going to run into interesresting problem when the actor's not actually standing on the ground tile, for instance when crossing a bridge. There might not even be a ground tile when large 3D objects are covering the ground, like in mountain ranges.

Oh boy... don't tell me that! Please!! Nooooooo....

 

Any ideas of a better way to work out what you are walking on? I expect this is going to be complex as hell.

 

Hmmm, maybe if you are elevated (and possible lowered) from the ground surface according to the height map, then assume that's a 3d object you'll be on, and try to calculate something that way.... eek!

Share this post


Link to post
Share on other sites
Hmmmm ok. It just seems to act a little strange. Sometimes when I'm walking on dirt it says grass, and sometimes when I'm on grass it says dirt (when they are close).

Only when walking, or also when you're standing still? If the former, perhaps it's due to the [xy]_tile_pos already containing the new position, while the actor is still moving. You could try to use actor->tmp.[xy]_tile_pos, see if it helps.

However, you're going to run into interesresting problem when the actor's not actually standing on the ground tile, for instance when crossing a bridge. There might not even be a ground tile when large 3D objects are covering the ground, like in mountain ranges.

Oh boy... don't tell me that! Please!! Nooooooo....

 

Any ideas of a better way to work out what you are walking on? I expect this is going to be complex as hell.

 

Hmmm, maybe if you are elevated (and possible lowered) from the ground surface according to the height map, then assume that's a 3d object you'll be on, and try to calculate something that way.... eek!

Pfff...

I'm not sure I have a good any good ideas on this.

 

What you could perhaps do, is to build a terrain map on map load. For each height tile, query the bbox_tree for the first object or ground tile you cross when you go vertically down from the height at that tile (or perhaps slightly above that height, start at the actor's knees for instance). Ehmm... well, that still won't work when the actor is more than knee deep ion the water. Oh well, you get the idea.

 

Usual disclaimer applies: I haven't tried to do this, don't even know if it's possible.

Share this post


Link to post
Share on other sites
Only when walking, or also when you're standing still? If the former, perhaps it's due to the [xy]_tile_pos already containing the new position, while the actor is still moving. You could try to use actor->tmp.[xy]_tile_pos, see if it helps.
Well the sound only plays when you are moving (the "walk" animation is called). That is a fair point about them already being updated. I'll have to have a look.

 

Actually... I've just realised there is another problem. The sound is created when the animation is loaded, and looped until the animation stops. However, it is competely possible to go over many different ground types in the one walk sequence (before another command is triggered I guess). Therefore, the sounds for walking probably need to be handled differently to the sounds for the other animations.

 

Much as I hate it, because it means another loop and more hence delays in the code, but I think we need to have a loop, or timer to check the current ground tile and update the walking sound every x milliseconds. Grrrr.

 

What you could perhaps do, is to build a terrain map on map load. For each height tile, query the bbox_tree for the first object or ground tile you cross when you go vertically down from the height at that tile (or perhaps slightly above that height, start at the actor's knees for instance). Ehmm... well, that still won't work when the actor is more than knee deep ion the water. Oh well, you get the idea.

Water isn't that much of a problem because in that case you would be wanting a water sound anyway.

 

Looking at the map editors forum, I just realised another issue. The edges between different tile types are covered in 2d textures. This might be where my odd sounds are coming from (ie, the underlying tile is actually different to the appearence).

 

This seems like the best idea, but it is definitely something to add *after* the update. I doubt I'd be able to get my head around how to do that in time... let alone finish the rest of it.

 

If anyone is keen to have a go at determining the ground type underfoot, please do. All the interface I need for sounds is to take in is x and y pos as int, and return the number of the ground type. Either we map everything to the ground tiles, and return the int (0 to 254), or we have a base set of ground types (int), and match ground tiles, 2d and 3d objects underfoot against them.

Share this post


Link to post
Share on other sites

From gamewin.c, lines 1110ff

 

actor *me = get_our_actor ();

safe_snprintf((char*)str,sizeof(str),"Coords: %-3i %3i",me->x_tile_pos, me->y_tile_pos);

safe_snprintf((char*)str,sizeof(str),"Coords: %.3g %.3g",me->x_pos, me->y_pos);

 

Maybe that helps ...

 

Coords for IP:

map: 13,17, x/y_tile: 13,17, x/y_pos: 6.5,9

map: 22,179, x/y_tile: 23,179, x/y_pos: 11.5, 89.5

map: 167,168, x/y_tile: 167,168, x/y_pos: 83.5,84

map: 140,79, x/y_tile: 140,79, x/y_pos: 70,39.5

Edited by Florian

Share this post


Link to post
Share on other sites
Maybe that helps ...

It's all good.

 

 

In other news, I am thinking I wouldn't need a seperate thread/timer as the steps processing could be handled with the other actor sounds in update_sounds. I still expect there to be more overhead because you need to check more data (every actor's ground pos), but if the ground position sound types for each x,y coord are loaded into an array on map load, then it would be a trivial matter to recall the sound for each tile, and hence be much faster.

 

... so what this comes down to is I can handle the code to interface to this array, but I don't want to spend time working on building the array as I already have a large workload for this release. So *please* if anyone is interested in this, feel free to have a go!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×