LibGizmo: C++ Lib to Manipulate Transformation Matrices


LibGizmo
Scale and Move operations



LibGizmo is a small C++ library that brings easy matrix (4×4 floats) manipulation in your OpenGL applications. Three main functions are available to create a move, rotate and scale gizmo objects to handle the fundamental matrix operations. A draw function is also available with mouse control that allows to display the gizmos and handle them with the mouse.

Here is a code snippet to show the basic use of LibGizmo:

#include "IGizmo.h"

// The model matrix.
float objectMatrix[16];

// The three gizmos
IGizmo* gizmoMove = CreateMoveGizmo();
IGizmo* gizmoRotate = CreateRotateGizmo();
IGizmo* gizmoScale = CreateScaleGizmo();
IGizmo* cur_gizmo = NULL;

// Manipulate the position of the object.
cur_gizmo = gizmoMove;
gizmo->SetEditMatrix(objectMatrix);
gizmo->SetScreenDimension(screenWidth, screenHeight);

// Render the gizmo.
gizmo->SetCameraMatrix(viewMat, projMat);
gizmo->Draw();

Will test it asap in GeeXlab 😉

Links:

LibGizmo
Rotate operation


4 thoughts on “LibGizmo: C++ Lib to Manipulate Transformation Matrices”

  1. YulFi

    In the demo, the rotations looks strange. The rotations use the axis in object space and no in world space. After somes rotations, i’m lost.
    But usefull tool, thx !

  2. Greg

    as YulFi said, the demo looks strange after a few transformation.
    has anyone tried to integrate this, does that happen as well in a real application, is it simply the gizmo not taking the object updated transformation into account ?

  3. Eddie

    Great stuff :)
    I’ve been wishing someone will create a library like this as I never had the time do it myself.

    I’m in the process of trying to integrate the lib into my code base (My rendering API abstracted out direct access to both OpenGL and DirectX, so have to modify the OpenGL part to provide a simple vertex buffer instead of directly drawing the primitives.)

    The rotation problem that YulFi mentioned is actually not about rendering the gizmo in world-space or object space, but the axis of rotation for the object should always match the “visual-axis” of the gizmo.

    This is kinda hard to explain in words, but I’ll try… (might be easier to understand if you download Blender and try out their gizmo, you should see the difference.)

    I think the real problem is that when click on the X-axis of the gizmo, and move my mouse, the object rotate around it’s X-axis, which can be different than the gizmo’s X-axis.
    Regardless of what the object’s current X-Y-Z axis is. It should always rotate around the X-Y-Z axis that’s represented by the visual of the gizmo.
    I believe you had it right that the gizmo doesn’t rotate together with the object transformation, as that will make rotating along “world axis” difficult and that’s what users want to do most of the time.
    I think the gizmo should always be rendered according to world-axis. Blender also does this by default.

Comments are closed.