ad
This commit is contained in:
parent
d8de965c16
commit
caf841454c
23
.vscode/c_cpp_properties.json
vendored
Normal file
23
.vscode/c_cpp_properties.json
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE"
|
||||
],
|
||||
"windowsSdkVersion": "10.0.17763.0",
|
||||
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "msvc-x64",
|
||||
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
|
||||
"configurationProvider": "vector-of-bool.cmake-tools"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
14
.vscode/settings.json
vendored
Normal file
14
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"cmake.configureOnOpen": false,
|
||||
"files.associations": {
|
||||
"chrono": "c",
|
||||
"memory": "c",
|
||||
"ratio": "c",
|
||||
"tuple": "c",
|
||||
"type_traits": "c",
|
||||
"utility": "c",
|
||||
"xmemory0": "c",
|
||||
"xtr1common": "c",
|
||||
"xutility": "c"
|
||||
}
|
||||
}
|
||||
|
|
@ -20,8 +20,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#define DEBUG_DRAW 0
|
||||
#define DEBUG_DRAW 1
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
@ -40,17 +41,17 @@ int main(void)
|
|||
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||
camera.type = CAMERA_PERSPECTIVE; // Camera mode type
|
||||
|
||||
Model model2 = LoadModel("resources/models/RiggedFigure.glb");
|
||||
Model model2 = LoadModel("resources/models/MonsterScaled.glb");
|
||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||
|
||||
// Load animation data
|
||||
int animsCount = 0;
|
||||
ModelAnimation *anims = LoadModelAnimations("resources/models/RiggedFigure.glb", &animsCount);
|
||||
ModelAnimation *anims = LoadModelAnimations("resources/models/MonsterScaled.glb", &animsCount);
|
||||
int animFrameCounter = 0;
|
||||
bool isValid = IsModelAnimationValid(model2, anims[2]);
|
||||
if (!isValid) {
|
||||
printf("\n\n\n\nModel Bone Count: %i, Animation Bone Count: %i, Animation Count: %i\n\n\n\n", model2.boneCount, anims[2].boneCount, animsCount);
|
||||
}
|
||||
//bool isValid = IsModelAnimationValid(model2, anims[0]);
|
||||
// if (!isValid) {
|
||||
// printf("\n\n\n\nModel Bone Count: %i, Animation Bone Count: %i, Animation Count: %i\n\n\n\n", model2.boneCount, anims[2].boneCount, animsCount);
|
||||
// }
|
||||
SetCameraMode(camera, CAMERA_FREE); // Set free camera mode
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
|
|
@ -80,7 +81,7 @@ int main(void)
|
|||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModelEx(model2, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
|
||||
DrawModelEx(model2, position, (Vector3){ 0.0f, 0.0f, 0.0f }, 0.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
|
||||
|
||||
//Draw debug
|
||||
if(DEBUG_DRAW)
|
||||
|
|
@ -88,7 +89,7 @@ int main(void)
|
|||
for (int i = 0; i < model2.boneCount; i++)
|
||||
{
|
||||
//DrawCube(anims[0].framePoses[animFrameCounter][i].translation, 0.2f, 0.2f, 0.2f, RED);
|
||||
//DrawCube(model2.bindPose[i].translation, 0.2f, 0.2f, 0.2f, RED);
|
||||
DrawCube(Vector3Negate(model2.bindPose[i].translation), 0.05f, 0.05f, 0.05f, RED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ int main(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// Unload model animations data
|
||||
// Unload model animations data
|
||||
for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
|
||||
RL_FREE(anims);
|
||||
|
||||
|
|
|
|||
BIN
examples/models/resources/models/MonsterScaled.glb
Normal file
BIN
examples/models/resources/models/MonsterScaled.glb
Normal file
Binary file not shown.
|
|
@ -219,7 +219,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
|||
endif
|
||||
|
||||
# Define default C compiler and archiver to pack library
|
||||
CC ?= gcc
|
||||
CC = gcc
|
||||
AR = ar
|
||||
|
||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
|
|
|
|||
37
src/models.c
37
src/models.c
|
|
@ -3716,14 +3716,6 @@ static Model LoadGLTF(const char *fileName)
|
|||
}
|
||||
}
|
||||
|
||||
// Mark parents in array
|
||||
if (data->skins[0].joints[i]->children_count > 0) {
|
||||
int numOfChildrenJoints = data->skins[0].joints[i]->children_count;
|
||||
for (int j = i; j < numOfChildrenJoints; j++) {
|
||||
model.bones[j].parent = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the tranlation for this joint
|
||||
if (data->skins[0].joints[i]->has_translation) {
|
||||
model.bindPose[i].translation.x = data->skins[0].joints[i]->translation[0];
|
||||
|
|
@ -3750,7 +3742,34 @@ static Model LoadGLTF(const char *fileName)
|
|||
}
|
||||
}
|
||||
|
||||
// Build bind pose from parent joints... Same IQM Loader
|
||||
for (int i = 0; i < model.boneCount; i++) {
|
||||
// Mark parents in array
|
||||
printf("BONE %d: %d\n", i, data->skins[0].joints[i]->children_count);
|
||||
if (data->skins[0].joints[i]->children_count > 0) {
|
||||
int numOfChildrenJoints = data->skins[0].joints[i]->children_count;
|
||||
for (int j = i; j < numOfChildrenJoints; j++) {
|
||||
model.bones[j].parent = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//INVERSE MATRIX, for transposing joint into skin space
|
||||
/*
|
||||
float* inverseMatrix = (float*)RL_CALLOC((16 * data->skins[0].joints_count), sizeof(float));
|
||||
LOAD_ACCESSOR(float, 16, data->skins[0].inverse_bind_matrices, inverseMatrix)
|
||||
int matrixIndex = 0;
|
||||
|
||||
for (int i = 0; i < (16 * data->skins[0].joints_count) - 1; i+= 15) {
|
||||
printf("\n\nMATRIX %d\n%f, %f, %f, %f\n%f, %f, %f, %f\n%f, %f, %f, %f\n%f, %f, %f, %f\n", matrixIndex,
|
||||
inverseMatrix[i], inverseMatrix[i+1], inverseMatrix[i+2], inverseMatrix[i+3],
|
||||
inverseMatrix[i+4], inverseMatrix[i+5], inverseMatrix[i+6], inverseMatrix[i+7],
|
||||
inverseMatrix[i+8], inverseMatrix[i+9], inverseMatrix[i+10], inverseMatrix[i+11],
|
||||
inverseMatrix[i+12], inverseMatrix[i+13], inverseMatrix[i+14], inverseMatrix[i+15]);
|
||||
matrixIndex++;
|
||||
}
|
||||
*/
|
||||
|
||||
//Build bind pose from parent joints... Same IQM Loader
|
||||
for (int i = 0; i < model.boneCount; i++)
|
||||
{
|
||||
if (model.bones[i].parent >= 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user