Blender DAE Exporter for HWRM

(D Kesserich) #1

Continuing the discussion from What can we use to open the example ships .DAEs?:

I figured it might be a good idea to separate out a topic to focus purely on getting Blender to output DAEs that HODOR won’t choke on.

As I said in the original topic, I’ve had some success using the Better Collada Exporter (BCE) script, but it’s far from perfect. Luckily, since it’s open source and it’s Python, it’s easy enough to adjust to try and fix it. To that end, I’ve forked BCE into the Better Collada Exporter: HW Edition, and thrown it onto GitHub right here.

So far what I’ve figured out is that the mesh id, material id, effect id, and image id fields that the original BCE was producing were totally wrong for HODOR, and would generate a ton of Geo Instance Not Found errors. I seem to have fixed that for meshes (at the very least, HODOR isn’t displaying any errors), but materials, effects, and images still may be problematic? Also the library materials block is going after the library effects block, which is not how the example ships have it.

If anyone wants to take a look at what’s there and contribute, that would be awesome.

[TUTORIAL] Blender - Getting a simple ship in game
[TUTORIAL] Blender - MAD Animations
Beyond Confused (How do I get HODOR?)
[TOOL] Blender HWRM Toolkit - Cube Maps!
[TOOL] Blender HWRM Toolkit
Modding tutorials Master Thread
(Sastrei) #2

You rock! Also, the library order may not be critical. I’ve succesfully turned a few dae’s into hod’s now and their library order was funky different from the examples.

(D Kesserich) #3

I’ve updated the script so now all the IDs are (I think) correct. HODOR still doesn’t like the materials, though. Also I noticed that there’s something wrong with the geometry, since the HOD it’s creating is significantly smaller than the HOD created after re-saving the DAE in Visual Studio (which will remove all the texture references, so HODOR builds a HOD with no materials. Also if I cut and paste the images, materials, and effects blocks out of the original and into the new one, HODOR will do the materials processing, but the hod is about 300kb smaller than one generated from the original DAE).

I’ve uploaded a handful of my DAE results to Google Drive here, for comparisons. Any help or assistance that anyone could give would be awesome, because file import/export alone is well outside my programming bailiwick, and adding 3D on top of that is largely headexplodes.

(D Kesserich) #4

This is getting frustrating. It feels like the more the output looks like the original, the less HODOR likes it.

The DAE output from the version of the plugin I just pushed to GitHub will make HODOR straight up crash, but the library materials, library effects, and library meshes blocks now look almost exactly like the original example (there are some unavoidable differences, like Blender can’t do alpha in Vertex Colors, and when I changed the “offset” values for the mesh data types in the block so they matched the example, it completely broke the triangle build order.) I feel like it’s still probably something materials related. Visual Studio is still able to parse it into the model viewer.

@BitVenom: I’ve uploaded the ShipTest-HODOR Crasher.dae to the Google Drive folder linked in the previous post. If you have the time to take a look I’d really appreciate it. I know you said in the other thread that you wanted raw data collection.

(BitVenom) #5

Absolutely! After the hard crunch that was getting this project and the first few patches out the door, I am taking some ‘major personal stuff’ time until early next week. That doesn’t mean I won’t look at this until then - I am a sort of constant workaholic/tinkerer - but I can’t commit either way.

I am planning a HODOR update very soon (file format is getting a bit of a re-rub, some bugfixes) - so if I find anything that I can take into account when parsing, I will.

(D Kesserich) #6


It turns out the reason the materials weren’t building was because I’d messed up some of the texture assignments in the materials (LOD1 and LOD2 had all three textures (diffuse, glow, spec) assigned to diffuse). Sorted that out and now the materials build off of my export! HOORAY!

HODOR still crashes when it gets to the mesh, though. I think it’s something to do with the material assignments within the mesh data missing a couple of the Maya method parameters. I’ll try figuring that out tomorrow.

(Sastrei) #7

Are you using nodes or regular materials for your experiments? They may result in different material assignment code on export.

(BitVenom) #8

I may have a bunch of hours to look into this later tonight - so PM me links to busted files (and info on what’s been done) and I can (probably) look. I am mostly away until Monday afternoon though :frowning:

(D Kesserich) #9

All Blender Internal, no nodes. I don’t think the script can handle nodes at all.

The export script originally was using a Blinn shader (hard-coded into the script) with a FCOLLADA technique profile, so I changed that to Phong and the MAYA technique profile, but (based on comparison with the original DAEs) I overlooked a couple of shader parameters that the script wasn’t set up to pull at all, so I need to add that in.

@BitVenom: Sent you a PM.

(Xercodo) #10

I’m watching this thread SO HARD right now

(D Kesserich) #11


DAE->HOD: Creating Homeworld2 Multi Mesh File - Version 512
DAE->HOD: Creating STAT[Kad_Swarmer_autogen_1] with Shader[ship]
-- Building LMIP[Kad_Swarmer_DIFF] for Param[$diffuse] (2048x2048 - 8888)
-- Building LMIP[Kad_Swarmer_GLOW] for Param[$glow] (2048x2048 - 8888)
-- Building LMIP[Kad_Swarmer_TEAM] for Param[$team] (2048x2048 - 8888)
-- Building LMIP[Kad_Swarmer_NORM] for Param[$normal] (2048x2048 - 8888)
DAE->HOD: Creating STAT[Kad_Swarmer_autogen_3] with Shader[ship]
DAE->HOD: Creating STAT[Kad_Swarmer_autogen_2] with Shader[ship]
DAE->HOD: Creating STAT[Kad_Swarmer] with Shader[ship]
DAE->HOD: Creating STAT[Kad_SwarmerThruster] with Shader[thruster]
-- Building LMIP[Kad_SwarmerEngine_DIFF] for Param[$diffuseOn] (512x1024 - 8888)

-- Building LMIP[Kad_SwarmerEngine_DIFX] for Param[$diffuseOff] (512x1024 - 8888
-- Building LMIP[Kad_SwarmerEngine_GLOW] for Param[$glowOn] (512x1024 - 8888)
-- Building LMIP[Kad_SwarmerEngine_GLOX] for Param[$glowOff] (512x1024 - 8888)
-- Building LMIP[Kad_SwarmerEngine_NORM] for Param[$normal] (512x1024 - 8888)
DAE->HOD: Generating Scene Data LOD[0]
DAE->HOD: Generating Scene Data LOD[1]
DAE->HOD: Generating Scene Data LOD[2]
DAE->HOD: Generating Scene Data LOD[3]
DAE->HOD: Generating Collision Meshes
DAE->HOD: Generating Animation Channels

IT WORKS! IT WORKS IT WORKS! (I think… I still have to get it into game. Is there a step by step guide anywhere for that? I never really took part in Homeworld 2 or OG Homeworld modding, so I don’t know what all is required in a loose file mod re:replacing a ship with another ship).

All it needed was the Reflective params.

The HOD it generated is 9kb larger than the HOD generated from the original DAE. Not sure why, though the DAE’s the plug-in generates have always been significantly larger than the original. There’s probably a whole ton of unnecessary stuff that’s being added into the DAE that I don’t really want to worry about stripping out if I don’t have to.

Updated version of the script is pushed to the GitHub repo in the first post. Couple notes about using it: You have to manually triangulate your mesh, and tick the Triangulate box in the exporter settings. Also be sure to tick ‘Animations.’ I’ll update the to have those options on by default later (and maybe see about adding some scaling options and unit names. It’s all 1.0 scale Meters right now.)

(Sastrei) #12

I did it old school and created a shortcut with the following target path:
“C:\Program Files (x86)\Steam\steamapps\common\Homeworld\HomeworldRM\Bin\Release\HomeworldRM.exe” -mpbeta -overrideBigFile

Place your ship hod into an appropriately named folder under Data > Ship

Make sure you have a .events and .ship file with a matching name. Just grab one of the other ships .event and .ship files and in the .ship file, comment out all the weapon and engine lines near the bottom.

Edit your startingfleets.lua under Scripts > Startingfleets to add your new test ship to the skirmish start fleet.

Also if you want to post the hod, I’ll toss it ingame real quick. :smiley:

(D Kesserich) #13

Like I said, I’ve never done it old school or new school, so most of that is gibberish to me.

I take it I have to unpack the HW1Ships.big to get the .event, ship, and startingfleets.lua files? How do I do that? I ran the big decrypter, but archive.exe just gives me a failed to initialize archive error when I try to run it

[edit]Figured it out. AND IT REALLY WORKS

I intentionally stretched out the swarmer’s sides to prove that it’s actually what I exported from Blender and not me accidentally using the HOD that I generated from the original DAE for comparison purposes.

So now the trick is going to be building a ship from scratch…

(D Kesserich) #14

A couple of notes: For reasons that I haven’t been able to figure out yet, sometimes Blender will crash when doing the export after loading a saved Blend file. It seems to be material related, as appending the objects into a new file and rebuilding the materials seems to fix it.

HODOR really doesn’t like relative image paths that don’t lead to the same folder as the DAE is saved in. Make sure you’re saving the DAE into the same folder as all your textures, or vice versa. Ran into this when testing with the Turanic Carrier.

(Xercodo) #15

I can;t get Blender to import the DAEs given to us for the example

What do? D:

(BitVenom) #16

HECK YEAH MAN (I can’t swear, doh… it just turns into little dots…)!!!

Great job. I’ll still dig into your DAE and see if I can ‘harden’ HODOR to bad/odd inputs though.

But still - really, really amazing work!

(D Kesserich) #17

As writing a new importer would have to be done from scratch and is beyond my abilities, you’ll have to convert them into FBXs with Visual Studio (the Community Edition is full featured and free). Then import the FBX into Blender. Be sure to set the scale to 100 when importing.

After that you’ll have to re-set up all the textures, which is kind of a pain.

Getting Homeworld Remastered Ships into Blender
(Xercodo) #18

How does that work? I been using VS for code dev stuff but never knew it could do that lol.

(Sastrei) #19

@DKesserich YOU ROCK!!! :smiley:

(D Kesserich) #20

Stumbled onto a problem with the script: Weapons don’t work. Looks like it’s an issue with the way animations are exported (the stupid id generator function of the original exporter strikes again), and I’m having a hell of a time parsing the damn thing to figure out how to fix it.

More as it develops…