Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Tag improvements, fix GLTF import #5606

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

sturnclaw
Copy link
Member

This PR makes model tags a separate object type which is affected and transformed by the model hierarchy in a way that is consistent with the hierarchy of the source file in Blender. This allows tags to be transformed and animated, while still retaining the ability to query their global model-space transform.

I've also made a refactor to how ModelBody lighting is handled, moving responsibility for calculating lighting to the camera/render pass rather than the body object itself. This will be expanded on later with future rendering improvements and is needed for clickable cockpits.

I've also made some minor tweaks to allow the game to load GLTF-format model source files as well as Collada. GLTF is set up so that Blender "text" objects can be imported as Label nodes and the orientation of the node is the same as it appears in Blender.

This branch is a prerequisite for my editor branch and will be merged somewhat quickly.

Use existing double->float matrix conversion code, simplify matrix calculation.
Calculating the atmospheric light attenuation for a body is no longer the domain of a ModelBody; it's moved to Camera to be used wherever necessary.

This simplifies the rendering code in ModelBody and SpaceStation.
Change the SceneGraph::Model Tag API to use string_view instead of std::string references.
The entire API has not been converted due to time and complexity constraints.
- Add a new Tag node that's concerned with storing a model-space global transform and keeping it updated when the model animation state changes.
- Tag nodes are now added to their parent nodes according to the model source data, rather than being reparented to the model root.
- The SGM_VERSION was bumped given that the new Tag nodes are not backwards compatible.
- SceneGraph nodes are now restricted to only having a single parent, as the parent information is required to efficiently calculate the global transform of Tag nodes.
- All tag transforms are updated when animations are ticked; this has some future potential for optimization.
- Correctly initialize the active animations field of Model.
The Blender GLTF exporter writes the generated text mesh of a text object to the node, needing special-case handling.

The Label implementation draws labels pointing towards +Z, which works for Collada models due to the implicit import rotation of the model.
Amend the orientation of label nodes when importing from GLTF.

Fixup: handle invalid animation node refs

GLTF exports a single frame of animation for all objects in the scene, some of which may have been turned into labels or other nodes.

Gracefully handle a missing node for these channels and ignore them.
@sturnclaw
Copy link
Member Author

NOTE: this PR introduces an SGM format bump due to the new Tag node, and as such any cached SGM models in your working tree after merge will need to be regenerated.

@impaktor
Copy link
Member

NOTE: this PR introduces an SGM format bump due to the new Tag node, and as such any cached SGM models in your working tree after merge will need to be regenerated.

How will this affect a player who upgrades their pioneer installation? Do we have some way to set configuration to force-rebuild them once? Just thinking: most players probably don't read the release information or instrucitons.

@bszlrd
Copy link
Contributor

bszlrd commented Aug 23, 2023

Aren't the models generated upon build?

@impaktor
Copy link
Member

@nozmajner last time I checked (which was years ago), @fluffyfreak made is so pioneer builds them first time you start pioneer, if they're missing. I don't remember that having been changed.

@sturnclaw
Copy link
Member Author

We distribute SGM files as part of binary builds of Pioneer, built using CI. For the end-user, they'll just have to delete the old data directory as usual when we make our next release. For developers working from repo, there is a separate facility to generate SGM files in-tree using the model compiler - you'll need to run find data/ -iname '*.sgm' | xargs rm or equivalent to remove the old SGM files. SGM files are not generated by the game directly; if they're not present or an incompatible version, the game falls back to loading from model source files instead (e.g. Collada).

@sturnclaw sturnclaw merged commit 1543657 into pioneerspacesim:master Aug 25, 2023
@sturnclaw sturnclaw deleted the model-tags branch August 25, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants