Jump to content

LeapMotion Camera Rotation Issue


photo

Recommended Posts

Hi, 

Now I am using leap motion plugin.

The problem I met is that

In the demo project, the function 

    Vec3 leap_pos_to_world_pos(const Unigine::Math::vec3 &pos)
    {
        Vec3 wpos(pos);
        std::swap(wpos.y, wpos.z);
        wpos.y = -wpos.y;
        wpos.x -= lm->getBaseline() / 2;

        auto iwt = main_camera->getIWorldTransform();
        iwt.setRotateZ(180);

        return iwt * Vec3(wpos);
    }

is Ok for the demo, but when I rotate the main_camera, this position transformation function doesn't support, it only support the camera whose rotaion is (180,0,0).

and I am confused by the following code:

        auto iwt = main_camera->getIWorldTransform();
        iwt.setRotateZ(180);

could you explain the above codes for me? Thanks.

And if I want the main_camera to be the VR camera, which is not a static one and can rotate all the time, how should I  make the transformation for the camera transform?

 Thanks.

Link to comment

Hi! This demo isn't generic. If you want to "attach" hands to camera try use this code. This can help for your case.

At first, hands coordinate system is world, then you need move them to camera and correct rotation.

It works for "main_camera" random transformations.

Vec3 leap_pos_to_world_pos(const Unigine::Math::vec3 &pos)
{
	Vec3 wpos(pos);
	std::swap(wpos.y, wpos.z);
	wpos.y = -wpos.y;
	wpos.x -= lm->getBaseline() / 2;

	return main_camera->getWorldTransform() * rotate(Vec3::RIGHT, 180.0) * rotate(Vec3::UP, 180.0) * Vec3(wpos);
}

 

Link to comment
×
×
  • Create New...