A tool to mirror models (a bit) more easily

Discussion in 'Tutorials & Resources' started by Crowbar, Mar 2, 2019.

  1. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    Mirroring a model usually involves decompiling it, actually flipping in your favorite model editor, and compiling back.

    I've written a tool that tries to automate the middle part of the process by crawling the SMD, no model editors involved.

    Usage screen, there's really nothing more to say:
    upload_2019-3-12_14-29-14.png

    Source code can be found here. If you want to improve it, fix it, or compile it for your system, go ahead.
    I haven't compiled this under anything other than win7 x64, but there's nothing bizarre about it so it should work fine on different systems...

    Binary (single exe archived) attached.
     

    Attached Files:

    • Like Like x 6
    • Thanks Thanks x 3
    Last edited: Mar 12, 2019
  2. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    update 12.03.2019:
    • fixed the bug where it would neglect to include any vertex animation data in the final SMD
    • added -I and -O flags (uppercase) to use stdin and stdout rather than files - ideally usable in a piping environment
    • all output meant to be read by human now goes to stderr
    • improved the usage screen
    The attached file and the link below are of the previous version from 03.03.2019! For the latest version, see the top post!
    source code gist revision
     

    Attached Files:

  3. Khuntza

    aa Khuntza

    Messages:
    134
    Positive Ratings:
    67
    For my latest Mirrored Map I've done something like 20+ mirrored models.. this will definitely save me some time. I'll give it a run in the coming days. Thanks.
     
  4. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    For your sake, make backups on every opportunity
    For mine, feel welcome to report anything that breaks
     
  5. Khuntza

    aa Khuntza

    Messages:
    134
    Positive Ratings:
    67
    I've got a couple of questions actually..

    What is the output model named? I've been using my own standard of appending _mirrored to it. Is this the same or do you put in the name of the file to be produced?

    Also, does it use the existing qc file to compile the new model? I've had issues if I use the same $bbox values from the existing qc and now remove it as part of my process.. is this accounted for?
     
  6. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    See usage - you specify your own name for the output model.
    This only knows of the SMD file, you'll have to manage the rest yourself. The vast majority of models use at least two SMDs - so you're calling the program multiple times. I'd suggest writing a shell script / batch file.
    This program would only be a piece of your workflow - an atomic piece, both in the sense that it does one single thing indivisibly, and in the sense that it must be part of some larger system to be useful.
    I've attempted to make it so that the program reflects the Unix way of writing and using software...

    example workflow:
    - decompile (using other tools)
    - use some script to automate calling this tool
    - possibly automate editing the QCs to remove bounding boxes (also using other tools)
    - compile back (using other tools)...

    Sorry if this disappoints you.
     
    • Thanks Thanks x 1
    Last edited: Mar 12, 2019
  7. Khuntza

    aa Khuntza

    Messages:
    134
    Positive Ratings:
    67
    Fair enough.. I currently decompile, load the model into Blender using the qc file, flip it in three clicks then export all SMD files at once, edit the old qc, then recompile. I currently turn around a mirrored model in under 5 mins but I would also say I have a need for them more than anyone else and have gotten quite efficient at doing them.

    If my understanding is correct this tool would simply be a command line replacement for what I do in Blender but I'd have to run this tool multiple times, once for each SMD from the original model.

    Regardless, I'll give the tool a go and report back once I know if it's more efficient in my workflow.
     
    • Agree Agree x 1
  8. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    Your understanding is correct. Your Blender workflow is very impressive, and if you call the program manually I think it can never be as efficient as that, kudos to you
    However, I believe there is potential for speeding it up by writing a script that seeks all SMD files in a directory, and calls the program for them, which would get you: copy to folder - run script - proceed to edit the QC, etc."
    But if you're devoted, you may write a script that does the whole thing for you (likely, the decompiling tools have a commandline interface under the hood that you can use).

    I really want to say I'm open to obsolescence. If this doesn't turn out to have the potential to be as efficient as it gets, and Blender does, you go ahead and write a guide - that's my vision.
     
    • Like Like x 1
  9. Khuntza

    aa Khuntza

    Messages:
    134
    Positive Ratings:
    67
    Im far from dissapointed and I dont want to trash your work at all.. I can barely write a PowerShell script, so I find your code quite impressive.

    Previously I was using 3DS Max and it was quite difficult for me. I had to mirror each SMD individually. This would have been a godsend.

    The SMD tools for Blender allow importing of all files in a model via the QC. This means I now mirror once and export all the mirrored files to a directory for easy recompiling.

    I think there is potential for your tool if it could do the whole process end to end.. decompile > recompile. I think you've probably solved the hardest part already.

    I thought from your username you must have been associated with the Crowbar application but perhaps not? It would be great to see your tool integrated with theirs as a possible new feature.

    I hadn't intended on doing a tutorial on model mirroring, but I could if demand is there. I do however intend on putting together a pack of all the props, skyboxes and particles I've built up from doing the mirrored maps.
     
    • Like Like x 1
  10. Crowbar

    aa Crowbar

    Messages:
    1,446
    Positive Ratings:
    1,230
    Haha, in no way except that I have a lot of respect for that tool and ZeqMacaw.

    On integration, it kinda inherently is? When you decompile and recompile it's Crowbar decompiler -> QC editing -> Crowbar wrapping around studiomdl, and when you introduce a tool like this it becomes Crowbar decompiler -> model flipper -> QC editing -> Crowbar again, so no change to any individual tool is required.

    I want to mention CompilePal, which aims to automate the map compiling process entirely - and it has the interface to run system commands, in particular, launch any executable you want with given parameters, so one may, for instance, write a VMF crawler that would look for problems before giving the map to VBSP.
    The fact that this can be done is why I think it's great to have such atomicity in tools (and support a text text interface, which is a universal format) and not force a GUI on anything.

    Not to lie, now I'm thinking of making something bigger that would automate it on a larger scale, but I'm not sure if I have the time or experience to deliver quality right now. (Here's reminding that this particular thing's source is open and anyone can go ahead. Besides, I'm pretty sure the quantity of text I've written in this thread now exceeds the source code of the actual tool in question... but this is a great topic to have views on)
     
    • Like Like x 1
  11. ϺΞΤЯΘΉλϺ

    ϺΞΤЯΘΉλϺ L3: Member

    Messages:
    125
    Positive Ratings:
    94
    oo this looks cool, nice job mate:)