You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/Editor/Objects/AxisGizmo.h

90 lines
2.7 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef CRYINCLUDE_EDITOR_OBJECTS_AXISGIZMO_H
#define CRYINCLUDE_EDITOR_OBJECTS_AXISGIZMO_H
#pragma once
#include "BaseObject.h"
#include "Gizmo.h"
#include "Include/ITransformManipulator.h"
// forward declarations.
struct DisplayContext;
class CAxisHelper;
/** Gizmo of Objects animation track.
*/
class SANDBOX_API CAxisGizmo
: public CGizmo
, public ITransformManipulator
, public CBaseObject::EventListener
{
public:
CAxisGizmo();
// Creates axis gizmo linked to an object.
CAxisGizmo(CBaseObject* object);
~CAxisGizmo();
//////////////////////////////////////////////////////////////////////////
// Ovverides from CGizmo
//////////////////////////////////////////////////////////////////////////
virtual void GetWorldBounds(AABB& bbox);
virtual void Display(DisplayContext& dc);
virtual bool HitTest(HitContext& hc);
virtual const Matrix34& GetMatrix() const;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// ITransformManipulator implementation.
//////////////////////////////////////////////////////////////////////////
virtual Matrix34 GetTransformation(RefCoordSys coordSys, IDisplayViewport* view = nullptr) const;
virtual void SetTransformation(RefCoordSys coordSys, const Matrix34& tm);
virtual bool HitTestManipulator(HitContext& hc);
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int nFlags);
virtual void SetAlwaysUseLocal(bool on)
{ m_bAlwaysUseLocal = on; }
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void SetWorldBounds(const AABB& bbox);
void DrawAxis(DisplayContext& dc);
static int GetGlobalAxisGizmoCount() { return m_axisGizmoCount; }
CBaseObjectPtr GetBaseObject() const override { return m_object; }
private:
void OnObjectEvent(CBaseObject* object, int event) override;
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
CBaseObjectPtr m_object;
AABB m_bbox;
std::unique_ptr<CAxisHelper> m_pAxisHelper;
bool m_bDragging;
QPoint m_cMouseDownPos;
Vec3 m_initPos;
int m_highlightAxis;
Matrix34 m_localTM;
Matrix34 m_parentTM;
Matrix34 m_userTM;
bool m_bAlwaysUseLocal;
RefCoordSys m_coordSysBackUp;
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
static int m_axisGizmoCount;
};
#endif // CRYINCLUDE_EDITOR_OBJECTS_AXISGIZMO_H