leocad/common/object.h

116 lines
3.2 KiB
C
Raw Normal View History

#pragma once
2011-09-07 23:06:51 +02:00
2012-08-17 01:50:40 +02:00
#include "lc_math.h"
#include "lc_objectproperty.h"
2012-08-17 01:50:40 +02:00
2020-04-19 04:45:21 +02:00
enum class lcObjectType
2011-09-07 23:06:51 +02:00
{
2020-04-19 04:45:21 +02:00
Piece,
Camera,
Light
2012-08-17 01:50:40 +02:00
};
2011-09-07 23:06:51 +02:00
struct lcObjectSection
{
lcObject* Object = nullptr;
quint32 Section = 0;
};
struct lcPieceInfoRayTest
{
2022-01-09 21:54:45 +01:00
const PieceInfo* Info = nullptr;
lcMatrix44 Transform;
lcVector3 Plane;
};
struct lcObjectRayTest
2011-09-07 23:06:51 +02:00
{
2014-05-03 18:59:57 +02:00
lcCamera* ViewCamera;
bool PiecesOnly;
2017-11-13 04:38:07 +01:00
bool IgnoreSelected;
2012-08-17 01:50:40 +02:00
lcVector3 Start;
lcVector3 End;
float Distance = FLT_MAX;
lcObjectSection ObjectSection;
lcPieceInfoRayTest PieceInfoRayTest;
};
struct lcObjectBoxTest
{
2014-05-03 18:59:57 +02:00
lcCamera* ViewCamera;
lcVector4 Planes[6];
2024-05-26 22:01:34 +02:00
std::vector<lcObject*> Objects;
2014-11-29 03:55:58 +01:00
};
2023-09-04 19:59:16 +02:00
#define LC_OBJECT_TRANSFORM_MOVE_X 0x001
#define LC_OBJECT_TRANSFORM_MOVE_Y 0x002
#define LC_OBJECT_TRANSFORM_MOVE_Z 0x004
#define LC_OBJECT_TRANSFORM_MOVE_XYZ (LC_OBJECT_TRANSFORM_MOVE_X | LC_OBJECT_TRANSFORM_MOVE_Y | LC_OBJECT_TRANSFORM_MOVE_Z)
#define LC_OBJECT_TRANSFORM_ROTATE_X 0x010
#define LC_OBJECT_TRANSFORM_ROTATE_Y 0x020
#define LC_OBJECT_TRANSFORM_ROTATE_Z 0x040
#define LC_OBJECT_TRANSFORM_ROTATE_XYZ (LC_OBJECT_TRANSFORM_ROTATE_X | LC_OBJECT_TRANSFORM_ROTATE_Y | LC_OBJECT_TRANSFORM_ROTATE_Z)
#define LC_OBJECT_TRANSFORM_SCALE_X 0x100
#define LC_OBJECT_TRANSFORM_SCALE_Y 0x200
#define LC_OBJECT_TRANSFORM_SCALE_Z 0x400
#define LC_OBJECT_TRANSFORM_SCALE_XYZ (LC_OBJECT_TRANSFORM_SCALE_X | LC_OBJECT_TRANSFORM_SCALE_Y | LC_OBJECT_TRANSFORM_SCALE_Z)
2014-05-01 20:42:11 +02:00
class lcObject
2011-09-07 23:06:51 +02:00
{
public:
2014-05-01 20:42:11 +02:00
lcObject(lcObjectType ObjectType);
virtual ~lcObject();
2011-09-07 23:06:51 +02:00
2020-05-04 00:39:39 +02:00
lcObject(const lcObject&) = delete;
2021-11-15 03:34:24 +01:00
lcObject(lcObject&&) = delete;
2020-05-04 00:39:39 +02:00
lcObject& operator=(const lcObject&) = delete;
2021-11-15 03:34:24 +01:00
lcObject& operator=(lcObject&&) = delete;
2020-05-04 00:39:39 +02:00
2011-09-07 23:06:51 +02:00
public:
2014-01-31 00:26:55 +01:00
bool IsPiece() const
{
2020-04-19 04:45:21 +02:00
return mObjectType == lcObjectType::Piece;
2014-01-31 00:26:55 +01:00
}
2011-09-07 23:06:51 +02:00
2014-01-31 00:26:55 +01:00
bool IsCamera() const
{
2020-04-19 04:45:21 +02:00
return mObjectType == lcObjectType::Camera;
2014-01-31 00:26:55 +01:00
}
2011-09-07 23:06:51 +02:00
2014-01-31 00:26:55 +01:00
bool IsLight() const
{
2020-04-19 04:45:21 +02:00
return mObjectType == lcObjectType::Light;
2014-01-31 00:26:55 +01:00
}
2011-09-07 23:06:51 +02:00
lcObjectType GetType() const
2014-01-31 00:26:55 +01:00
{
return mObjectType;
2014-01-31 00:26:55 +01:00
}
2011-09-07 23:06:51 +02:00
virtual bool IsSelected() const = 0;
2017-12-02 21:22:04 +01:00
virtual bool IsSelected(quint32 Section) const = 0;
virtual void SetSelected(bool Selected) = 0;
2017-12-02 21:22:04 +01:00
virtual void SetSelected(quint32 Section, bool Selected) = 0;
virtual bool IsFocused() const = 0;
2017-12-02 21:22:04 +01:00
virtual bool IsFocused(quint32 Section) const = 0;
virtual void SetFocused(quint32 Section, bool Focused) = 0;
virtual quint32 GetFocusSection() const = 0;
2024-01-21 21:53:18 +01:00
virtual void UpdatePosition(lcStep Step) = 0;
2017-12-02 21:22:04 +01:00
virtual quint32 GetAllowedTransforms() const = 0;
virtual lcVector3 GetSectionPosition(quint32 Section) const = 0;
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const = 0;
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const = 0;
virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const = 0;
2024-02-19 23:54:45 +01:00
virtual QVariant GetPropertyValue(lcObjectPropertyId PropertyId) const = 0;
virtual bool SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool AddKey, QVariant Value) = 0;
2024-01-15 02:41:01 +01:00
virtual bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const = 0;
2024-01-21 21:53:18 +01:00
virtual bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) = 0;
virtual void RemoveKeyFrames() = 0;
2020-12-14 01:27:21 +01:00
virtual QString GetName() const = 0;
static QString GetCheckpointString(lcObjectPropertyId PropertyId);
2011-09-07 23:06:51 +02:00
2012-08-17 01:50:40 +02:00
private:
lcObjectType mObjectType;
2011-09-07 23:06:51 +02:00
};