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
|
|
|
|
2015-12-11 02:46:30 +01:00
|
|
|
#define LC_PIECE_HIDDEN 0x00001
|
2015-12-14 19:01:17 +01:00
|
|
|
#define LC_PIECE_PIVOT_POINT_VALID 0x00002
|
|
|
|
#define LC_PIECE_POSITION_SELECTED 0x00004
|
|
|
|
#define LC_PIECE_POSITION_FOCUSED 0x00008
|
|
|
|
#define LC_PIECE_CONTROL_POINT_1_SELECTED 0x00010
|
|
|
|
#define LC_PIECE_CONTROL_POINT_1_FOCUSED 0x00020
|
|
|
|
#define LC_PIECE_CONTROL_POINT_2_SELECTED 0x00040
|
|
|
|
#define LC_PIECE_CONTROL_POINT_2_FOCUSED 0x00080
|
|
|
|
#define LC_PIECE_CONTROL_POINT_3_SELECTED 0x00100
|
|
|
|
#define LC_PIECE_CONTROL_POINT_3_FOCUSED 0x00200
|
|
|
|
#define LC_PIECE_CONTROL_POINT_4_SELECTED 0x00400
|
|
|
|
#define LC_PIECE_CONTROL_POINT_4_FOCUSED 0x00800
|
|
|
|
#define LC_PIECE_CONTROL_POINT_5_SELECTED 0x01000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_5_FOCUSED 0x02000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_6_SELECTED 0x04000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_6_FOCUSED 0x08000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_7_SELECTED 0x10000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_7_FOCUSED 0x20000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_8_SELECTED 0x40000
|
|
|
|
#define LC_PIECE_CONTROL_POINT_8_FOCUSED 0x80000
|
2015-12-11 02:46:30 +01:00
|
|
|
|
|
|
|
#define LC_PIECE_SELECTION_MASK (LC_PIECE_POSITION_SELECTED | 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)
|
|
|
|
#define LC_PIECE_FOCUS_MASK (LC_PIECE_POSITION_FOCUSED | 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)
|
2014-05-01 16:55:12 +02:00
|
|
|
|
|
|
|
enum lcPieceSection
|
|
|
|
{
|
2015-12-11 02:46:30 +01:00
|
|
|
LC_PIECE_SECTION_POSITION,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_1,
|
|
|
|
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,
|
|
|
|
LC_PIECE_SECTION_CONTROL_POINT_8
|
|
|
|
};
|
|
|
|
|
|
|
|
#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
|
|
|
|
2017-04-14 02:07:29 +02:00
|
|
|
virtual 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
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual bool IsSelected(lcuint32 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
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual 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
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual void SetSelected(lcuint32 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;
|
|
|
|
}
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual 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
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual bool IsFocused(lcuint32 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual void SetFocused(lcuint32 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;
|
|
|
|
}
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual lcuint32 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;
|
|
|
|
|
|
|
|
return LC_PIECE_SECTION_INVALID;
|
2014-05-01 16:55:12 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual lcuint32 GetAllowedTransforms() const override;
|
2016-05-01 02:20:37 +02:00
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual lcVector3 GetSectionPosition(lcuint32 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();
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-14 02:26:40 +02:00
|
|
|
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override;
|
|
|
|
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override;
|
|
|
|
virtual void DrawInterface(lcContext* Context) const override;
|
2014-05-01 16:55:12 +02:00
|
|
|
|
2017-06-20 03:30:54 +02:00
|
|
|
void AddRenderMeshes(lcScene& Scene, bool DrawInterface, bool Highlight) const;
|
2017-03-27 03:28:31 +02:00
|
|
|
void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) 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)
|
|
|
|
{
|
2016-05-21 03:21:21 +02:00
|
|
|
if (ControlPoints.GetSize() > 1)
|
2016-05-02 07:33:58 +02:00
|
|
|
{
|
|
|
|
mControlPoints = ControlPoints;
|
|
|
|
UpdateMesh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-12 01:05:49 +01:00
|
|
|
void SetControlPointScale(int ControlPointIndex, float Scale)
|
|
|
|
{
|
|
|
|
mControlPoints[ControlPointIndex].Scale = Scale;
|
|
|
|
UpdateMesh();
|
|
|
|
}
|
|
|
|
|
2017-04-21 02:53:42 +02:00
|
|
|
const char* GetName() const override;
|
2014-07-06 08:04:09 +02:00
|
|
|
bool IsVisible(lcStep Step);
|
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-01-23 04:28:05 +01:00
|
|
|
void SetPieceInfo(PieceInfo* Info, 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);
|
2015-12-16 01:28:40 +01:00
|
|
|
void Move(lcStep Step, bool AddKey, const lcVector3& Distance);
|
|
|
|
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
|
|
|
|
2016-03-03 01:04:49 +01:00
|
|
|
bool InsertControlPoint(const lcVector3& WorldStart, const lcVector3& WorldEnd);
|
|
|
|
bool RemoveFocusedControlPoint();
|
|
|
|
|
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
|
|
|
|
2012-03-28 03:07:18 +02:00
|
|
|
void SetColorCode(lcuint32 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
|
|
|
|
{
|
2016-04-03 01:11:39 +02:00
|
|
|
lcuint32 Section = GetFocusSection();
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
int ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_1;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2016-02-29 21:13:54 +01:00
|
|
|
lcuint32 Section = GetFocusSection();
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
int ControlPointIndex = Section - LC_PIECE_SECTION_CONTROL_POINT_1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-05-17 23:52:20 +02:00
|
|
|
public:
|
|
|
|
PieceInfo* mPieceInfo;
|
2012-03-28 03:07:18 +02:00
|
|
|
|
|
|
|
int mColorIndex;
|
|
|
|
lcuint32 mColorCode;
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
2016-02-29 21:13:54 +01:00
|
|
|
lcuint32 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
|
|
|
};
|
|
|
|
|