2011-09-07 21:06:51 +00:00
|
|
|
#ifndef _VIEW_H_
|
|
|
|
#define _VIEW_H_
|
|
|
|
|
2013-08-09 04:57:18 +00:00
|
|
|
#include "lc_glwidget.h"
|
2014-05-03 21:16:48 +00:00
|
|
|
#include "camera.h"
|
2017-04-01 16:53:54 -07:00
|
|
|
#include "lc_scene.h"
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2014-05-17 23:03:05 +00:00
|
|
|
enum lcTrackButton
|
|
|
|
{
|
|
|
|
LC_TRACKBUTTON_NONE,
|
|
|
|
LC_TRACKBUTTON_LEFT,
|
|
|
|
LC_TRACKBUTTON_MIDDLE,
|
|
|
|
LC_TRACKBUTTON_RIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum lcTrackTool
|
|
|
|
{
|
|
|
|
LC_TRACKTOOL_NONE,
|
|
|
|
LC_TRACKTOOL_INSERT,
|
|
|
|
LC_TRACKTOOL_POINTLIGHT,
|
|
|
|
LC_TRACKTOOL_SPOTLIGHT,
|
|
|
|
LC_TRACKTOOL_CAMERA,
|
|
|
|
LC_TRACKTOOL_SELECT,
|
|
|
|
LC_TRACKTOOL_MOVE_X,
|
|
|
|
LC_TRACKTOOL_MOVE_Y,
|
|
|
|
LC_TRACKTOOL_MOVE_Z,
|
|
|
|
LC_TRACKTOOL_MOVE_XY,
|
|
|
|
LC_TRACKTOOL_MOVE_XZ,
|
|
|
|
LC_TRACKTOOL_MOVE_YZ,
|
|
|
|
LC_TRACKTOOL_MOVE_XYZ,
|
|
|
|
LC_TRACKTOOL_ROTATE_X,
|
|
|
|
LC_TRACKTOOL_ROTATE_Y,
|
|
|
|
LC_TRACKTOOL_ROTATE_Z,
|
|
|
|
LC_TRACKTOOL_ROTATE_XY,
|
|
|
|
LC_TRACKTOOL_ROTATE_XYZ,
|
2016-03-12 00:05:49 +00:00
|
|
|
LC_TRACKTOOL_SCALE_PLUS,
|
|
|
|
LC_TRACKTOOL_SCALE_MINUS,
|
2014-05-17 23:03:05 +00:00
|
|
|
LC_TRACKTOOL_ERASER,
|
|
|
|
LC_TRACKTOOL_PAINT,
|
|
|
|
LC_TRACKTOOL_ZOOM,
|
|
|
|
LC_TRACKTOOL_PAN,
|
|
|
|
LC_TRACKTOOL_ORBIT_X,
|
|
|
|
LC_TRACKTOOL_ORBIT_Y,
|
|
|
|
LC_TRACKTOOL_ORBIT_XY,
|
|
|
|
LC_TRACKTOOL_ROLL,
|
|
|
|
LC_TRACKTOOL_ZOOM_REGION
|
|
|
|
};
|
|
|
|
|
2014-05-26 22:58:08 +00:00
|
|
|
enum lcDragState
|
|
|
|
{
|
|
|
|
LC_DRAGSTATE_NONE,
|
|
|
|
LC_DRAGSTATE_PIECE
|
|
|
|
// LC_DRAGSTATE_COLOR
|
|
|
|
};
|
|
|
|
|
2013-08-09 04:57:18 +00:00
|
|
|
class View : public lcGLWidget
|
2011-09-07 21:06:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-12-08 07:32:39 +00:00
|
|
|
View(lcModel* Model);
|
2012-02-05 02:50:57 +00:00
|
|
|
virtual ~View();
|
|
|
|
|
2017-06-20 08:06:40 -07:00
|
|
|
void SetHighlight(bool Highlight)
|
|
|
|
{
|
|
|
|
mHighlight = Highlight;
|
|
|
|
}
|
|
|
|
|
2015-04-27 00:47:31 +00:00
|
|
|
static void CreateResources(lcContext* Context);
|
|
|
|
static void DestroyResources(lcContext* Context);
|
|
|
|
|
2012-02-05 02:50:57 +00:00
|
|
|
void OnDraw();
|
|
|
|
void OnInitialUpdate();
|
2013-08-09 04:57:18 +00:00
|
|
|
void OnUpdateCursor();
|
|
|
|
void OnLeftButtonDown();
|
|
|
|
void OnLeftButtonUp();
|
|
|
|
void OnLeftButtonDoubleClick();
|
|
|
|
void OnMiddleButtonDown();
|
|
|
|
void OnMiddleButtonUp();
|
|
|
|
void OnRightButtonDown();
|
|
|
|
void OnRightButtonUp();
|
2015-09-06 19:52:17 +00:00
|
|
|
void OnBackButtonUp();
|
|
|
|
void OnForwardButtonUp();
|
2013-08-09 04:57:18 +00:00
|
|
|
void OnMouseMove();
|
|
|
|
void OnMouseWheel(float Direction);
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2014-11-29 02:55:58 +00:00
|
|
|
void CancelTrackingOrClearSelection();
|
2014-05-26 22:58:08 +00:00
|
|
|
void BeginPieceDrag();
|
|
|
|
void EndPieceDrag(bool Accept);
|
2014-11-30 17:53:09 +00:00
|
|
|
|
|
|
|
void SetProjection(bool Ortho);
|
|
|
|
void LookAt();
|
2014-11-08 01:05:17 +00:00
|
|
|
void ZoomExtents();
|
2014-05-26 22:58:08 +00:00
|
|
|
|
2014-11-25 00:51:34 +00:00
|
|
|
void RemoveCamera();
|
2014-11-08 01:05:17 +00:00
|
|
|
void SetCamera(lcCamera* Camera, bool ForceCopy);
|
2017-06-20 21:43:39 -07:00
|
|
|
void SetCamera(const char* CameraName);
|
2014-11-25 00:51:34 +00:00
|
|
|
void SetCameraIndex(int Index);
|
2014-11-08 01:05:17 +00:00
|
|
|
void SetViewpoint(lcViewpoint Viewpoint);
|
2012-08-20 04:05:56 +00:00
|
|
|
void SetDefaultCamera();
|
2014-05-03 01:22:24 +00:00
|
|
|
lcMatrix44 GetProjectionMatrix() const;
|
2012-07-31 05:27:40 +00:00
|
|
|
LC_CURSOR_TYPE GetCursor() const;
|
2015-12-04 20:32:10 +00:00
|
|
|
void ShowContextMenu() const;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2014-11-30 17:53:09 +00:00
|
|
|
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
2015-01-10 20:30:37 +00:00
|
|
|
lcMatrix44 GetPieceInsertPosition() const;
|
2016-03-03 00:04:49 +00:00
|
|
|
void GetRayUnderPointer(lcVector3& Start, lcVector3& End) const;
|
2014-05-03 16:59:57 +00:00
|
|
|
lcObjectSection FindObjectUnderPointer(bool PiecesOnly) const;
|
2014-11-29 02:55:58 +00:00
|
|
|
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
|
2014-05-03 16:59:57 +00:00
|
|
|
|
2014-12-08 07:32:39 +00:00
|
|
|
lcModel* mModel;
|
2014-05-17 23:03:05 +00:00
|
|
|
lcCamera* mCamera;
|
2013-12-17 02:43:16 +00:00
|
|
|
|
2014-05-03 06:08:52 +00:00
|
|
|
lcVector3 ProjectPoint(const lcVector3& Point) const
|
|
|
|
{
|
|
|
|
int Viewport[4] = { 0, 0, mWidth, mHeight };
|
|
|
|
return lcProjectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
|
|
|
|
}
|
|
|
|
|
|
|
|
lcVector3 UnprojectPoint(const lcVector3& Point) const
|
|
|
|
{
|
|
|
|
int Viewport[4] = { 0, 0, mWidth, mHeight };
|
|
|
|
return lcUnprojectPoint(Point, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnprojectPoints(lcVector3* Points, int NumPoints) const
|
|
|
|
{
|
|
|
|
int Viewport[4] = { 0, 0, mWidth, mHeight };
|
|
|
|
lcUnprojectPoints(Points, NumPoints, mCamera->mWorldView, GetProjectionMatrix(), Viewport);
|
|
|
|
}
|
2014-05-17 23:03:05 +00:00
|
|
|
|
|
|
|
protected:
|
2015-04-27 00:47:31 +00:00
|
|
|
static void CreateSelectMoveOverlayMesh(lcContext* Context);
|
|
|
|
|
2014-05-17 23:03:05 +00:00
|
|
|
void DrawSelectMoveOverlay();
|
|
|
|
void DrawRotateOverlay();
|
|
|
|
void DrawSelectZoomRegionOverlay();
|
|
|
|
void DrawRotateViewOverlay();
|
2014-08-23 22:56:59 +00:00
|
|
|
void DrawGrid();
|
|
|
|
void DrawAxes();
|
2014-05-17 23:03:05 +00:00
|
|
|
void DrawViewport();
|
|
|
|
|
|
|
|
void UpdateTrackTool();
|
2016-05-01 00:20:37 +00:00
|
|
|
bool IsTrackToolAllowed(lcTrackTool TrackTool, lcuint32 AllowedTransforms) const;
|
2014-05-17 23:03:05 +00:00
|
|
|
lcTool GetCurrentTool() const;
|
2016-04-23 00:17:33 +00:00
|
|
|
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
|
2014-05-17 23:03:05 +00:00
|
|
|
float GetOverlayScale() const;
|
|
|
|
void StartTracking(lcTrackButton TrackButton);
|
|
|
|
void StopTracking(bool Accept);
|
2016-05-09 01:59:10 +00:00
|
|
|
void OnButtonDown(lcTrackButton TrackButton);
|
2014-05-17 23:03:05 +00:00
|
|
|
|
2015-02-08 18:54:51 +00:00
|
|
|
lcScene mScene;
|
2014-05-26 22:58:08 +00:00
|
|
|
lcDragState mDragState;
|
2014-05-17 23:03:05 +00:00
|
|
|
lcTrackButton mTrackButton;
|
|
|
|
lcTrackTool mTrackTool;
|
2016-05-19 21:16:31 +00:00
|
|
|
bool mTrackUpdated;
|
2014-05-17 23:03:05 +00:00
|
|
|
int mMouseDownX;
|
|
|
|
int mMouseDownY;
|
2017-06-20 08:06:40 -07:00
|
|
|
bool mHighlight;
|
2015-04-14 04:14:10 +00:00
|
|
|
|
2015-04-26 18:14:33 +00:00
|
|
|
lcVertexBuffer mGridBuffer;
|
2015-04-14 04:14:10 +00:00
|
|
|
int mGridSettings[7];
|
2015-04-27 00:47:31 +00:00
|
|
|
|
|
|
|
static lcVertexBuffer mRotateMoveVertexBuffer;
|
|
|
|
static lcIndexBuffer mRotateMoveIndexBuffer;
|
2011-09-07 21:06:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _VIEW_H_
|