StRiKeR Posted February 4, 2016 I'm working on a wad tool written in Python.Mainly to pursue my interest in the architecture of the WAD format. Secondly, to increase my programming skills. I've parsed the infotable and I am attempting to display E1M1's VERTEXES/LINEDEFS.However, I don't know how to map a point whose X and Y coords in the level are say X:-1088 Y:3060 to a screen. Whose top-left is 0,0. How is this mapped? Is some geometric function needed? I think I need to find the center of the map in the level to reference against the center of my canvas to map the cords? Thanks in advance.. 0 Share this post Link to post
Linguica Posted February 4, 2016 Here's an example: https://github.com/devinacker/omgifol/blob/master/demo/drawmaps.py 0 Share this post Link to post
StRiKeR Posted February 4, 2016 Linguica said:Here's an example: https://github.com/devinacker/omgifol/blob/master/demo/drawmaps.py Thanks. Omgifol is a complicated library to me right now. It's structure isn't clear to me. He's importing a lot of his other modules.. 0 Share this post Link to post
scifista42 Posted February 4, 2016 I'm not familiar with Python syntax, so I'll just describe principles. While loading vertexes, remember the very lowest x coordinate there is in the whole map and story it in a variable called for example "minX", same for the very highest x coordinate (maxX), and very lowest + very highest y coordinates too (minY, maxY). Now, assuming you want the entire map to fit onto the canvas, define a scale factor (a floating point number) like this:scale = min(canvasWidth/(maxX-minX),canvasHeight/(maxY-minY));Where "canvasWidth" and "canvasHeight" are self-explanatory, and the function "min" kind of too (it returns the lesser one of the 2 parameters passed to it). Now for each vertex ("v"), assuming it already has "x" and "y" properties loaded from the map's VERTEXES, compute "canvasX" and "canvasY" coordinates like this:v.canvasX = (v.x-minX)*scale; v.canvasY = (v.y-minY)*scale;(EDIT: Ninjaed by Linguica.) 0 Share this post Link to post
StRiKeR Posted February 4, 2016 scifista42 said:I'm not familiar with Python syntax, so I'll just describe principles. While loading vertexes, remember the very lowest x coordinate there is in the whole map and story it in a variable called for example "minX", same for the very highest x coordinate (maxX), and very lowest + very highest y coordinates too (minY, maxY). Now, assuming you want the entire map to fit onto the canvas, define a scale factor (a floating point number) like this:scale = min(canvasWidth/(maxX-minX),canvasHeight/(maxY-minY));Where "canvasWidth" and "canvasHeight" are self-explanatory, and the function "min" kind of too (it returns the lesser one of the 2 parameters passed to it). Now for each vertex ("v"), assuming it already has "x" and "y" properties loaded from the map's VERTEXES, compute "canvasX" and "canvasY" coordinates like this:v.canvasX = (v.x-minX)*scale; v.canvasY = (v.y-minY)*scale;(EDIT: Ninjaed by Linguica.) With what you've explained to me, the Python code makes sense now! Thanks guys! 0 Share this post Link to post