mirror of https://github.com/bjornbytes/lovr.git
WIP;
This commit is contained in:
parent
69b5569f9e
commit
49ab151b53
|
@ -1 +1 @@
|
|||
Subproject commit d402825d03517b94cf4eac8c6caa9514f9e7562f
|
||||
Subproject commit 98a1b7671d560964c8a27cc7030ced22a1e1e263
|
|
@ -10,17 +10,20 @@ static void poseNode(Model* model, int nodeIndex, mat4 transform) {
|
|||
float globalTransform[16];
|
||||
mat4_set(globalTransform, transform);
|
||||
|
||||
int* boneIndex = map_get(&model->modelData->boneMap, node->name);
|
||||
if (!boneIndex) {
|
||||
mat4_multiply(globalTransform, node->transform);
|
||||
} else {
|
||||
Bone* bone = &model->modelData->bones.data[*boneIndex];
|
||||
mat4 finalTransform = model->pose + (*boneIndex * 16);
|
||||
|
||||
float localTransform[16];
|
||||
mat4_identity(localTransform);
|
||||
lovrAnimatorEvaluate(model->animator, node->name, localTransform);
|
||||
|
||||
mat4_set(model->nodeTransforms[nodeIndex], localTransform);
|
||||
|
||||
int* boneIndex = map_get(&model->modelData->boneMap, node->name);
|
||||
if (!boneIndex) {
|
||||
mat4_multiply(globalTransform, node->transform);
|
||||
mat4_multiply(globalTransform, localTransform);
|
||||
} else {
|
||||
Bone* bone = &model->modelData->bones.data[*boneIndex];
|
||||
mat4 finalTransform = model->pose + (*boneIndex * 16);
|
||||
|
||||
mat4_multiply(globalTransform, localTransform);
|
||||
|
||||
mat4_identity(finalTransform);
|
||||
|
@ -41,6 +44,7 @@ static void renderNode(Model* model, int nodeIndex) {
|
|||
|
||||
lovrGraphicsPush();
|
||||
lovrGraphicsMatrixTransform(MATRIX_MODEL, node->transform);
|
||||
lovrGraphicsMatrixTransform(MATRIX_MODEL, model->nodeTransforms[nodeIndex]);
|
||||
|
||||
for (int i = 0; i < node->primitives.length; i++) {
|
||||
ModelPrimitive* primitive = &model->modelData->primitives[node->primitives.data[i]];
|
||||
|
@ -113,6 +117,10 @@ Model* lovrModelCreate(ModelData* modelData) {
|
|||
mat4_identity(model->pose + (16 * i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 640; i++) {
|
||||
mat4_identity(model->nodeTransforms[i]);
|
||||
}
|
||||
|
||||
vec_deinit(&format);
|
||||
return model;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ typedef struct {
|
|||
Material** materials;
|
||||
Animator* animator;
|
||||
float pose[MAX_BONES * 16];
|
||||
float nodeTransforms[640][16];
|
||||
float aabb[6];
|
||||
bool aabbDirty;
|
||||
} Model;
|
||||
|
|
Loading…
Reference in New Issue