Program G1CO import/export addon for blender

AlexXsWx

Active Member
I wrote an addon for blender to import and export majority of .g1co files:

https://www.mediafire.com/file/bjo1942wbdh0069/io_scene_g1co.zip/file ( [mirror] )

I developed it using blender v2.91.0, Revan says it's working in v3.3.

This allows to mod stage collisions, for example.

Note that out of 1588 g1co files in latest FieldEditor4.rdb, 1+18+196 files (~13.5%) are of a subtype different than "HVB_2" (aka "bounding volume hierarchy") and are not supported by this addon:

1 file is of subtype 3 ([S0102PIR_set-pir-bag-roll-a01_phys].g1co )
0x9F7E1091.g1co
[S0101PIR_set-pir-bag-a01_phys].g1co
[S0102PIR_set-pir-bag-a01_phys].g1co
[S0201BST_KVS_set-bst-goods-sofa-a01_phys].g1co
[S0201BST_KVS_set-bst-goods-sofa-after_phys].g1co
[S0201BST_KVS_set-bst-trash-dumpster-a01_phys].g1co
[S0201BST_KVS_set-bst-trash-dumpster-a02_phys].g1co
[S0201BST_KVS_set-bst-trash-dumpster-a03_phys].g1co
[S0399CRM_set-cri-basket-b_phys].g1co
[S0399CRM_set-cri-basket-c_phys].g1co
[S0399CRM_set-cri-chair-a_phys].g1co
[S0399CRM_set-cri-chair-b_phys].g1co
[S0399CRM_set-cri-desk-a_phys].g1co
[S0399CRM_set-cri-drum-a01_phys].g1co
[S0399CRM_set-cri-drum-a02_phys].g1co
[S0399CRM_set-cri-drum-a03_phys].g1co
[S0399CRM_set-cri-fence-e01_phys].g1co
[S0399CRM_set-cri-polytank-a_phys].g1co
[S0101PIR_set-kinematics-physics-col-box_phys].g1co
[S0101PIR_set-pir-box-rope-a01_phys].g1co
[S0101PIR_set-pir-box-t-a01_phys].g1co
[S0101PIR_set-pir-box-w-des-stack3-a01_phys].g1co
[S0101PIR_set-pir-des-barrel-p-stack3-a01_phys].g1co
[S0101PIR_set-pir-des-barrel-w-a01_phys].g1co
[S0101PIR_set-pir-des-box-w-a01_phys].g1co
[S0101PIR_set-S0101PIR-pship-floor-col-a02_phys].g1co
[S0101PIR_set-s0101-phycol-a01_phys].g1co
[S0101PIR_set-s0101-phycol-a02_phys].g1co
[S0101PIR_set-s0101-phycol-a03_phys].g1co
[S0101PIR_set-s0101-phycol-a04_phys].g1co
[S0101PIR_set-s0101-phycol-a05_phys].g1co
[S0101PIR_set-s0101-phycol-a06_phys].g1co
[S0101PIR_set-s0101-phycol-a07_phys].g1co
[S0101PIR_set-s0101-phycol-a08_phys].g1co
[S0101PIR_set-s0101-phycol-a09_phys].g1co
[S0101PIR_set-s0101-phycol-a10_phys].g1co
[S0101PIR_set-s0101-phycol-a11_phys].g1co
[S0101PIR_set-s0101-phycol-a12_phys].g1co
[S0101PIR_set-s0101-phycol-a13_phys].g1co
[S0101PIR_set-s0101-phycol-a14_phys].g1co
[S0101PIR_set-s0101-phycol-a15_phys].g1co
[S0101PIR_set-s0101-phycol-a16_phys].g1co
[S0101PIR_set-s0101-phycol-a17_phys].g1co
[S0102PIR_set-kinematics-physics-col-box_phys].g1co
[S0102PIR_set-pir-bag-white-a01_phys].g1co
[S0102PIR_set-pir-box-cannonball-a01_phys].g1co
[S0102PIR_set-pir-box-net-a01_phys].g1co
[S0102PIR_set-pir-box-net-a02_phys].g1co
[S0102PIR_set-pir-box-net-a03_phys].g1co
[S0102PIR_set-pir-box-rope-a01_phys].g1co
[S0102PIR_set-pir-box-w-a02-brk_phys].g1co
[S0102PIR_set-pir-des-barrel-p-a01_phys].g1co
[S0102PIR_set-pir-des-barrel-w-a01-nomoss_phys].g1co
[S0102PIR_set-pir-des-box-w-a01-nomoss_phys].g1co
[S0102PIR_set-pir-des-box-w-a02_phys].g1co
[S0102PIR_set-pir-des-gpowder-barrel-gmk-a01_phys].g1co
[S0102PIR_set-ship-houmotuko-floor-col-a01_phys].g1co
[S0199PIR_set-kinematics-physics-col-box_phys].g1co
[S0199PIR_set-pir-des-bigdoor-break_phys].g1co
[S0199PIR_set-pir-des-wall-break-a01_phys].g1co
[S0199PIR_set-S0101PIR-hahen-a01_phys].g1co
[S0199PIR_set-ship-bukiko-floor-col-a01_phys].g1co
[S0199PIR_set-ship-connect-floor-col-a01_phys].g1co
[S0201BST_KVS_set-bst-building-a01-fence_phys].g1co
[S0201BST_KVS_set-bst-building-b01-fence_phys].g1co
[S0201BST_KVS_set-bst-cardboard-a01_phys].g1co
[S0201BST_KVS_set-bst-cardboard-a02_phys].g1co
[S0201BST_KVS_set-bst-cardboard-a03_phys].g1co
[S0201BST_KVS_set-bst-cardboard-b01_phys].g1co
[S0201BST_KVS_set-bst-cardboard-b02_phys].g1co
[S0201BST_KVS_set-bst-cardboard-b03_phys].g1co
[S0201BST_KVS_set-bst-car-chevrolet-gim-a01_phys].g1co
[S0201BST_KVS_set-bst-drum-a01_phys].g1co
[S0201BST_KVS_set-bst-drum-a02_phys].g1co
[S0201BST_KVS_set-bst-drum-a03_phys].g1co
[S0201BST_KVS_set-bst-drum-fire-a01_phys].g1co
[S0201BST_KVS_set-bst-emptycan-a01_phys].g1co
[S0201BST_KVS_set-bst-emptycan-a02_phys].g1co
[S0201BST_KVS_set-bst-emptycan-a03_phys].g1co
[S0201BST_KVS_set-bst-emptycan-a04_phys].g1co
[S0201BST_KVS_set-bst-emptycan-a05_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-a_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-b_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-c_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-d_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-e_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-f_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-g_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-i_phys].g1co
[S0201BST_KVS_set-bst-fence-a02-j_phys].g1co
[S0201BST_KVS_set-bst-fence-a03_phys].g1co
[S0201BST_KVS_set-bst-ground-a01_phys].g1co
[S0201BST_KVS_set-bst-litter-a03_phys].g1co
[S0201BST_KVS_set-bst-litter-a04_phys].g1co
[S0201BST_KVS_set-bst-litter-a05_phys].g1co
[S0201BST_KVS_set-bst-Mountain-of-garbage_phys].g1co
[S0201BST_KVS_set-bst-oil-tank-a01_phys].g1co
[S0201BST_KVS_set-bst-shelf-a01_phys].g1co
[S0201BST_KVS_set-bst-small-fence-a01_phys].g1co
[S0201BST_KVS_set-bst-storage-locker-a01_phys].g1co
[S0201BST_KVS_set-bst-storage-locker-after_phys].g1co
[S0201BST_KVS_set-bst-storeroom-a01_phys].g1co
[S0201BST_KVS_set-bst-trash-b01_phys].g1co
[S0201BST_KVS_set-bst-trash-b03_phys].g1co
[S0201BST_KVS_set-bst-trash-c01_phys].g1co
[S0201BST_KVS_set-bst-trash-c02_phys].g1co
[S0201BST_KVS_set-bst-trash-c03_phys].g1co
[S0201BST_KVS_set-kinematics-physics-col-box_phys].g1co
[S0201BST_set-bst-building-a01-fence_phys].g1co
[S0201BST_set-bst-building-b01-fence_phys].g1co
[S0201BST_set-bst-cardboard-a01_phys].g1co
[S0201BST_set-bst-cardboard-a02_phys].g1co
[S0201BST_set-bst-cardboard-a03_phys].g1co
[S0201BST_set-bst-cardboard-b01_phys].g1co
[S0201BST_set-bst-cardboard-b02_phys].g1co
[S0201BST_set-bst-cardboard-b03_phys].g1co
[S0201BST_set-bst-car-chevrolet-gim-a01_phys].g1co
[S0201BST_set-bst-drum-a01_phys].g1co
[S0201BST_set-bst-drum-a02_phys].g1co
[S0201BST_set-bst-drum-a03_phys].g1co
[S0201BST_set-bst-drum-fire-a01_phys].g1co
[S0201BST_set-bst-emptycan-a01_phys].g1co
[S0201BST_set-bst-emptycan-a02_phys].g1co
[S0201BST_set-bst-emptycan-a03_phys].g1co
[S0201BST_set-bst-emptycan-a04_phys].g1co
[S0201BST_set-bst-emptycan-a05_phys].g1co
[S0201BST_set-bst-fence-a02-a_phys].g1co
[S0201BST_set-bst-fence-a02-b_phys].g1co
[S0201BST_set-bst-fence-a02-c_phys].g1co
[S0201BST_set-bst-fence-a02-d_phys].g1co
[S0201BST_set-bst-fence-a02-e_phys].g1co
[S0201BST_set-bst-fence-a02-f_phys].g1co
[S0201BST_set-bst-fence-a02-g_phys].g1co
[S0201BST_set-bst-fence-a02-i_phys].g1co
[S0201BST_set-bst-fence-a02-j_phys].g1co
[S0201BST_set-bst-fence-a03_phys].g1co
[S0201BST_set-bst-goods-sofa-a01_phys].g1co
[S0201BST_set-bst-ground-a01_phys].g1co
[S0201BST_set-bst-litter-a03_phys].g1co
[S0201BST_set-bst-litter-a04_phys].g1co
[S0201BST_set-bst-litter-a05_phys].g1co
[S0201BST_set-bst-Mountain-of-garbage_phys].g1co
[S0201BST_set-bst-oil-tank-a01_phys].g1co
[S0201BST_set-bst-shelf-a01_phys].g1co
[S0201BST_set-bst-small-fence-a01_phys].g1co
[S0201BST_set-bst-storage-locker-a01_phys].g1co
[S0201BST_set-bst-storeroom-a01_phys].g1co
[S0201BST_set-bst-trash-b01_phys].g1co
[S0201BST_set-bst-trash-b03_phys].g1co
[S0201BST_set-bst-trash-c01_phys].g1co
[S0201BST_set-bst-trash-c02_phys].g1co
[S0201BST_set-bst-trash-c03_phys].g1co
[S0201BST_set-bst-trash-dumpster-a01_phys].g1co
[S0201BST_set-bst-trash-dumpster-a02_phys].g1co
[S0201BST_set-bst-trash-dumpster-a03_phys].g1co
[S0201BST_set-kinematics-physics-col-box_phys].g1co
[S0201BST_set-pir-box-hollow-a01_phys].g1co
[S0201BST_set-pir-box-hollow-a02_phys].g1co
[S0301CRM_set-cri-machine-a01_phys].g1co
[S0301CRM_set-cri-machine-b01_phys].g1co
[S0301CRM_set-cri-tank-a01_phys].g1co
[S0302CRM_set-cri-booth-b02_phys].g1co
[S0302CRM_set-cri-booth-b03_phys].g1co
[S0302CRM_set-cri-booth-c01_phys].g1co
[S0302CRM_set-cri-fence-a01_phys].g1co
[S0302CRM_set-cri-garbage-c01_phys].g1co
[S0399CRM_set-col-cri-ground-b01_phys].g1co
[S0399CRM_set-cri-box-a01_phys].g1co
[S0399CRM_set-cri-box-b01_phys].g1co
[S0399CRM_set-cri-box-c01_phys].g1co
[S0399CRM_set-cri-box-c02_phys].g1co
[S0399CRM_set-kinematics-physics-col-box_phys].g1co
[S0399CRM_set-kinematics-physics-col-box-1m_phys].g1co
[S0701MUS_set-mus-bar-billiards_phys].g1co
[S0701MUS_set-mus-bar-bucket_phys].g1co
[S0701MUS_set-mus-bar-chair-01_phys].g1co
[S0701MUS_set-mus-bar-chair-02_phys].g1co
[S0701MUS_set-mus-bar-chair-03_phys].g1co
[S0701MUS_set-mus-bar-chair-04_phys].g1co
[S0701MUS_set-mus-bar-drum_phys].g1co
[S0701MUS_set-mus-bar-floor-01_phys].g1co
[S0701MUS_set-mus-bar-table-01_phys].g1co
[S0701MUS_set-mus-bar-table-02_phys].g1co
[S0701MUS_set-mus-bar-table-03_phys].g1co
[S0799MUS_set-mus-col-ground_phys].g1co
[S0799MUS_set-mus-floor-01_phys].g1co
[S0799MUS_set-mus-floor-02_phys].g1co
[S0799MUS_set-mus-kinematics-physics-colbox_phys].g1co
[S0799MUS_set-mus-passage-01-b_phys].g1co
[S0799MUS_set-mus-passage-01-c_phys].g1co
[S0799MUS_set-mus-passage-01-d_phys].g1co
[S0799MUS_set-mus-passage-01-h_phys].g1co
[S0799MUS_set-mus-passage-01-i_phys].g1co
[S0799MUS_set-mus-passage-02-b_phys].g1co
[S0799MUS_set-mus-passage-02-c_phys].g1co
[S0799MUS_set-mus-passage-02-d_phys].g1co
[S0799MUS_set-mus-passage-02-e_phys].g1co
[S0901WAY_set-way-box-01_phys].g1co
[S0901WAY_set-way-phy-wall-01_phys].g1co
[S0901WAY_set-way-phy-wall-02_phys].g1co
[S0901WAY_set-way-phy-wall-03_phys].g1co
[S0901WAY_set-way-phy-wall-04_phys].g1co
[S0901WAY_set-way-phy-wall-05_phys].g1co
[S0901WAY_set-way-phy-wall-06_phys].g1co
[S0901WAY_set-way-phy-wall-07_phys].g1co
[S0901WAY_set-way-sign-04bk-02_phys].g1co
[S0901WAY_set-way-sign-05bk-01_phys].g1co
[S0901WAY_set-way-sign-05bk-02_phys].g1co
[S0901WAY_set-way-sign-05bk-03_phys].g1co
[S0901WAY_set-way-sign-05bk-04_phys].g1co
[S0901WAY_set-way-tire-gim-02_phys].g1co
[S1501GRD_set-S1501-inside-ceil-col-01a_phys].g1co
[S1501GRD_set-S1501-inside-floor-col-01a_phys].g1co
[S1501GRD_set-S1501-wallparts-01a_phys].g1co

The addon might be picky when it comes to "bad" geometry (faces of more than 3 vertices, loose vertices, loose edges), so if you experience issues make sure to clear that.
Also, the bounding volume hierarchy algorithm I wrote is very basic and dumb, and for example can't split linked triangles into different bounding volumes. For in-game performance reasons you might want to split some of your objects manually.
Also, my algorithm seems to produce a lot more BVHs than whatever doa6 devs used, so maybe tune down the max depth export option if you encounter issues. 0 to disable BVH optimization completely, -1 to lift the max depth restriction alltogether.
Also, there are few bytes in the g1co file format that I don't understand - they seem like memory garbage, and it seems to work fine when I just ignore them, but there's a chance they do something like settings collision filters/mask/groups (e.g. vs camera, vs particles, vs chars, vs garbage, vs projectiles etc), in which case a simple import and export even without any modification will lose/overwrite that info.

Import also provides an option to "import AABBs" which will display the bounding volume hierarchy, as well as create vertex groups with assigned BVHs, mainly for debugging purposes, or seeing how deep the original g1co files go.

If you import a file and don't see the result, try scaling it down (like x0.01), since units of g1co files seem to be centimeters. Don't forget to scale it back up or use the scale on export option to put it back to correct units.

Also note that you can import more than 1 g1co file at once.

As usual, thanks to Revan for testing :)
 

Rev_an

Active Member
this tool makes collision mesh editing ludicrously easy and the game is letting me get away with all sorts of horrible things to get that douglas memorial mod working. some tips/things to look out for with doa 6 (can't speak to other koei games but these tools might work on their colmeshes):

are you sure editing a collision mesh is better than editing a scene database for what you're trying to do?

are your normals the right way around? they control which "side" of a 2d face the actual wall is on, you can generally walk through walls from the out of bounds side

pay attention to whether what you're editing is using a relative or absolute position, loading something into blender, moving it around, and exporting it might make your colmesh be somewhere you don't expect.

some stages like chinese festival and forbidden fortune look like they're mostly world-spaced but if you check the databse files CF is like 1.4km off center at (1,000 0 1,000)

on default settings, blender is (x, -z, y) to the game's (x y z)

quaternions suck but you don't need any calculus or trigonometry to get wolfram alpha to multiply them for you, and for game objects that have collision meshes attached to them instead of being lined up with an invisible floating separate one you don't need to calculate any rotations anyway just edit them in-place however they are imported to blender

did you check the "limit to selection only" box?
 
ALL DOA6 DOA5 DOA4 DOA3 DOA2U DOAD
Top