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

Misc changes to the GLTF module before audio PR #87063

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

aaronfranke
Copy link
Member

This PR includes a few changes I made while working on my upcoming GLTF audio PR, but without any audio stuff.

  • Fully document GLTFBufferView.
  • Partially document GLTFAccessor.
  • Improve some documentation in GLTFDocumentExtension.
  • Add a method to GLTFState to append a PackedByteArray to the buffers / bufferViews, with optional deduplication.
  • Add a method to GLTFBufferView to read the data from this bufferView as a PackedByteArray.
  • Allow the node JSON to be empty when calling import_node on extensions. This is required to handle the case of Godot scene -> in-memory GLTF data -> Godot scene, so like a half-export then half-import.
  • Allow the scene node to be null when calling export_node on extensions. This is required to handle the case of GLTF file -> in-memory GLTF data -> GLTF file, so like a half-import then half-export. This is an actual use case I have that needs to be supported, and anyway, this is good for code cleanliness to ensure the steps are fully separated.

@fire
Copy link
Member

fire commented Jan 10, 2024

Can you write an example how to use handle the case of GLTF file -> in-memory GLTF data -> GLTF file, so like a half-import then half-export.

I think I know what you mean, but what do you mean? It would help the general godot developer if we were able to put a sample here.

Otherwise I didn't see any obvious problems, but need a testplan -- like project examples of the use cases you mentioned.

@aaronfranke
Copy link
Member Author

@fire Here is an example use case from The Mirror, packing a GLTF into a GLB:

## Converts a GLTF document (including all its external dependencies) to a GLB byte array.
## GLTF files can have dependencies on other files. This would make distribution very complex.
## In order to resolve this, we can convert the GLTF to GLB data at runtime to pack it into one file.
static func convert_gltf_files_to_glb_data(path: String) -> PackedByteArray:
	var state: GLTFState = GLTFState.new()
	var doc: GLTFDocument = GLTFDocument.new()
	var err = doc.append_from_file(path, state)
	if err:
		push_error(str(err))
		return PackedByteArray()
	return doc.generate_buffer(state)

@akien-mga akien-mga merged commit fb45210 into godotengine:master Jan 15, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@aaronfranke aaronfranke deleted the gltf-misc-before-audio branch January 15, 2024 16:33
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