mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
88 lines
4.9 KiB
C++
88 lines
4.9 KiB
C++
#pragma once
|
|
|
|
#include "lc_context.h"
|
|
|
|
#include <optional>
|
|
|
|
class lcViewManipulator
|
|
{
|
|
public:
|
|
lcViewManipulator(lcView* View);
|
|
|
|
void DrawSelectMove(lcTrackButton TrackButton, lcTrackTool TrackTool, quint32 TrackToolSection);
|
|
void DrawRotate(lcTrackButton TrackButton, lcTrackTool TrackTool);
|
|
|
|
std::pair<lcTrackTool, quint32> UpdateSelectMove(lcTrackButton TrackButton);
|
|
lcTrackTool UpdateRotate();
|
|
|
|
static void CreateResources(lcContext* Context);
|
|
static void DestroyResources(lcContext* Context);
|
|
|
|
protected:
|
|
struct lcRotationDiscInfo
|
|
{
|
|
int AxisIndex;
|
|
float Radius;
|
|
lcVector4 Rotation;
|
|
lcVector4 FillColor;
|
|
lcVector4 HighlightColor;
|
|
bool CameraFacing;
|
|
};
|
|
|
|
struct lcMoveAxisInfo
|
|
{
|
|
lcVector4 Color;
|
|
};
|
|
|
|
void DrawTrainTrack(lcPiece* Piece, lcContext* Context, lcTrackTool TrackTool, quint32 TrackToolSection);
|
|
std::tuple<lcTrackTool, quint32, float> UpdateSelectMoveTrainTrack(lcPiece* Piece, float OverlayScale, const lcVector3& Start, const lcVector3& End) const;
|
|
|
|
static bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms);
|
|
bool GetRotationWorldMatrix(lcMatrix44& WorldMatrix) const;
|
|
static lcTrackTool GetRotationAxis(const lcVector3& LocalIntersection, float Epsilon);
|
|
static std::optional<lcRotationDiscInfo> GetRotationDiscInfo(lcTrackTool TrackTool);
|
|
static std::optional<lcMoveAxisInfo> GetMoveAxisInfo(lcTrackTool TrackTool);
|
|
lcMatrix44 GetRotationDiscWorldMatrix(const lcRotationDiscInfo& DiscInfo, const lcMatrix44& WorldMatrix) const;
|
|
float GetRotationDiscStartAngle(const lcRotationDiscInfo& DiscInfo, const lcMatrix44& DiscWorldMatrix) const;
|
|
void DrawTrackballHover(const lcMatrix44& WorldMatrix, float OverlayScale) const;
|
|
bool DrawRotationDisc(lcTrackButton TrackButton, const lcVector3& MouseToolDistance, const std::optional<lcRotationDiscInfo>& RotationDisc, const lcMatrix44& WorldMatrix, float OverlayScale) const;
|
|
void DrawCameraRotationRing(lcTrackButton TrackButton, lcTrackTool TrackTool, const lcMatrix44& WorldMatrix, float OverlayScale) const;
|
|
void DrawAxisRotationRings(lcTrackButton TrackButton, lcTrackTool TrackTool, bool HasAngle, const lcMatrix44& WorldMatrix, float OverlayScale) const;
|
|
void DrawRotationText(lcTrackButton TrackButton, const lcVector3& MouseToolDistance, const std::optional<lcRotationDiscInfo>& RotationDisc, const lcMatrix44& WorldMatrix, float OverlayScale) const;
|
|
void DrawMoveDistance(lcTrackButton TrackButton, lcTrackTool TrackTool, const lcVector3& StartPosition, const lcVector3& EndPosition, float Distance) const;
|
|
|
|
lcView* mView = nullptr;
|
|
|
|
static lcVertexBuffer mRotateMoveVertexBuffer;
|
|
static lcIndexBuffer mRotateMoveIndexBuffer;
|
|
|
|
static constexpr lcVector4 mColorXAxis = lcVector4(200.0f / 255.0f, 40.0f / 255.0f, 60.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorYAxis = lcVector4(100.0f / 255.0f, 200.0f / 255.0f, 20.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorZAxis = lcVector4( 40.0f / 255.0f, 60.0f / 255.0f, 230.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorCamera = lcVector4(190.0f / 255.0f, 190.0f / 255.0f, 190.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorTrackball = lcVector4(120.0f / 255.0f, 120.0f / 255.0f, 120.0f / 255.0f, 30.0f / 255.0f);
|
|
static constexpr lcVector4 mColorXAxisSelected = lcVector4(245.0f / 255.0f, 110.0f / 255.0f, 150.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorYAxisSelected = lcVector4(175.0f / 255.0f, 233.0f / 255.0f, 100.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorZAxisSelected = lcVector4(118.0f / 255.0f, 162.0f / 255.0f, 244.0f / 255.0f, 255.0f / 255.0f);
|
|
static constexpr lcVector4 mColorCameraSelected = lcVector4(230.0f / 255.0f, 230.0f / 255.0f, 230.0f / 255.0f, 255.0f / 255.0f);
|
|
|
|
static constexpr float mOverlayRotateRadius = 2.0f;
|
|
static constexpr float mOverlayRotateCameraRadius = 2.5f;
|
|
|
|
static constexpr int mMoveIndexStart = 0;
|
|
static constexpr int mMoveIndexCount = 36;
|
|
static constexpr int mRotateIndexStart = mMoveIndexStart + mMoveIndexCount * 3;
|
|
static constexpr int mRotateIndexCount = 120;
|
|
static constexpr int mMovePlaneIndexStart = mRotateIndexStart + mRotateIndexCount * 3;
|
|
static constexpr int mMovePlaneIndexCount = 4;
|
|
static constexpr int mTrainTrackRotateIndexStart = mMovePlaneIndexStart + mMovePlaneIndexCount * 3;
|
|
static constexpr int mTrainTrackRotateIndexCount = 96;
|
|
static constexpr int mTrainTrackInsertIndexStart = mTrainTrackRotateIndexStart + mTrainTrackRotateIndexCount * 2;
|
|
static constexpr int mTrainTrackInsertIndexCount = 72;
|
|
static constexpr int mTrainTrackConnectionIndexStart = mTrainTrackInsertIndexStart + mTrainTrackInsertIndexCount;
|
|
static constexpr int mTrainTrackConnectionIndexCount = 36;
|
|
static constexpr int mIndexCount = mTrainTrackConnectionIndexStart + mTrainTrackConnectionIndexCount;
|
|
static const GLushort mRotateMoveIndices[mIndexCount];
|
|
static lcVector3 mRotateMoveVertices[51 + 138 + 10 + 74 + 28 + 24];
|
|
};
|