File Gizmo.h

namespace Ogre

File: MovableText.h

Description: This creates a billboarding object that display a text. Note: This object must have a dedicated scene node since it will rotate it to face the camera (OGRE 2.1)

Author

2003 by cTh see gavocanov@rambler.ru 2006 by barraq see nospam@barraquand.com 2012 to work with newer versions of OGRE by MindCalamity mindcalamity@gmail.com 2015 to work on OGRE 2.1 (but not on older versions anymore) by Jayray jeremy.richert1@gmail.com

namespace Gsage
class Gizmo : public EventSubscriber<Gizmo>
#include <Gizmo.h>

Transformation Gizmo, supports move, scale and rotate operations.

Lua usage example:

-- create gizmo
gizmo = imgui.createGizmo()

-- setting target
local render = eal:getEntity("test").render
if render == nil then
  exit(1)
end
gizmo:addTarget(render.root)

-- enable
gizmo:enable(true)

-- render on each ImGUI cycle
gizmo:render(0, 0, 320, 240)

-- changing mode
gizmo.mode = imgui.gizmo.WORLD

-- changing operation
gizmo.operation = imgui.gizmo.ROTATE

-- draw coordinates editor for this gizmo
-- it is separate to make it possible to draw it in the separate window
gizmo:drawCoordinatesEditor(1, 0, 0, "%.3f", 1,
"position",
"scale",
"rotation")

Public Functions

Gizmo(OgreRenderSystem *rs)
virtual ~Gizmo()
void render(float x, float y, const std::string &rttName)

Render gizmo UI

void enable(bool value)

Enable/disable gizmo

void addTarget(SceneNodeWrapper *target)

Set target

void removeTarget(const SceneNodeWrapper *target)

Remove target

void resetTargets()

Reset all targets in Gizmo

void setOperation(ImGuizmo::OPERATION value)

Set gizmo operation

ImGuizmo::OPERATION getOperation() const

Get gizmo operation

void setMode(ImGuizmo::MODE value)

Set gizmo mode

ImGuizmo::MODE getMode() const

Get gizmo mode

bool drawCoordinatesEditor(float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const std::string &display_format = "%.3f", float power = 1.0f, const std::string &posLabel = "position", const std::string &scaleLabel = "scale", const std::string &rotationLabel = "rotation")

Draw coordinates editor

Private Types

typedef std::vector<SceneNodeWrapper *> Targets
typedef std::map<const SceneNodeWrapper *, Ogre::Vector3> Positions

Private Functions

const Ogre::Vector3 &getPosition()
const Ogre::Vector3 &getScale()
const Ogre::Quaternion &getOrientation()
bool onTargetDestroyed(EventDispatcher *sender, const Event &event)
void updateTargetNode(bool reset = true)
void rotate(float delta[3])
void setScale(float scale[3])
bool extractMatrix(Ogre::Matrix4, float *dest, int length)

Private Members

OgreRenderSystem *mRenderSystem
Targets mTargets
Positions mPositions
Positions mInitialPositions
Positions mInitialScales
float mModelMatrix[16]
Ogre::Vector3 mPosition
Ogre::Vector3 mScale
Ogre::Quaternion mOrientation
ImGuizmo::OPERATION mOperation
ImGuizmo::MODE mMode
bool mEnabled
bool mUsing