Skip to content
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

[models] glTF doesn't support scaling #1024

Closed
electronstudio opened this issue Nov 24, 2019 · 6 comments
Closed

[models] glTF doesn't support scaling #1024

electronstudio opened this issue Nov 24, 2019 · 6 comments

Comments

@electronstudio
Copy link
Contributor

Scale a cube in Blender:

image

Export as glTF:
scaledcube.gltf.zip

Load into models_loading.c example:

INFO: [/Users/richard/scaledcube.gltf][gltf] Model meshes/materials: 1/1
INFO: [VAO ID 2] Mesh uploaded successfully to VRAM (GPU)

Does not apply scaling:

image

@electronstudio
Copy link
Contributor Author

@Gamerfiend

@Gamerfiend
Copy link
Contributor

Hey sorry I just noticed this! @electronstudio Please make sure you have applied all transforms to the model. I've ran into this same issue, and applying transforms before exporting can solve this issue.

@raysan5
Copy link
Owner

raysan5 commented Jan 8, 2020

@Gamerfiend thanks for the proposed solution.

@raysan5 raysan5 closed this as completed Jan 8, 2020
@Shr1ftyy
Copy link

Shr1ftyy commented Oct 3, 2023

Note to others who may come across this issue.

I just stumbled upon this issue after my mouse ray mesh collisions weren't working as intended. It turned out, that the ray checks collisions with the original GLTF model, but not the scaled model which is drawn (this also includes the fact that the transform does not change when drawing the model, as well as the rotation), hence the model is always at the center of the world coordinates. to compensate for this, ensure you update the model's transform matrices (example below written in odin).

            transform := _unit^.model.transform
            transform[0][0] *= _unit^.modelScale
            transform[1][1] *= _unit^.modelScale
            transform[2][2] *= _unit^.modelScale

            transform[0][3] = _unit^.position.x
            transform[1][3] = _unit^.position.y
            transform[2][3] = _unit^.position.z

Below is an image which may help readers identify what they need to modify:
image

@Shr1ftyy
Copy link

Shr1ftyy commented Oct 3, 2023

Also, just wanted to say...

I LOVE THIS LIB SO MUCH OMG <3 <3 <3 GREAT WORK @raysan5

@keithstellyes
Copy link
Contributor

keithstellyes commented Oct 12, 2023

I ran into this same issue, doing Ctrl+A in Blender to "Apply all transforms" fixed it. Thank you @Gamerfiend

Worth noting other 3D viewers are able to to handle the scaling just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants