Porting hammer maps to unity

Discussion in 'Mapping Questions & Discussion' started by Simulacron, Nov 25, 2016.

  1. Simulacron

    Simulacron L6: Sharp Member

    Messages:
    299
    Positive Ratings:
    151
    At the moment I'm experimenting with unity and I just wanted to know if it's possible to port source maps to unity. And if it is possible, how does it works?
    Thanks for your help!
     
  2. Idolon

    aa Idolon the worst admin

    Messages:
    1,525
    Positive Ratings:
    4,334
    You have two options:

    1) Create/find a .vmf importer. WallWorm might be worth looking into, though I'm not that familiar with what it can do.

    2) Use Hammer's ".DXF Export" option to export to .dxf, which Unity knows. However, I'm not sure how much data this actually transfers, so you might not be able to import entities this way (should you want to).

    Note that Source is designed to cull extra faces on compile, so importing a raw map file means you'll have to do the face culling yourself (or just deal with bad performance). You can probably write a script to cull faces that have nodraw as their texture, but you'll still have to be careful with your texture usage in Hammer.
     
    • Agree Agree x 2
    • Thanks Thanks x 1
  3. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    Go via UE4 and use HammUEr - http://hammuer.nte.be/

    HammUEr will batch export materials and props as well as bsp level geometry. If you're starting a project you might just want to consider staying in UE4, but if you definitely want to use Unity then taking the geo and materials from UE4 to Unity shouldn't be too difficult as most of the legwork has been done by HammUEr since UE4 and Unity's requirements for stuff is fairly similar

    Note: I haven't actually used this
     
    • Thanks Thanks x 2
  4. Simulacron

    Simulacron L6: Sharp Member

    Messages:
    299
    Positive Ratings:
    151
    So I quickly tried out the .DXF export. It only works partial. I used one of my maps to try it out. It seems like the all brushes get converted including clip brushes, skybox etc. However, they doesn't seem to have a collision mask, because I fall staraight throug. Textures get also removed completly. Hope I could help somebody else with this quick summary and thanks again for your help!
     
  5. Idolon

    aa Idolon the worst admin

    Messages:
    1,525
    Positive Ratings:
    4,334
    DXF export just spits out all of the geometry with no regard for what's supposed to be "real" or not, since that's handled by the compile tools.

    Unity handles collisions and texturing differently than Source does. I don't know what kind of data gets saved in the DXF, but if UV data isn't saved, you might want to look into writing your own .vmf importer or getting HammUEr.
     
    • Thanks Thanks x 1
  6. Crash

    aa Crash func_nerd

    Messages:
    3,149
    Positive Ratings:
    4,750
    I work with HammUEr often, it's a great tool.
     
    • Thanks Thanks x 1
  7. henke37

    aa henke37

    Messages:
    1,879
    Positive Ratings:
    442
    From my limited experience with unity, I worry that you might run into issues that PVS solved. It depends on the exact workings of the converter of course, but it is certainly something to keep in mind.
     
  8. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    Seems like you don't really know how to use Unity yet, I'd recommend getting to know Unity a bit better before trying to port from source to Unity. Jumping in at the deep end isn't always the best way to learn.

    Anyway:
    Hammer's DXF export exports /everything/ so if you only want regular visible geo, you'll have to remove everything else from the vmf before exporting. It'll export the backs of displacement brushes too so those need to be removed afterwards. I dunno if it's Hammer's export or 3DSMax's import but in that pipeline normals get flipped so you'll need to flip them back.

    If you want anything to be solid in unity you need to give it a collider. As far as textures I thiiiiiiink the dxf export keeps the UVs that they have in Hammer but I might be totally wrong, either way you'll need to manually convert the materials into something Unity can use, that means saving textures as png/tga and creating materials in unity.

    Several of these things are why I recommended HammUEr, it will batch convert materials, can ignore various tool brushes and nodraw faces, and can export props as well as geometry. It'd be nice if there was a Source->Unity version, but Source->UE4->Unity is at least manageable