Mesh_Entities!
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
Node_Handle :: #type, distinct u32;
|
||||
Material_Handle :: #type, distinct u32;
|
||||
Model_Handle :: #type, isa u32;
|
||||
|
||||
Model_Asset :: struct {
|
||||
path: string;
|
||||
}
|
||||
|
||||
MAX_BONES :: 128;
|
||||
MAX_WEIGHTS :: 4;
|
||||
@@ -66,7 +71,9 @@ Model :: struct {
|
||||
materials : [..] Model_Material;
|
||||
}
|
||||
|
||||
get_first_mesh_from_model :: (model: Model) -> Mesh_Handle, bool {
|
||||
get_first_mesh_from_model :: (handle: Model_Handle) -> Mesh_Handle, bool {
|
||||
model := get_model_by_handle(handle);
|
||||
|
||||
for model.nodes {
|
||||
for m: it.meshes {
|
||||
return m, true;
|
||||
@@ -377,7 +384,9 @@ parse_fbx_node :: (model: *Model, fbx_node: *ufbx_node) {
|
||||
// }
|
||||
//}
|
||||
|
||||
array_add(*node.meshes, parray_add(*engine.renderer.meshes, mesh));
|
||||
array_add(*node.meshes, parray_add(*engine.renderer.meshes, mesh));struct {
|
||||
path: string;
|
||||
}
|
||||
array_add(*node.material_defaults, model.materials[mesh_mat.material.typed_id]); // @Incomplete
|
||||
}
|
||||
}
|
||||
@@ -580,7 +589,7 @@ load_fbx_texture :: (map: ufbx_material_map, format: Format) -> Texture_Handle {
|
||||
return 0;
|
||||
}
|
||||
|
||||
load_fbx :: (path: string) -> *Model, bool {
|
||||
load_fbx :: (path: string) -> Model_Handle, bool {
|
||||
opts : ufbx_load_opts = .{};
|
||||
opts.load_external_files = true;
|
||||
opts.generate_missing_normals = true;
|
||||
@@ -597,10 +606,11 @@ load_fbx :: (path: string) -> *Model, bool {
|
||||
|
||||
if scene == null {
|
||||
log_error("FBX '%' could not be loaded", path);
|
||||
return null, false;
|
||||
return 0, false;
|
||||
}
|
||||
|
||||
model, locator := find_and_occupy_empty_slot(*engine.renderer.model_lib);
|
||||
model : Model;
|
||||
|
||||
model.path = copy_string(path);
|
||||
model.name = copy_string(path);
|
||||
|
||||
@@ -643,24 +653,27 @@ load_fbx :: (path: string) -> *Model, bool {
|
||||
|
||||
for i: 0..scene.nodes.count-1 {
|
||||
node := scene.nodes.data[i];
|
||||
parse_fbx_node(model, node);
|
||||
parse_fbx_node(*model, node);
|
||||
}
|
||||
|
||||
// Load animations
|
||||
array_resize(*model.animations, xx scene.anim_stacks.count);
|
||||
for 0..model.animations.count-1 {
|
||||
parse_anim_stack(*model.animations[it], scene.anim_stacks.data[it], scene, model);
|
||||
parse_anim_stack(*model.animations[it], scene.anim_stacks.data[it], scene, *model);
|
||||
}
|
||||
|
||||
ufbx_free_scene(scene);
|
||||
|
||||
return model, false;
|
||||
array_add(*engine.renderer.model_lib, model);
|
||||
handle := cast(Model_Handle)engine.renderer.model_lib.count;
|
||||
|
||||
return handle, false;
|
||||
}
|
||||
|
||||
get_or_load_model :: (path: string) -> *Model {
|
||||
get_or_load_model :: (path: string) -> Model_Handle {
|
||||
for * engine.renderer.model_lib {
|
||||
if it.path == path {
|
||||
return it;
|
||||
return xx (it_index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user