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

IK_TWO_BONE work, IK_FABRIK - failed #14

Open
Mikez2015 opened this issue Jan 25, 2021 · 4 comments
Open

IK_TWO_BONE work, IK_FABRIK - failed #14

Mikez2015 opened this issue Jan 25, 2021 · 4 comments

Comments

@Mikez2015
Copy link

Hello

I'm using a simple two-bone structure and I found that the IK_FABRIK solver didn't want to work properly. I made two videos, the first in IK_TWO_BONE mode, the second in IK_FABRIK mode. I am wondering why IK_FABRIK mode is not working.
The code is the same, except for the solver mode.

IK_TWO_BONE:
https://youtu.be/hR41geXbEeU

IK_FABRIK:
https://youtu.be/D1ZIXcFRjW8

@TheComet
Copy link
Owner

TheComet commented Jan 26, 2021

Hey!

Nice demos! Which branch/commit hash are you on?

If you're on devel then unfortunately FABRIK is still being developed.

@Mikez2015
Copy link
Author

Mikez2015 commented Jan 27, 2021

Hey!

Nice demos! Which branch/commit hash are you on?

If you're on devel then unfortunately FABRIK is still being developed.

I use Default branch (master).

Please see this short code, maybe I was wrong somewhere :

	if (!start) {

		// solver = ik.solver.create(IK_TWO_BONE);
		solver = ik.solver.create(IK_FABRIK);

		root = solver->node->create(0);
		child1 = solver->node->create_child(root, 1);
		child2 = solver->node->create_child(child1, 2);
		child1->position = ik.vec3.vec3( 0.0f, 1.0f, 0.7f);
		child2->position = ik.vec3.vec3( 0.0f, 1.0f, -0.7f);

		eff = solver->effector->create();
		solver->effector->attach(eff, child2);

		solver->flags |= IK_ENABLE_TARGET_ROTATIONS;

		ik.solver.set_tree(solver, root);
		ik.solver.rebuild(solver);

		start = true;
	}

	glm::vec3 start = glm::vec3(251.0f, 5.0f, 268.0f);

	TEST_DEBUG_IK = models[34].phys.pos - start;

	eff->target_position = ik.vec3.vec3(TEST_DEBUG_IK.x, TEST_DEBUG_IK.y, TEST_DEBUG_IK.z);

	ik.solver.solve(solver);

	glm::vec3 l1 = start + glm::vec3(child1->position.x, child1->position.y, child1->position.z);
	glm::vec3 l2 = start + glm::vec3(child2->position.x, child2->position.y, child2->position.z);

	create_DebugLine(start, l1, glm::vec4(vecColor_Red, 1.0f), 3.0f);
	create_DebugLine(l1, l2, glm::vec4(vecColor_Green, 1.0f), 3.0f);

Here are a couple more videos just for this code. First video for TWO BONES, second video for FABRIK:
1.
https://youtu.be/A3N7a8Qvp8k
2.
https://youtu.be/75f-jKEsZmI

Update:
In Fabrik mode I noticed one strange thing. The first joint (red line) does not move at all.

@donghaoye
Copy link

couple more videos just for this code. F
pretty! could provide the full example code?

@Jerryzhangzhao
Copy link

Hey!
Nice demos! Which branch/commit hash are you on?
If you're on devel then unfortunately FABRIK is still being developed.

I use Default branch (master).

Please see this short code, maybe I was wrong somewhere :

	if (!start) {

		// solver = ik.solver.create(IK_TWO_BONE);
		solver = ik.solver.create(IK_FABRIK);

		root = solver->node->create(0);
		child1 = solver->node->create_child(root, 1);
		child2 = solver->node->create_child(child1, 2);
		child1->position = ik.vec3.vec3( 0.0f, 1.0f, 0.7f);
		child2->position = ik.vec3.vec3( 0.0f, 1.0f, -0.7f);

		eff = solver->effector->create();
		solver->effector->attach(eff, child2);

		solver->flags |= IK_ENABLE_TARGET_ROTATIONS;

		ik.solver.set_tree(solver, root);
		ik.solver.rebuild(solver);

		start = true;
	}

	glm::vec3 start = glm::vec3(251.0f, 5.0f, 268.0f);

	TEST_DEBUG_IK = models[34].phys.pos - start;

	eff->target_position = ik.vec3.vec3(TEST_DEBUG_IK.x, TEST_DEBUG_IK.y, TEST_DEBUG_IK.z);

	ik.solver.solve(solver);

	glm::vec3 l1 = start + glm::vec3(child1->position.x, child1->position.y, child1->position.z);
	glm::vec3 l2 = start + glm::vec3(child2->position.x, child2->position.y, child2->position.z);

	create_DebugLine(start, l1, glm::vec4(vecColor_Red, 1.0f), 3.0f);
	create_DebugLine(l1, l2, glm::vec4(vecColor_Green, 1.0f), 3.0f);

Here are a couple more videos just for this code. First video for TWO BONES, second video for FABRIK:
1.
https://youtu.be/A3N7a8Qvp8k
2.
https://youtu.be/75f-jKEsZmI

Update:
In Fabrik mode I noticed one strange thing. The first joint (red line) does not move at all.

Hi, great demo! And I met the same issue, have you already solved it?

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

4 participants