leocad/common/piece.h

120 lines
2.5 KiB
C
Raw Normal View History

2011-09-07 23:06:51 +02:00
#ifndef _PIECE_H_
#define _PIECE_H_
class Piece;
class Group;
class PieceInfo;
#include "object.h"
2012-03-28 03:07:18 +02:00
#include "lc_colors.h"
#include "lc_math.h"
2011-09-07 23:06:51 +02:00
#define LC_PIECE_HIDDEN 0x01
#define LC_PIECE_SELECTED 0x02
#define LC_PIECE_FOCUSED 0x04
enum LC_PK_TYPES
2011-09-07 23:06:51 +02:00
{
LC_PK_POSITION,
LC_PK_ROTATION,
LC_PK_COUNT
};
2011-09-07 23:06:51 +02:00
class Piece : public Object
{
public:
Piece (PieceInfo* pPieceInfo);
~Piece ();
2014-01-30 04:13:34 +01:00
void Select(bool bSelecting, bool bFocus, bool bMultiple);
virtual void InsertTime(unsigned short start, unsigned short time);
virtual void RemoveTime(unsigned short start, unsigned short time);
2012-08-23 20:47:37 +02:00
virtual bool IntersectsVolume(const lcVector4 Planes[6]) const;
2011-09-07 23:06:51 +02:00
Piece* m_pNext;
void Hide()
{ m_nState = LC_PIECE_HIDDEN; }
void UnHide()
{ m_nState &= ~LC_PIECE_HIDDEN; }
bool IsHidden()
{ return (m_nState & LC_PIECE_HIDDEN) != 0; }
bool IsSelected()
{ return (m_nState & LC_PIECE_SELECTED) != 0; }
bool IsFocused()
{ return (m_nState & LC_PIECE_FOCUSED) != 0; }
const char* GetName() const
2013-08-09 06:57:18 +02:00
{ return m_strName; }
2011-09-07 23:06:51 +02:00
2012-08-17 01:50:40 +02:00
virtual void MinIntersectDist(lcClickLine* ClickLine);
2014-01-30 04:13:34 +01:00
bool IsVisible(unsigned short nTime);
void Initialize(float x, float y, float z, unsigned char nStep);
2011-09-07 23:06:51 +02:00
void CreateName(Piece* pPiece);
void CompareBoundingBox(float box[6]);
void SetPieceInfo(PieceInfo* pPieceInfo);
2013-08-09 06:57:18 +02:00
bool FileLoad(lcFile& file);
void FileSave(lcFile& file) const;
2011-09-07 23:06:51 +02:00
2014-01-30 04:13:34 +01:00
void UpdatePosition(unsigned short nTime);
void Move(unsigned short nTime, bool bAddKey, float dx, float dy, float dz);
2011-09-07 23:06:51 +02:00
void DoGroup(Group* pGroup);
void UnGroup(Group* pGroup);
Group* GetTopGroup();
void SetGroup(Group* pGroup)
{ m_pGroup = pGroup; }
Group* GetGroup()
{ return m_pGroup; }
void SetName(char* name)
{ strcpy(m_strName, name); }
const char* GetName()
{ return m_strName; }
void SetStepShow(unsigned char step)
{ m_nStepShow = step; }
2013-01-06 20:24:25 +01:00
unsigned char GetStepShow()
2011-09-07 23:06:51 +02:00
{ return m_nStepShow; }
void SetStepHide(unsigned char step)
{ m_nStepHide = step; }
2013-01-06 20:24:25 +01:00
unsigned char GetStepHide()
{ return (unsigned char)m_nStepHide; }
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
public:
PieceInfo* mPieceInfo;
2012-03-28 03:07:18 +02:00
int mColorIndex;
lcuint32 mColorCode;
lcMatrix44 mModelWorld;
lcVector3 mPosition;
lcVector4 mRotation;
2011-09-07 23:06:51 +02:00
protected:
// Atributes
Group* m_pGroup;
lcuint8 m_nStepShow;
lcuint8 m_nStepHide;
2011-09-07 23:06:51 +02:00
lcuint8 m_nState;
2011-09-07 23:06:51 +02:00
char m_strName[81];
};
#endif // _PIECE_H