2017-07-19 23:20:32 +02:00
|
|
|
#pragma once
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
class PieceInfo;
|
|
|
|
|
|
|
|
#include "object.h"
|
2012-03-28 03:07:18 +02:00
|
|
|
#include "lc_colors.h"
|
2012-05-17 23:52:20 +02:00
|
|
|
#include "lc_math.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 19:12:15 +01:00
|
|
|
#define LC_PIECE_HIDDEN 0x000001
|
|
|
|
#define LC_PIECE_PIVOT_POINT_VALID 0x000002
|
|
|
|
#define LC_PIECE_POSITION_SELECTED 0x000004
|
|
|
|
#define LC_PIECE_POSITION_FOCUSED 0x000008
|
|
|
|
#define LC_PIECE_CONTROL_POINT_1_SELECTED 0x000010
|
|
|
|
#define LC_PIECE_CONTROL_POINT_1_FOCUSED 0x000020
|
|
|
|
#define LC_PIECE_CONTROL_POINT_2_SELECTED 0x000040
|
|
|
|
#define LC_PIECE_CONTROL_POINT_2_FOCUSED 0x000080
|
|
|
|
#define LC_PIECE_CONTROL_POINT_3_SELECTED 0x000100
|
|
|
|
#define LC_PIECE_CONTROL_POINT_3_FOCUSED 0x000200
|
|
|
|
#define LC_PIECE_CONTROL_POINT_4_SELECTED 0x000400
|
|
|
|
#define LC_PIECE_CONTROL_POINT_4_FOCUSED 0x000800
|
|
|
|
#define LC_PIECE_CONTROL_POINT_5_SELECTED 0x001000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_5_FOCUSED 0x002000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_6_SELECTED 0x004000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_6_FOCUSED 0x008000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_7_SELECTED 0x010000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_7_FOCUSED 0x020000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_8_SELECTED 0x040000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_8_FOCUSED 0x080000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_9_SELECTED 0x100000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_9_FOCUSED 0x200000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_10_SELECTED 0x400000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_10_FOCUSED 0x800000
|
|
|
|
|
|
|
|
#define LC_MAX_CONTROL_POINTS 10
|
|
|
|
|
|
|
|
#define LC_PIECE_CONTROL_POINT_SELECTION_MASK (LC_PIECE_CONTROL_POINT_1_SELECTED | LC_PIECE_CONTROL_POINT_2_SELECTED | LC_PIECE_CONTROL_POINT_3_SELECTED | LC_PIECE_CONTROL_POINT_4_SELECTED | LC_PIECE_CONTROL_POINT_5_SELECTED | LC_PIECE_CONTROL_POINT_6_SELECTED | LC_PIECE_CONTROL_POINT_7_SELECTED | LC_PIECE_CONTROL_POINT_8_SELECTED | LC_PIECE_CONTROL_POINT_9_SELECTED | LC_PIECE_CONTROL_POINT_10_SELECTED)
|
|
|
|
#define LC_PIECE_CONTROL_POINT_FOCUS_MASK (LC_PIECE_CONTROL_POINT_1_FOCUSED | LC_PIECE_CONTROL_POINT_2_FOCUSED | LC_PIECE_CONTROL_POINT_3_FOCUSED | LC_PIECE_CONTROL_POINT_4_FOCUSED | LC_PIECE_CONTROL_POINT_5_FOCUSED | LC_PIECE_CONTROL_POINT_6_FOCUSED | LC_PIECE_CONTROL_POINT_7_FOCUSED | LC_PIECE_CONTROL_POINT_8_FOCUSED | LC_PIECE_CONTROL_POINT_9_FOCUSED | LC_PIECE_CONTROL_POINT_10_FOCUSED)
|
|
|
|
|
|
|
|
#define LC_PIECE_SELECTION_MASK (LC_PIECE_POSITION_SELECTED | LC_PIECE_CONTROL_POINT_SELECTION_MASK)
|
|
|
|
#define LC_PIECE_FOCUS_MASK (LC_PIECE_POSITION_FOCUSED | LC_PIECE_CONTROL_POINT_FOCUS_MASK)
|
2014-05-01 16:55:12 +02:00
|
|
|
|
|
|
|
enum lcPieceSection
|
|
|
|
{
|
2015-12-11 02:46:30 +01:00
|
|
|
LC_PIECE_SECTION_POSITION,
|
2020-03-22 19:12:15 +01:00
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_FIRST,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_1 = LC_PIECE_SECTION_CONTROL_POINT_FIRST,
|
2015-12-11 02:46:30 +01:00
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_2,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_3,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_4,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_5,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_6,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_7,
|
2020-03-22 19:12:15 +01:00
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_8,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_9,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_10,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_LAST = LC_PIECE_SECTION_CONTROL_POINT_10
|
2015-12-11 02:46:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LC_PIECE_SECTION_INVALID (~0U)
|
|
|
|
|
|
|
|
struct lcPieceControlPoint
|
|
|
|
{
|
2016-02-29 21:13:54 +01:00
|
|
|
lcMatrix44 Transform;
|
2016-03-12 01:05:49 +01:00
|
|
|
float Scale;
|
2014-05-01 16:55:12 +02:00
|
|
|
};
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-01 20:42:11 +02:00
|
|
|
class lcPiece : public lcObject
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-12-11 02:46:30 +01:00
|
|
|
lcPiece(PieceInfo* Info);
|
2017-03-09 00:49:57 +01:00
|
|
|
lcPiece(const lcPiece& Other);
|
2014-05-01 20:42:11 +02:00
|
|
|
~lcPiece();
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-05-04 00:39:39 +02:00
|
|
|
lcPiece(lcPiece&&) = delete;
|
|
|
|
lcPiece& operator=(const lcPiece&) = delete;
|
|
|
|
lcPiece& operator=(lcPiece&&) = delete;
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
bool IsSelected() const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_SELECTION_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
bool IsSelected(quint32 Section) const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
2016-02-17 00:11:52 +01:00
|
|
|
Q_UNUSED(Section);
|
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
return (mState & LC_PIECE_SELECTION_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
void SetSelected(bool Selected) override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_SELECTION_MASK;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_SELECTION_MASK | LC_PIECE_FOCUS_MASK);
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
void SetSelected(quint32 Section, bool Selected) override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
2015-12-11 02:46:30 +01:00
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_PIECE_SECTION_POSITION:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_POSITION_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_POSITION_SELECTED | LC_PIECE_POSITION_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_1:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_1_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_1_SELECTED | LC_PIECE_CONTROL_POINT_1_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_2:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_2_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_2_SELECTED | LC_PIECE_CONTROL_POINT_2_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_3:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_3_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_3_SELECTED | LC_PIECE_CONTROL_POINT_3_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_4:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_4_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_4_SELECTED | LC_PIECE_CONTROL_POINT_4_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_5:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_5_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_5_SELECTED | LC_PIECE_CONTROL_POINT_5_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_6:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_6_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_6_SELECTED | LC_PIECE_CONTROL_POINT_6_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_7:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_7_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_7_SELECTED | LC_PIECE_CONTROL_POINT_7_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_8:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_8_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_8_SELECTED | LC_PIECE_CONTROL_POINT_8_FOCUSED);
|
|
|
|
break;
|
2020-03-22 19:12:15 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_9:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_9_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_9_SELECTED | LC_PIECE_CONTROL_POINT_9_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_10:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_CONTROL_POINT_10_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_CONTROL_POINT_10_SELECTED | LC_PIECE_CONTROL_POINT_10_FOCUSED);
|
|
|
|
break;
|
2015-12-11 02:46:30 +01:00
|
|
|
}
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
bool IsFocused() const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_FOCUS_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
bool IsFocused(quint32 Section) const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
2015-12-11 02:46:30 +01:00
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_PIECE_SECTION_POSITION:
|
|
|
|
return (mState & LC_PIECE_POSITION_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_1:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_1_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_2:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_2_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_3:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_3_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_4:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_4_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_5:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_5_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_6:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_6_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_7:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_7_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_8:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_8_FOCUSED) != 0;
|
2020-03-22 19:12:15 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_9:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_9_FOCUSED) != 0;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_10:
|
|
|
|
return (mState & LC_PIECE_CONTROL_POINT_10_FOCUSED) != 0;
|
2015-12-11 02:46:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
void SetFocused(quint32 Section, bool Focused) override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
2015-12-11 02:46:30 +01:00
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_PIECE_SECTION_POSITION:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_POSITION_SELECTED | LC_PIECE_POSITION_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_POSITION_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_1:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_1_SELECTED | LC_PIECE_CONTROL_POINT_1_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_1_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_2:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_2_SELECTED | LC_PIECE_CONTROL_POINT_2_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_2_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_3:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_3_SELECTED | LC_PIECE_CONTROL_POINT_3_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_3_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_4:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_4_SELECTED | LC_PIECE_CONTROL_POINT_4_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_4_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_5:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_5_SELECTED | LC_PIECE_CONTROL_POINT_5_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_5_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_6:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_6_SELECTED | LC_PIECE_CONTROL_POINT_6_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_6_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_7:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_7_SELECTED | LC_PIECE_CONTROL_POINT_7_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_7_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_8:
|
2015-12-16 01:28:40 +01:00
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_8_SELECTED | LC_PIECE_CONTROL_POINT_8_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_8_FOCUSED;
|
2015-12-11 02:46:30 +01:00
|
|
|
break;
|
2020-03-22 19:12:15 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_9:
|
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_9_SELECTED | LC_PIECE_CONTROL_POINT_9_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_9_FOCUSED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_10:
|
|
|
|
if (Focused)
|
|
|
|
mState |= (LC_PIECE_CONTROL_POINT_10_SELECTED | LC_PIECE_CONTROL_POINT_10_FOCUSED);
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_CONTROL_POINT_10_FOCUSED;
|
|
|
|
break;
|
2015-12-11 02:46:30 +01:00
|
|
|
}
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
quint32 GetFocusSection() const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (mState & LC_PIECE_POSITION_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_POSITION;
|
|
|
|
|
2015-12-11 02:46:30 +01:00
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_1_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_1;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_2_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_2;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_3_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_3;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_4_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_4;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_5_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_5;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_6_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_6;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_7_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_7;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_8_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_8;
|
|
|
|
|
2020-03-22 19:12:15 +01:00
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_9_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_9;
|
|
|
|
|
|
|
|
if (mState & LC_PIECE_CONTROL_POINT_10_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_CONTROL_POINT_10;
|
|
|
|
|
2015-12-11 02:46:30 +01:00
|
|
|
return LC_PIECE_SECTION_INVALID;
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
quint32 GetAllowedTransforms() const override;
|
2016-05-01 02:20:37 +02:00
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
lcVector3 GetSectionPosition(quint32 Section) const override
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_PIECE_SECTION_POSITION:
|
2015-12-15 02:57:22 +01:00
|
|
|
if (mState & LC_PIECE_PIVOT_POINT_VALID)
|
|
|
|
return lcMul(mPivotMatrix, mModelWorld).GetTranslation();
|
|
|
|
else
|
|
|
|
return mModelWorld.GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_1:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[0].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_2:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[1].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_3:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[2].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_4:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[3].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_5:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[4].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_6:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[5].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_7:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[6].Transform, mModelWorld).GetTranslation();
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_8:
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMul(mControlPoints[7].Transform, mModelWorld).GetTranslation();
|
2020-03-22 19:12:15 +01:00
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_9:
|
|
|
|
return lcMul(mControlPoints[8].Transform, mModelWorld).GetTranslation();
|
|
|
|
|
|
|
|
case LC_PIECE_SECTION_CONTROL_POINT_10:
|
|
|
|
return lcMul(mControlPoints[9].Transform, mModelWorld).GetTranslation();
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return lcVector3(0.0f, 0.0f, 0.0f);
|
|
|
|
}
|
|
|
|
|
2014-09-05 02:24:28 +02:00
|
|
|
void SaveLDraw(QTextStream& Stream) const;
|
2014-09-08 21:42:20 +02:00
|
|
|
bool ParseLDrawLine(QTextStream& Stream);
|
2014-09-02 05:44:51 +02:00
|
|
|
|
2015-03-21 21:12:04 +01:00
|
|
|
void SetFileLine(int Line)
|
|
|
|
{
|
|
|
|
mFileLine = Line;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetFileLine() const
|
|
|
|
{
|
|
|
|
return mFileLine;
|
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
void RayTest(lcObjectRayTest& ObjectRayTest) const override;
|
|
|
|
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override;
|
|
|
|
void DrawInterface(lcContext* Context, const lcScene& Scene) const override;
|
|
|
|
void RemoveKeyFrames() override;
|
2014-05-01 16:55:12 +02:00
|
|
|
|
2020-12-05 20:02:10 +01:00
|
|
|
void AddMainModelRenderMeshes(lcScene* Scene, bool Highlight, bool Fade) const;
|
|
|
|
void AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
2020-04-11 20:04:27 +02:00
|
|
|
void SubmodelCompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const;
|
2016-02-19 18:53:54 +01:00
|
|
|
|
2014-08-31 02:53:12 +02:00
|
|
|
void InsertTime(lcStep Start, lcStep Time);
|
|
|
|
void RemoveTime(lcStep Start, lcStep Time);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-09-02 05:44:51 +02:00
|
|
|
bool IsHidden() const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_HIDDEN) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHidden(bool Hidden)
|
|
|
|
{
|
|
|
|
if (Hidden)
|
|
|
|
mState |= LC_PIECE_HIDDEN;
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_HIDDEN;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2016-03-03 01:04:49 +01:00
|
|
|
const lcArray<lcPieceControlPoint>& GetControlPoints() const
|
|
|
|
{
|
|
|
|
return mControlPoints;
|
|
|
|
}
|
|
|
|
|
2016-05-02 07:33:58 +02:00
|
|
|
void SetControlPoints(const lcArray<lcPieceControlPoint>& ControlPoints)
|
|
|
|
{
|
2020-03-30 21:17:08 +02:00
|
|
|
mControlPoints = ControlPoints;
|
|
|
|
UpdateMesh();
|
2016-05-02 07:33:58 +02:00
|
|
|
}
|
|
|
|
|
2016-03-12 01:05:49 +01:00
|
|
|
void SetControlPointScale(int ControlPointIndex, float Scale)
|
|
|
|
{
|
|
|
|
mControlPoints[ControlPointIndex].Scale = Scale;
|
|
|
|
UpdateMesh();
|
|
|
|
}
|
|
|
|
|
2017-07-23 05:54:33 +02:00
|
|
|
const QString& GetID() const
|
|
|
|
{
|
|
|
|
return mID;
|
|
|
|
}
|
|
|
|
|
2017-07-24 04:35:18 +02:00
|
|
|
void UpdateID();
|
|
|
|
|
2020-12-14 01:27:21 +01:00
|
|
|
QString GetName() const override;
|
2019-03-13 03:51:04 +01:00
|
|
|
bool IsVisible(lcStep Step) const;
|
|
|
|
bool IsVisibleInSubModel() const;
|
2019-05-28 01:39:51 +02:00
|
|
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector<lcModelPartsEntry>& ModelParts) const;
|
2015-01-10 21:30:37 +01:00
|
|
|
void Initialize(const lcMatrix44& WorldMatrix, lcStep Step);
|
2016-02-19 18:53:54 +01:00
|
|
|
const lcBoundingBox& GetBoundingBox() const;
|
|
|
|
void CompareBoundingBox(lcVector3& Min, lcVector3& Max) const;
|
2017-07-23 05:54:33 +02:00
|
|
|
void SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait);
|
2013-08-09 06:57:18 +02:00
|
|
|
bool FileLoad(lcFile& file);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
void UpdatePosition(lcStep Step);
|
2018-01-15 20:35:15 +01:00
|
|
|
void MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance);
|
2015-12-16 01:28:40 +01:00
|
|
|
void Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix, const lcVector3& Center, const lcMatrix33& RotationFrame);
|
|
|
|
void MovePivotPoint(const lcVector3& Distance);
|
|
|
|
void RotatePivotPoint(const lcMatrix33& RotationMatrix);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-03-22 19:12:15 +01:00
|
|
|
bool CanAddControlPoint() const;
|
|
|
|
bool CanRemoveControlPoint() const;
|
|
|
|
|
2016-03-03 01:04:49 +01:00
|
|
|
bool InsertControlPoint(const lcVector3& WorldStart, const lcVector3& WorldEnd);
|
|
|
|
bool RemoveFocusedControlPoint();
|
2020-03-30 21:17:08 +02:00
|
|
|
void VerifyControlPoints(lcArray<lcPieceControlPoint>& ControlPoints) const;
|
2016-03-03 01:04:49 +01:00
|
|
|
|
2014-05-25 20:23:09 +02:00
|
|
|
lcGroup* GetTopGroup();
|
|
|
|
|
|
|
|
void SetGroup(lcGroup* Group)
|
|
|
|
{
|
|
|
|
mGroup = Group;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcGroup* GetGroup()
|
|
|
|
{
|
|
|
|
return mGroup;
|
|
|
|
}
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
lcStep GetStepShow() const
|
|
|
|
{
|
|
|
|
return mStepShow;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcStep GetStepHide() const
|
|
|
|
{
|
|
|
|
return mStepHide;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStepHide(lcStep Step)
|
|
|
|
{
|
2015-12-22 23:44:46 +01:00
|
|
|
if (Step < 2)
|
|
|
|
Step = 2;
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
mStepHide = Step;
|
2015-12-22 23:44:46 +01:00
|
|
|
|
|
|
|
if (mStepHide <= mStepShow)
|
|
|
|
SetStepShow(mStepHide - 1);
|
2014-07-06 08:04:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetStepShow(lcStep Step)
|
|
|
|
{
|
2015-12-22 23:44:46 +01:00
|
|
|
if (Step == LC_STEP_MAX)
|
|
|
|
Step = LC_STEP_MAX - 1;
|
|
|
|
|
2017-03-19 01:42:34 +01:00
|
|
|
if (mStepShow != Step)
|
|
|
|
{
|
|
|
|
mFileLine = -1;
|
|
|
|
mStepShow = Step;
|
|
|
|
}
|
2015-12-22 23:44:46 +01:00
|
|
|
|
|
|
|
if (mStepHide <= mStepShow)
|
|
|
|
mStepHide = mStepShow + 1;
|
2014-07-06 08:04:09 +02:00
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2017-12-02 21:22:04 +01:00
|
|
|
void SetColorCode(quint32 ColorCode)
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2012-03-28 03:07:18 +02:00
|
|
|
mColorCode = ColorCode;
|
|
|
|
mColorIndex = lcGetColorIndex(ColorCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetColorIndex(int ColorIndex)
|
|
|
|
{
|
|
|
|
mColorIndex = ColorIndex;
|
|
|
|
mColorCode = lcGetColorCode(ColorIndex);
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-08-31 02:53:12 +02:00
|
|
|
void SetPosition(const lcVector3& Position, lcStep Step, bool AddKey)
|
|
|
|
{
|
|
|
|
ChangeKey(mPositionKeys, Position, Step, AddKey);
|
|
|
|
}
|
|
|
|
|
2015-01-10 21:30:37 +01:00
|
|
|
void SetRotation(const lcMatrix33& Rotation, lcStep Step, bool AddKey)
|
2014-08-31 02:53:12 +02:00
|
|
|
{
|
|
|
|
ChangeKey(mRotationKeys, Rotation, Step, AddKey);
|
|
|
|
}
|
|
|
|
|
2015-12-14 19:01:17 +01:00
|
|
|
lcVector3 GetRotationCenter() const
|
|
|
|
{
|
2020-03-23 04:18:52 +01:00
|
|
|
const quint32 Section = GetFocusSection();
|
2016-04-03 01:11:39 +02:00
|
|
|
|
|
|
|
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
|
|
|
{
|
|
|
|
if (mState & LC_PIECE_PIVOT_POINT_VALID)
|
|
|
|
return lcMul31(mPivotMatrix.GetTranslation(), mModelWorld);
|
|
|
|
else
|
|
|
|
return mModelWorld.GetTranslation();
|
|
|
|
}
|
2015-12-14 19:01:17 +01:00
|
|
|
else
|
2016-04-03 01:11:39 +02:00
|
|
|
{
|
2020-03-23 04:18:52 +01:00
|
|
|
const int ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_1;
|
2016-04-03 01:11:39 +02:00
|
|
|
|
|
|
|
if (ControlPointIndex >= 0 && ControlPointIndex < mControlPoints.GetSize())
|
|
|
|
{
|
2016-04-19 20:37:50 +02:00
|
|
|
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
2016-04-03 01:11:39 +02:00
|
|
|
return lcMul31(Transform.GetTranslation(), mModelWorld);
|
|
|
|
}
|
|
|
|
|
2015-12-14 19:01:17 +01:00
|
|
|
return mModelWorld.GetTranslation();
|
2016-04-03 01:11:39 +02:00
|
|
|
}
|
2015-12-14 19:01:17 +01:00
|
|
|
}
|
|
|
|
|
2015-12-15 20:47:52 +01:00
|
|
|
lcMatrix33 GetRelativeRotation() const
|
2015-12-14 19:01:17 +01:00
|
|
|
{
|
2020-03-23 04:18:52 +01:00
|
|
|
const quint32 Section = GetFocusSection();
|
2016-02-29 21:13:54 +01:00
|
|
|
|
|
|
|
if (Section == LC_PIECE_SECTION_POSITION || Section == LC_PIECE_SECTION_INVALID)
|
|
|
|
{
|
|
|
|
if (mState & LC_PIECE_PIVOT_POINT_VALID)
|
|
|
|
return lcMatrix33(lcMul(mModelWorld, mPivotMatrix));
|
|
|
|
else
|
|
|
|
return lcMatrix33(mModelWorld);
|
|
|
|
}
|
2015-12-14 19:01:17 +01:00
|
|
|
else
|
2016-02-29 21:13:54 +01:00
|
|
|
{
|
2020-03-23 04:18:52 +01:00
|
|
|
const int ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_1;
|
2016-02-29 21:13:54 +01:00
|
|
|
|
|
|
|
if (ControlPointIndex >= 0 && ControlPointIndex < mControlPoints.GetSize())
|
|
|
|
{
|
2016-04-19 20:37:50 +02:00
|
|
|
const lcMatrix44& Transform = mControlPoints[ControlPointIndex].Transform;
|
2016-02-29 21:13:54 +01:00
|
|
|
return lcMatrix33(lcMul(Transform, mModelWorld));
|
|
|
|
}
|
|
|
|
|
|
|
|
return lcMatrix33Identity();
|
|
|
|
}
|
2015-12-14 19:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResetPivotPoint()
|
|
|
|
{
|
|
|
|
mState &= ~LC_PIECE_PIVOT_POINT_VALID;
|
2019-08-20 23:52:29 +02:00
|
|
|
mPivotMatrix = lcMatrix44Identity();
|
2015-12-14 19:01:17 +01:00
|
|
|
}
|
|
|
|
|
2012-05-17 23:52:20 +02:00
|
|
|
public:
|
|
|
|
PieceInfo* mPieceInfo;
|
2012-03-28 03:07:18 +02:00
|
|
|
|
|
|
|
int mColorIndex;
|
2017-12-02 21:22:04 +01:00
|
|
|
quint32 mColorCode;
|
2012-03-28 03:07:18 +02:00
|
|
|
|
2012-05-17 23:52:20 +02:00
|
|
|
lcMatrix44 mModelWorld;
|
2015-12-14 19:01:17 +01:00
|
|
|
lcMatrix44 mPivotMatrix;
|
2012-05-17 23:52:20 +02:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
protected:
|
2016-02-19 18:53:54 +01:00
|
|
|
void UpdateMesh();
|
|
|
|
|
2015-12-14 19:01:17 +01:00
|
|
|
bool IsPivotPointVisible() const
|
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_PIVOT_POINT_VALID) && IsFocused();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AreControlPointsVisible() const
|
2015-12-11 02:46:30 +01:00
|
|
|
{
|
|
|
|
return IsSelected();
|
|
|
|
}
|
|
|
|
|
2014-08-31 02:53:12 +02:00
|
|
|
lcArray<lcObjectKey<lcVector3>> mPositionKeys;
|
2015-01-10 21:30:37 +01:00
|
|
|
lcArray<lcObjectKey<lcMatrix33>> mRotationKeys;
|
2014-08-31 02:53:12 +02:00
|
|
|
|
2015-03-21 21:12:04 +01:00
|
|
|
int mFileLine;
|
2017-07-23 05:54:33 +02:00
|
|
|
QString mID;
|
2015-03-21 21:12:04 +01:00
|
|
|
|
2014-08-07 17:22:33 +02:00
|
|
|
lcGroup* mGroup;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
lcStep mStepShow;
|
|
|
|
lcStep mStepHide;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2017-12-02 21:22:04 +01:00
|
|
|
quint32 mState;
|
2015-12-11 02:46:30 +01:00
|
|
|
lcArray<lcPieceControlPoint> mControlPoints;
|
2016-02-19 18:53:54 +01:00
|
|
|
lcMesh* mMesh;
|
2011-09-07 23:06:51 +02:00
|
|
|
};
|