2011-09-07 23:06:51 +02:00
|
|
|
#ifndef _PIECE_H_
|
|
|
|
#define _PIECE_H_
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
#define LC_PIECE_HIDDEN 0x01
|
|
|
|
#define LC_PIECE_POSITION_SELECTED 0x02
|
|
|
|
#define LC_PIECE_POSITION_FOCUSED 0x04
|
|
|
|
|
|
|
|
#define LC_PIECE_SELECTION_MASK (LC_PIECE_POSITION_SELECTED)
|
|
|
|
#define LC_PIECE_FOCUS_MASK (LC_PIECE_POSITION_FOCUSED)
|
|
|
|
|
|
|
|
enum lcPieceSection
|
|
|
|
{
|
|
|
|
LC_PIECE_SECTION_POSITION
|
|
|
|
};
|
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:
|
2014-05-01 20:42:11 +02:00
|
|
|
lcPiece(PieceInfo* pPieceInfo);
|
|
|
|
~lcPiece();
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
virtual bool IsSelected() const
|
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_SELECTION_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual bool IsSelected(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_SELECTION_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
virtual void SetSelected(bool Selected)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual void SetSelected(lcuint32 Section, bool Selected)
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_PIECE_POSITION_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_PIECE_SELECTION_MASK | LC_PIECE_FOCUS_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsFocused() const
|
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_FOCUS_MASK) != 0;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual bool IsFocused(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_PIECE_FOCUS_MASK) != 0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual void SetFocused(lcuint32 Section, bool Focused)
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (Focused)
|
|
|
|
mState |= LC_PIECE_POSITION_SELECTED | LC_PIECE_POSITION_FOCUSED;
|
|
|
|
else
|
|
|
|
mState &= ~LC_PIECE_FOCUS_MASK;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual lcuint32 GetFocusSection() const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (mState & LC_PIECE_POSITION_FOCUSED)
|
|
|
|
return LC_PIECE_SECTION_POSITION;
|
|
|
|
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual lcVector3 GetSectionPosition(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_PIECE_SECTION_POSITION:
|
2015-01-10 21:30:37 +01:00
|
|
|
return 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;
|
|
|
|
}
|
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
|
|
|
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
2015-05-17 01:04:35 +02:00
|
|
|
virtual void DrawInterface(lcContext* Context) const;
|
2014-05-01 16:55:12 +02: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
|
|
|
|
2015-01-15 03:21:10 +01:00
|
|
|
const char* GetName() const;
|
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);
|
2011-09-07 23:06:51 +02:00
|
|
|
void CompareBoundingBox(float box[6]);
|
|
|
|
void SetPieceInfo(PieceInfo* pPieceInfo);
|
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);
|
|
|
|
void Move(lcStep Step, bool AddKey, const lcVector3& Distance);
|
2011-09-07 23:06:51 +02: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)
|
|
|
|
{
|
|
|
|
mStepHide = Step;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStepShow(lcStep Step)
|
|
|
|
{
|
2015-03-21 21:12:04 +01:00
|
|
|
mFileLine = -1;
|
2014-07-06 08:04:09 +02:00
|
|
|
mStepShow = Step;
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
protected:
|
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;
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
// Atributes
|
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
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
lcuint8 mState;
|
2011-09-07 23:06:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _PIECE_H
|