MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_scene_attach_model

Function bloom_scene_attach_model

native/android/src/lib.rs:2020–2058  ·  view source on GitHub ↗
(node_handle: f64, model_handle: f64, mesh_index: f64)

Source from the content-addressed store, hash-verified

2018
2019#[no_mangle]
2020pub extern "C" fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_index: f64) {
2021 let eng = engine();
2022 let mi = mesh_index as usize;
2023
2024 let model_data = match eng.models.models.get(model_handle) {
2025 Some(md) => md,
2026 None => return,
2027 };
2028 if mi >= model_data.meshes.len() { return; }
2029 let mesh = &model_data.meshes[mi];
2030
2031 let vertices = mesh.vertices.clone();
2032 let indices = mesh.indices.clone();
2033 let base_color_tex = mesh.texture_idx;
2034 let normal_tex = mesh.normal_texture_idx;
2035 let mr_tex = mesh.metallic_roughness_texture_idx;
2036 let emissive_tex = mesh.emissive_texture_idx;
2037 let emissive_factor = mesh.emissive_factor;
2038 eng.scene.update_geometry(node_handle, vertices, indices);
2039
2040 if let Some(tex_idx) = base_color_tex {
2041 eng.scene.set_material_texture(node_handle, tex_idx);
2042 }
2043 if let Some(tex_idx) = normal_tex {
2044 eng.scene.set_material_normal_texture(node_handle, tex_idx);
2045 }
2046 if let Some(tex_idx) = mr_tex {
2047 eng.scene.set_material_metallic_roughness_texture(node_handle, tex_idx);
2048 }
2049 if let Some(tex_idx) = emissive_tex {
2050 eng.scene.set_material_emissive_texture(node_handle, tex_idx);
2051 }
2052 eng.scene.set_material_emissive_factor(
2053 node_handle,
2054 emissive_factor[0],
2055 emissive_factor[1],
2056 emissive_factor[2],
2057 );
2058}
2059
2060#[no_mangle]
2061pub extern "C" fn bloom_scene_create_node() -> f64 {

Callers

nothing calls this directly

Calls 9

cloneMethod · 0.80
update_geometryMethod · 0.80
set_material_textureMethod · 0.80
engineFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected