Skip to main content

gltforge_unity/
lib.rs

1pub mod convert;
2pub mod error;
3pub(crate) mod gltf_primitive_data;
4pub mod unity_gltf;
5pub mod unity_image;
6pub mod unity_indices;
7pub mod unity_mesh;
8pub mod unity_node;
9pub mod unity_node_transform;
10pub mod unity_pbr_metallic_roughness;
11pub mod unity_scene;
12pub mod unity_submesh;
13
14// -------------------------------------------------------------------------- //
15
16pub use unity_gltf::{UnityGltf, gltforge_load, gltforge_release, gltforge_retain};
17pub use unity_image::{
18    UnityImage, gltforge_image_bytes, gltforge_image_count, gltforge_image_name, gltforge_image_uri,
19};
20pub use unity_indices::UnityIndices;
21pub use unity_mesh::{
22    UnityMesh, gltforge_mesh_count, gltforge_mesh_index_format, gltforge_mesh_name,
23    gltforge_mesh_normals, gltforge_mesh_positions, gltforge_mesh_tangents,
24    gltforge_mesh_uv_channel_count, gltforge_mesh_uvs, gltforge_mesh_vertex_count,
25};
26pub use unity_node::{
27    UnityNode, gltforge_node_child, gltforge_node_child_count, gltforge_node_count,
28    gltforge_node_mesh_count, gltforge_node_mesh_index, gltforge_node_name,
29    gltforge_node_transform,
30};
31pub use unity_node_transform::UnityNodeTransform;
32pub use unity_pbr_metallic_roughness::{
33    ALPHA_MODE_BLEND, ALPHA_MODE_MASK, ALPHA_MODE_OPAQUE, UnityPbrMetallicRoughness,
34    gltforge_pbr_metallic_roughness_alpha_cutoff, gltforge_pbr_metallic_roughness_alpha_mode,
35    gltforge_pbr_metallic_roughness_base_color_factor,
36    gltforge_pbr_metallic_roughness_base_color_texture, gltforge_pbr_metallic_roughness_count,
37    gltforge_pbr_metallic_roughness_cull, gltforge_pbr_metallic_roughness_emissive_factor,
38    gltforge_pbr_metallic_roughness_emissive_texture,
39    gltforge_pbr_metallic_roughness_metallic_factor,
40    gltforge_pbr_metallic_roughness_metallic_roughness_texture,
41    gltforge_pbr_metallic_roughness_name, gltforge_pbr_metallic_roughness_normal_scale,
42    gltforge_pbr_metallic_roughness_normal_texture,
43    gltforge_pbr_metallic_roughness_occlusion_strength,
44    gltforge_pbr_metallic_roughness_occlusion_texture,
45    gltforge_pbr_metallic_roughness_roughness_factor,
46};
47pub use unity_scene::{gltforge_root_node_count, gltforge_root_node_index, gltforge_scene_name};
48pub use unity_submesh::{
49    UnitySubMesh, gltforge_mesh_submesh_count, gltforge_mesh_submesh_indices_u16,
50    gltforge_mesh_submesh_indices_u32, gltforge_mesh_submesh_material,
51};
52
53// -------------------------------------------------------------------------- //
54
55/// Returns null + sets `out_len = 0` when a name is absent,
56/// otherwise returns a pointer to the UTF-8 bytes and sets `out_len`.
57unsafe fn write_name(name: Option<&String>, out_len: *mut u32) -> *const u8 {
58    match name {
59        Some(s) => {
60            if !out_len.is_null() {
61                unsafe { *out_len = s.len() as u32 };
62            }
63            s.as_ptr()
64        }
65        None => {
66            if !out_len.is_null() {
67                unsafe { *out_len = 0 };
68            }
69            std::ptr::null()
70        }
71    }
72}