Shpuld

Map Scaling Script

19 posts in this topic

I made this short script for scaling maps in Python 3. It can scale maps individually on each axis.

This can be useful if you for example wanna test things out in your maps in a bit different scale.

 

NOTE: The maps won't be fun to edit afterwards because things are bound to get off grid when scaling recklessy like this.

 

EDIT: I made a very simple GUI for this thing, it lets you browse for the file you wanna scale and do all the other functionality with buttons and text fields instead as well.

Here's a screenshot of it:

 

lLdakZj.png

 

 

Usage:

 

-Make sure you have Python 3.x on your computer to run the script

-Download the python script here:

https://www.dropbox.com/s/azq6adtd51uhkxm/reflex_mapscaler.py?dl=0

-Select the map you want to be scaled as the input file.

-Edit the scale factors to whatever you want, remember that in Reflex Y-axis is for up and down.

-Type in the name for the new .map file you want to create, you can leave the ".map" extension out if you want, it will be added automatically

-As the GUI tells you, the new map will be placed in the same directory where the input file was found.

-Press "Scale Map" when you're ready, it should tell you if something was wrong with the input values or if the operation succeeded.

 

Screenshots of the effects on Shpdm3.map

 

Scale factors: "0.5, 0.5, 0.5"

https://www.dropbox.com/s/3v3vmabhb32fmgm/Screenshot%202014-11-14%2000.31.08.png?dl=0

 

Scale factors: "1.5, 1.5, 0.5"

https://www.dropbox.com/s/7c65mxxoli93qhg/Screenshot%202014-11-14%2000.44.07.png?dl=0

 

Scale factors: "2, 0.5, 2"

https://www.dropbox.com/s/13nonhxtbxb1z12/Screenshot%202014-11-14%2000.49.08.png?dl=0

Share this post


Link to post
Share on other sites

great work I would love to see more scripts like this, maybe for merging maps, color theming, and other stuff that isnt built into the editor yet

Share this post


Link to post
Share on other sites

do you think it would be possible to write a script that will texture the whole map with nolight material? I would just go find and replace all if the editor will give some texture at the start problem it its none...

Share this post


Link to post
Share on other sites

Shpuld,

even though I do not really see the use of rescaling a map, because if you do have to, the level designer messed up so badly there is pretty much no hope for the map to begin with. But... technically your work is ground breaking, because it means maps can be manipulated. So great job.

 

This brings up an interesting point in general... modding the editor... coming from playing Skyrim extensively with their huge mod community, and also from GTKradiant, a way to "officially" add external tools seamlessly into the editor/game would be great.

 

Application for an external tool used under Q3A was Mirix... this tool could mirror halves of e.g. CTF maps, to fix the textures in the mirror and even the lighting (e.g. change red lights to blue), and the orientation of entities e.g. the spawns... just as a thought.

 

Brush source format explained?

 

As that may be, would you be so kind as to pick the source of one brush, and explain what the various numbers in the .map source stand for? I am sure your experimenting has helped you understand very well how the Reflex format works. Thank you.

 

And again, great job.

Share this post


Link to post
Share on other sites

Shpuld,

even though I do not really see the use of rescaling a map, because if you do have to, the level designer messed up so badly there is pretty much no hope for the map to begin with.

 

 

In my case I made a remake of the classic dm4; I knew it wouldn't work at 1:1 scale, ran some quick tests and decided on 3:2; once I had finished we discovered that this was too large and rescaled it to 9:8 using Shpuld's very helpful script, and this scale worked very well and resulted in a remake that played very well also.  Kovaak has also nearly completed a remake of the original aerowalk at 1:1 scale, but at this scale you can circle jump straight to red from the top of the stairs, if he decides this is something worth fixing then the map scaling script is one option that could come in very handily.

Share this post


Link to post
Share on other sites

Yo guys, haven't been checking out this forum in a while.

 

AEon: The .map format in reflex is super simple and making new scripts like this wouldn't be too much work. I'd imagine the devs themselves will be incorporating features like this in the official editor when they have more time.

Perhaps they will make an interface for external tools as well as you mentioned them. Kinda like blender uses python for scripts/addons. Would be really handy.

 

Quick explanation of .map format (sample is from a build 22 map, I guess it's exactly the same for the current build as well, can't confirm atm):

 

 

reflex map version 6
entity
    type WorldSpawn
    ColourXRGB32 clearColor b4dcff
    ColourXRGB32 worldColor0 0
    ColourXRGB32 worldColor1 0

Just the "header", important stuff on the first line, don't modify.

Then there's the entity block for worldspawn, contains the colors that you can set in the editor as well.

 

 

brush
    vertices
        144.000000 32.000000 192.000000
        176.000000 64.000000 192.000000
        176.000000 64.000000 -128.000000
        144.000000 -64.000000 -128.000000
        144.000000 32.000000 -128.000000
        176.000000 -64.000000 192.000000
        176.000000 -64.000000 -128.000000
        144.000000 -64.000000 192.000000
    faces
        0.000000 0.000000 1.000000 1.000000 0.000000 0 1 2 4 structural/dev/dev_grey128
        0.000000 0.000000 1.000000 1.000000 0.000000 3 4 2 6 internal/editor/textures/editor_nolight
        0.000000 0.000000 1.000000 1.000000 0.000000 2 1 5 6 internal/editor/textures/editor_nolight
        0.000000 0.000000 1.000000 1.000000 0.000000 0 4 3 7 structural/dev/dev_grey128
        0.000000 0.000000 1.000000 1.000000 0.000000 5 1 0 7 internal/editor/textures/editor_nolight
        0.000000 0.000000 1.000000 1.000000 0.000000 3 6 5 7 internal/editor/textures/editor_nolight

A normal brush block, notice how indents are used to show where a block is. Vertices are defined with XYZ coords as expected, and the order of them matters. First vertex in a brush will be 0, next will be 1, etc...

Faces are defined by various attributes for the texture/surface first, first 2 numbers are U and V offset for the texture (writing this out of memory, so I'm not 100% sure), the next 2 numbers are UV scaling, the 5th number is the rotation.

Then we have the vertex indices (first defined vertex in this brush is 0 etc...) that will be used for this face. THE ORDER OF THE INDICES FOR A FACE IS CRUCIAL. They have to be counter-clockwise when watching the face from outside (face normal pointing at you). The brush will be invalid if the vertices aren't in a proper order for a single face. You can't have one face that has its normal pointed inside for example.

I'm pretty sure you can't have faces with more verts than 4, but a developer needs to confirm this.

The last field for a face is, of course, the material. Nothing really to say about this.

 

Entities have a bit varying fileds, the first field for them seems to always be "type *", and that determines what else they need. I recommend you make a test map with all kinds of different ents and then open the .map file with your favorite text editor and see how they work yourself.

 

tehace: I actually made a nolight material replacer script for a friend already, but it's kinda WIP (only replaces unassigned materials with nl) and a simple notepad find+replace does the same thing better at the moment...

Bonuspunkt likes this

Share this post


Link to post
Share on other sites
I'm pretty sure you can't have faces with more verts than 4, but a developer needs to confirm this.

 

chronokun's converter lets you create e.g. 16-sided cylinders, their caps are one face... so faces with more vertices are actually supported. I have just looked into the source of such a cylinder:

brush
    vertices
        -1664.000000 352.000000 1288.000000
        -1681.000000 352.000000 1285.000000
        -1694.000000 352.000000 1278.000000
        -1701.000000 352.000000 1265.000000
        -1704.000000 352.000000 1248.000000
        -1701.000000 352.000000 1231.000000
        -1694.000000 352.000000 1218.000000
        -1681.000000 352.000000 1211.000000
        -1664.000000 352.000000 1208.000000
        -1647.000000 352.000000 1211.000000
        -1634.000000 352.000000 1218.000000
        -1627.000000 352.000000 1231.000000
        -1624.000000 352.000000 1248.000000
        -1627.000000 352.000000 1265.000000
        -1634.000000 352.000000 1278.000000
        -1647.000000 352.000000 1285.000000
        -1634.000000 384.000000 1278.000000
        -1627.000000 384.000000 1265.000000
        -1624.000000 384.000000 1248.000000
        -1627.000000 384.000000 1231.000000
        -1634.000000 384.000000 1218.000000
        -1647.000000 384.000000 1211.000000
        -1664.000000 384.000000 1208.000000
        -1681.000000 384.000000 1211.000000
        -1694.000000 384.000000 1218.000000
        -1701.000000 384.000000 1231.000000
        -1704.000000 384.000000 1248.000000
        -1701.000000 384.000000 1265.000000
        -1694.000000 384.000000 1278.000000
        -1681.000000 384.000000 1285.000000
        -1664.000000 384.000000 1288.000000
        -1647.000000 384.000000 1285.000000
    faces
        0.000000 0.000000 0.500000 0.500000 0.000000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 structural/dev/dev_nogrid_grey128
        0.000000 0.000000 0.500000 0.500000 0.000000 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 structural/dev/dev_red
        0.000000 0.000000 0.500000 0.500000 0.000000 31 30 0 15 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 12 18 17 13 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 14 16 31 15 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 17 16 14 13 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 30 29 1 0 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 27 26 4 3 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 29 28 2 1 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 2 28 27 3 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 5 25 24 6 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 24 23 7 6 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 26 25 5 4 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 23 22 8 7 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 20 19 11 10 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 9 21 20 10 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 11 19 18 12 internal/editor/textures/editor_nolight
        0.000000 0.000000 0.500000 0.500000 0.000000 22 21 9 8 internal/editor/textures/editor_nolight

The dev_red line is the top cap of the cylinder, one face. My cylinder in AEtimeR is surrounded by a ring, thus only the top and bottom caps have a proper textures, the sides are all nolight.

 

Just mentioned the info, if case you are interested.

 

I pretty much did already understand how the format is "supposed to work", but having it verified in detail, if of course very much better.

Share this post


Link to post
Share on other sites

tehace: I actually made a nolight material replacer script for a friend already, but it's kinda WIP (only replaces unassigned materials with nl) and a simple notepad find+replace does the same thing better at the moment...

 

how does this work? I have no problem changing the colours of already assigned materials with notepad++ and find/replace but whenever I create a brush it have no materials assigned to it therefore I cant replace something that doesnt exist :)

Share this post


Link to post
Share on other sites

In UltraEdit I would use regular expressions in search/replace, to e.g. match "# # # # n", i.e. any 4 index numbers followed by an empty material at the end of the line. Or something along those lines. But as you say, not quite so trivial from a normal editor. I have notepad++ installed as well, but rarely use it... don't recall if it had regular expressions or not.

Share this post


Link to post
Share on other sites

Nice script.

Is there any script/way to "inject" (copy paste) custom brush/verticles/faces into map
I don't want to convert my map from reflex 6 to radiant format, but i want to add some new stuff from radiant to it

Thanks

Share this post


Link to post
Share on other sites
On 2015-05-18 at 0:31 PM, Soulmarine said:

Nice script.

Is there any script/way to "inject" (copy paste) custom brush/verticles/faces into map
I don't want to convert my map from reflex 6 to radiant format, but i want to add some new stuff from radiant to it

Thanks

The .map file is just text, you can open it in a text editor and copy paste stuff. What I do is make stuff into a prefab then cut/paste the prefab so I know im only getting what I want. Just make sure that your prefab is before the "global" in the map file and obviously make a backup before fiddling with it. Not sure how well this would work with a v6 map.

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