-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[models] glTF not loaded correctly, mesh transform related #1930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@chriscamacho I'm afraid glTF has suffered several changes lately, it was reviewed on #1849 by @object71 but I'm not sure if he can keep maintaining it. |
given OBJ loading appears broken (again) currently the only way I've been able to get 3d media into raylib is via my own scratch written OBJ loader... I'd be inclined to investigate some other options for getting 3d media into raylib, ideally that can be used as an art path from blender (as most can afford the purchase price!) |
Indeed I cannot continue working at this point. I am occupied with other personal projects. I may review code regarding GLTF though. When I last worked on the feature 3-4 months ago the loading and display of models was correct. I've cleaned up the code and put comments to describe the process of loading models. The only thing which did not work was animations because they seemed to stretch wierdly when played. There is an open issue about it and I've commented my observations in it. |
In what manner is the OBJ loader broken. I have just tested several OBJ models, as well as the one that was previous listed as causing a crash in RayLib, and there was no issues. |
So I will leave a little update on my investigation here! Model LoadingAfter a while of testing, I came to the realization that the data loaded by raylib is not wrong. It is actually exactly the same as in the model file that you provided (a direct link would've been helpful :D ) Raylib Model Data
This data exactly corresponds to what your model data is providing on a base level. Corresponding glTF2 Snippet of your model "nodes" : [
{
"mesh" : 0,
"name" : "y-axis",
"translation" : [
0,
0.550000011920929,
0
]
},
{
"mesh" : 1,
"name" : "z-axis",
"translation" : [
0.5,
0.550000011920929,
0
]
},
{
"mesh" : 2,
"name" : "x-axis",
"rotation" : [
0.7071068286895752,
0,
0,
0.7071068286895752
],
"translation" : [
0,
0,
0.550000011920929
]
},
{
"mesh" : 3,
"name" : "Cube.001",
"translation" : [
0.25,
0.25,
0.25
]
},
{
"mesh" : 4,
"name" : "Cube.002",
"scale" : [
0.20000000298023224,
0.20000000298023224,
0.20000000298023224
]
}
], Part of the problemAs someone with a little knowledge of how these transformations work, you might notice that your x, y, z axis objects don't have the transformations you would expect! This is because you transformed them on a Vertex level instead of in world space, e.g. edit mode in Blender in your case. State/Current ConclusionSo with that said, the missing transformation data must lie in the vertex positions and I need further investigation to exactly find the point where the data differs from the Model. |
Further Updatefor(int i=0; i<model.meshCount; i++){
Vector3 tl = model.bindPose[i].translation;
Quaternion rot = model.bindPose[i].rotation;
Vector3 scale = model.bindPose[i].scale;
Matrix mt = MatrixTranslate(tl.x,tl.y,tl.z);
Matrix mr = QuaternionToMatrix(rot);
Matrix ms = MatrixScale(scale.x,scale.y,scale.z);
Matrix t = MatrixMultiply(MatrixMultiply(mr,mt), ms);
DrawMesh(model.meshes[i],model.materials[model.meshMaterial[i]],t);
} Applying the bone transformations manually instead of relying on ProblemThe bone transforms are not applied in the Lines 3023 to 3050 in 936199d
Setting of the values in Line 4894 in 936199d
Next StepsI am not quite sure what the intended use of the Lines 375 to 388 in 936199d
I am not really sure about all the different kinds of model loading, but I think that it might be a solution to add I hope this helps a little for now~ --Appended 2 hours Later |
@MrDiver Very nice! Thank you very much for investigating this issue! I think there are two separate issues here:
In any case, this issue and probably #1799 are both related to missing transformations that should be applied. |
A new update on my investigations -> #1964 This is only solving a part of the problem, but it is at least half the job done for the mesh transforms. More explanation in the PR. |
@630Studios please see #1966 |
@MrDiver Do you think this issue could be closed at this point? |
If I'm not mistaken, everything related to this issue should be solved now ! |
Please, before submitting a new issue verify and check:
Issue description
Previously loading gltf2 models, I saw the same in blender as I did in raylib
Environment
Void Linux, Mesa Intel(R) HD Graphics 5500 (BDW GT2), GL version 4.6
Issue Screenshot
Code Example
As per my "template" on bedroomcoders.co.uk
The text was updated successfully, but these errors were encountered: