work save : glTF scene support
This commit is contained in:
parent
3c359ff4bc
commit
b265ded584
6386
examples/Makefile
6386
examples/Makefile
File diff suppressed because it is too large
Load Diff
4
src/external/cgltf.h
vendored
4
src/external/cgltf.h
vendored
|
|
@ -732,6 +732,7 @@ typedef struct cgltf_data
|
||||||
cgltf_scene* scenes;
|
cgltf_scene* scenes;
|
||||||
cgltf_size scenes_count;
|
cgltf_size scenes_count;
|
||||||
|
|
||||||
|
unsigned int scene_id;
|
||||||
cgltf_scene* scene;
|
cgltf_scene* scene;
|
||||||
|
|
||||||
cgltf_animation* animations;
|
cgltf_animation* animations;
|
||||||
|
|
@ -5758,7 +5759,8 @@ static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens
|
||||||
else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk));
|
out_data->scene_id = cgltf_json_to_int(tokens + i, json_chunk);
|
||||||
|
out_data->scene = CGLTF_PTRINDEX(cgltf_scene, out_data->scene_id);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
|
else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
|
||||||
|
|
|
||||||
12
src/raylib.h
12
src/raylib.h
|
|
@ -366,6 +366,13 @@ typedef struct Transform {
|
||||||
Vector3 scale; // Scale
|
Vector3 scale; // Scale
|
||||||
} Transform;
|
} Transform;
|
||||||
|
|
||||||
|
//Scene
|
||||||
|
typedef struct Scene {
|
||||||
|
int meshCount; // Number of meshes
|
||||||
|
int *meshes; // Scene meshes array
|
||||||
|
Transform *meshTransforms; // transform matrices for meshes
|
||||||
|
} Scene;
|
||||||
|
|
||||||
// Bone, skeletal animation bone
|
// Bone, skeletal animation bone
|
||||||
typedef struct BoneInfo {
|
typedef struct BoneInfo {
|
||||||
char name[32]; // Bone name
|
char name[32]; // Bone name
|
||||||
|
|
@ -382,6 +389,11 @@ typedef struct Model {
|
||||||
Material *materials; // Materials array
|
Material *materials; // Materials array
|
||||||
int *meshMaterial; // Mesh material number
|
int *meshMaterial; // Mesh material number
|
||||||
|
|
||||||
|
// Scene data
|
||||||
|
int sceneCount; // Number of scenes
|
||||||
|
Scene *scenes; // Scenes array
|
||||||
|
int scene; // Scene should be displayed
|
||||||
|
|
||||||
// Animation data
|
// Animation data
|
||||||
int boneCount; // Number of bones
|
int boneCount; // Number of bones
|
||||||
BoneInfo *bones; // Bones information (skeleton)
|
BoneInfo *bones; // Bones information (skeleton)
|
||||||
|
|
|
||||||
|
|
@ -4649,6 +4649,7 @@ static Model LoadGLTF(const char *fileName)
|
||||||
TRACELOG(LOG_DEBUG, " > Buffers count: %i", data->buffers_count);
|
TRACELOG(LOG_DEBUG, " > Buffers count: %i", data->buffers_count);
|
||||||
TRACELOG(LOG_DEBUG, " > Images count: %i", data->images_count);
|
TRACELOG(LOG_DEBUG, " > Images count: %i", data->images_count);
|
||||||
TRACELOG(LOG_DEBUG, " > Textures count: %i", data->textures_count);
|
TRACELOG(LOG_DEBUG, " > Textures count: %i", data->textures_count);
|
||||||
|
TRACELOG(LOG_DEBUG, " > Scenes count: %1", data->scenes_count);
|
||||||
|
|
||||||
// Force reading data buffers (fills buffer_view->buffer->data)
|
// Force reading data buffers (fills buffer_view->buffer->data)
|
||||||
// NOTE: If an uri is defined to base64 data or external path, it's automatically loaded -> TODO: Verify this assumption
|
// NOTE: If an uri is defined to base64 data or external path, it's automatically loaded -> TODO: Verify this assumption
|
||||||
|
|
@ -4943,6 +4944,22 @@ static Model LoadGLTF(const char *fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load scene data
|
||||||
|
if (data->scenes_count > 0) {
|
||||||
|
model.scene = data->scene_id;
|
||||||
|
model.scenes = (Scene *)malloc(sizeof(Scene) * data->scenes_count);
|
||||||
|
memset(model.scenes, 0, sizeof(Scene) * data->scenes_count);
|
||||||
|
for (unsigned int i = 0; i < data->scenes_count; i++) {
|
||||||
|
// TODO: for each nodes, find
|
||||||
|
if (data->scenes[i].nodes_count>0) {
|
||||||
|
for (unsigned int j = 0; j < data->scenes[i].nodes_count; j++) {
|
||||||
|
scenes
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// TODO: Load glTF meshes animation data
|
// TODO: Load glTF meshes animation data
|
||||||
// REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skins
|
// REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skins
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user