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

[rmodels] Animation issue with the GLB/GLTF files #4569

Open
efeozyer opened this issue Dec 2, 2024 · 1 comment
Open

[rmodels] Animation issue with the GLB/GLTF files #4569

efeozyer opened this issue Dec 2, 2024 · 1 comment
Labels
help needed - please! I need help with this issue

Comments

@efeozyer
Copy link

efeozyer commented Dec 2, 2024

  • [ x ] I tested it on latest raylib version from master branch
  • [ x ] I checked there is no similar issue already reported
  • [ x ] I checked the documentation on the wiki
  • [ x ] My code has no errors or misuse of raylib

Issue description

Hi folks, I recently started using Raylib with the basic setup. Basically I was trying to load ,GLB file and animate it.
You can see there, my character how looks like without animation.

image

But.. that happens when I called UpdateModelAnimation method.
image

I thought that, something wrong with my .GLB file but I have tried this, web site and it was working properly.

https://gltf-viewer.donmccurdy.com/

Environment

Windows x64 \ Raylib 5.5 \ VC++

Additional files

orc_warrior.zip

// Raylib.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "raylib.h"
#include <iostream>

int main()
{
	InitWindow(800, 600, "Raylib Window");

	int animCount = 0;
	int animFrame = 0;
	auto model = LoadModel("orc_warrior.glb");
	auto animations = LoadModelAnimations("orc_warrior.glb", &animCount);

	Camera camera = { 0 };
	camera.position = { 4.0f, 4.0f, 4.f };
	camera.target = { 0.0f, 2.0f, 0.0f };
	camera.up = { 0.0f, 1.0f, 0.0f };
	camera.fovy = 60.0f;
	camera.projection = CAMERA_PERSPECTIVE;

	while (!WindowShouldClose()) {
		BeginDrawing();
		ClearBackground(BLACK);
		BeginMode3D(camera);
		DrawText("Hello, Raylib!", 190, 200, 20, LIGHTGRAY);
		DrawModel(model, { 0.0f, 0.0f, 0.0f }, 1.0f, WHITE);
		
		if (IsKeyDown(KEY_W))
		{
			UpdateModelAnimation(model, animations[0], animFrame);
			if (animFrame >= animations[0].frameCount) {
				animFrame = 0;
			}
			animFrame++;
		}

		DrawGrid(100, 5);
		EndMode3D();
		EndDrawing();
	}
	CloseWindow();
	return 0;
}


@efeozyer efeozyer changed the title Animation issue GLB/GLTF files Animation issue with the GLB/GLTF files Dec 2, 2024
@raysan5 raysan5 changed the title Animation issue with the GLB/GLTF files [rmodels] Animation issue with the GLB/GLTF files Dec 3, 2024
@raysan5 raysan5 added the help needed - please! I need help with this issue label Dec 3, 2024
@Kirandeep-Singh-Khehra
Copy link
Contributor

Kirandeep-Singh-Khehra commented Dec 4, 2024

Hi @efeozyer,

I faced similar issue before with Mixamo Y-bot. I tried your example too. and its somewhat similar. I have modified your model a little and you can get here. orc_warrior.zip.

What i did:

  1. Open blender.
  2. Import model in blender.
  3. Delete camera, default cube and light.
  4. Change rotation model to Euler model and set rotations to 0. As shown here.
    image
  5. Now export the model and use it again.
  6. It will work now. You can apply transform in code to make him upright. There's a way to apply transforms permanently to a model in blender but i'm not good with blender.

I think this issue is with UpdateModelAnimation() function(or UpdateModelAnimationBones()) or issue could be that bindPose does not consider rotation of mesh while loading or updating bones. But this process works.

You may see animation running too fast, you can add SetTargetFPS(60); before while loop to see it at normal speeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed - please! I need help with this issue
Projects
None yet
Development

No branches or pull requests

3 participants