jak-project/custom_assets
Hat Kid c64eea6337
[buildactor] support generating collide-meshes for custom models (#3540)
This adds support for generating collide meshes when importing custom
models. A couple of things to keep in mind:

- A single `collide-mesh` may only have up to 255 vertices.
- When exporting a GLTF file in Blender, a `collide-mesh` will be
generated for every mesh object that has collision properties applied
(ideally, you would set all visual meshes to `ignore` and your collision
meshes to `invisible` in the OpenGOAL plugin's custom properties).
- Ensure that your actor using the model properly allocates enough
`collide-shape-prim-mesh`es for each `collide-mesh` ([example from the
original game that uses multiple
meshes](f6688659f2/goal_src/jak1/levels/finalboss/robotboss.gc (L2628-L2806))).

~One annoying problem that I haven't fully figured out yet (unrelated to
the actual functionality):
`collide-mesh`es are stored in art groups as an `(array collide-mesh)`
in the `art-joint-geo`'s `extra`, so I had to add a new `Res` type to
support this. The way that `array`s are stored in `res-lump`s is a bit
of a hack right now. The lump only stores a pointer to the array, so the
size of that is 4 bytes, but because we have to generate all the actual
array data too, the current `ResLump` code in C++ doesn't handle this
case well and would assert, so I decided to omit the asserts if an
`array` tag is present and "fake" the size so the object file is
generated more closely to how the game expects it until we figure out
something better.~
This was fixed by generating the array data beforehand and creating a
`ResRef` class that takes the pointer to the array data and adds it to
the lump.
2024-05-29 06:09:20 +02:00
..
blender_plugins [wip] build actor tool (#3266) 2024-05-18 18:18:25 +02:00
jak1 [buildactor] support generating collide-meshes for custom models (#3540) 2024-05-29 06:09:20 +02:00
jak2/levels/test-zone [wip] build actor tool (#3266) 2024-05-18 18:18:25 +02:00
jak3/levels/test-zone [wip] build actor tool (#3266) 2024-05-18 18:18:25 +02:00
README.md [wip] build actor tool (#3266) 2024-05-18 18:18:25 +02:00

Custom Levels

Disclaimer: custom levels are still in development and are missing most features.

The first three steps are already done for "test zone", so this can be used as a starting point.

1: File Setup

To create a custom level, copy the layout of custom_assets/jak1/levels/test-zone. See test-zone.jsonc for information on how to name things. The .gd file also contains the level name.

2: Modify the engine

Modify goal_src/jak1/engine/level/level-info.gc to add level info for each custom level. There is level info for test-zone at the bottom that can be used as an example.

3: Modify the build system

Modify goal_src/jak1/game.gp and add a custom level target:

(build-custom-level "test-zone")
;; the DGO file
(custom-level-cgo "TESTZONE.DGO" "test-zone/testzone.gd")

4: Export the GLTF file from blender.

For now, all meshes are displayed and treated as ground collision. This causes buggy collision because walls shouldn't use "floor" mode.

Blender will create a .glb file, which must have the name specified in the .jsonc file and should be located in custom_assets/jak1/levels/your_level

5: Rebuild the game

Any time the .glb file is changed, you must rebuild the game. Launch the compiler (goalc) and run (mi) to rebuild everything. It's recommended to leave the compiler open - it will remember files that haven't changed and skip rebuilding them.

6: Go to the custom level

Start the game in debug mode gk.

In the compiler window, run (lt) to connect to the game. You must run this again every time you restart the game. If this doesn't work, there could be a firewall issue and you must allow goalc/gk to use the network. They don't make any outside connections.

In the compiler window, run a command like (bg-custom 'test-zone-vis) to load and start at a custom level.