oganm / dd2vtt_importer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with the y-coordinates lining up properly (being too high up)

Elacim opened this issue · comments

Hey, I've been messing about with your tool and I think I've discovered a bug.
image
When I import a map, the x-offset is set perfect, but the y-offset is off by a considerable amount (a few map tiles off). I've messed with the output ppi and different map sizes and all but one seem to line up as well as your test.dd2vtt project. The exception is test_map_20x20_64ppi.dd2vtt, which matches the test.dd2vtt ppi and map size.
I've also attempted fixing it by tinkering with the convert_coords() function in util.gd and I can get everything to line up if I change the y-offset of /2 to something else, (vect.y*resolution.pixels_per_grid -resolution.map_size.x*resolution.pixels_per_grid/2)) but I have to do it on a map-by-map basis. I'm unsure of how to make it more dynamic, but I believe that that may be the problem area.
I've attached the dungeondraft files, dd2vtt files, and the project.godot I've been trying it out with so you can try reproducing it.
test-maps.zip
Trying-out_dd2vtt.zip
.

Oh, I found the issue!

func convert_coords(vect: Vector2, resolution: Dictionary)->Vector2:
	return Vector2(vect.x*resolution.pixels_per_grid -resolution.map_size.x*resolution.pixels_per_grid/2,
		      vect.y*resolution.pixels_per_grid -resolution.map_size.x*resolution.pixels_per_grid/2)

should be

func convert_coords(vect: Vector2, resolution: Dictionary)->Vector2:
	return Vector2(vect.x*resolution.pixels_per_grid -resolution.map_size.x*resolution.pixels_per_grid/2,
		      vect.y*resolution.pixels_per_grid -resolution.map_size.y*resolution.pixels_per_grid/2)

There's a typo in the vector y (-resolution.map_size.x should be resolution.map_size.y).
I tested this fix with all the files a supplied and it worked with everyone of them except the test_cropped.dd2vtt.
This is a whole 'nother can of worms.
I noticed that the map origin is different in test_cropped, so I tried resetting it to 0 0, but that didn't seem to fix it. I think cropping the map in dungeondraft causes it to not align properly but I can't find the cause of this. I've tried editing the map_origin, map_size, and the pixels_per_grid, but only pixels_per_grid seems to make a visible change (changes scale).

Oh dear.. didn't realize the origin could shift between files. As long as this is not a general failure of everything that imports these files the information should be available in the files I assume. Will take a better look at what's going on

A proper description of the file format. Not sure if there is a primary source

https://arkenforge.com/universal-vtt-files/