File: object.h

package info (click to toggle)
leocad 25.09-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,008 kB
  • sloc: cpp: 51,794; xml: 11,265; python: 81; sh: 52; makefile: 16
file content (115 lines) | stat: -rw-r--r-- 3,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once

#include "lc_math.h"
#include "lc_objectproperty.h"

enum class lcObjectType
{
	Piece,
	Camera,
	Light
};

struct lcObjectSection
{
	lcObject* Object = nullptr;
	quint32 Section = 0;
};

struct lcPieceInfoRayTest
{
	const PieceInfo* Info = nullptr;
	lcMatrix44 Transform;
	lcVector3 Plane;
};

struct lcObjectRayTest
{
	lcCamera* ViewCamera;
	bool PiecesOnly;
	bool IgnoreSelected;
	lcVector3 Start;
	lcVector3 End;
	float Distance = FLT_MAX;
	lcObjectSection ObjectSection;
	lcPieceInfoRayTest PieceInfoRayTest;
};

struct lcObjectBoxTest
{
	lcCamera* ViewCamera;
	lcVector4 Planes[6];
	std::vector<lcObject*> Objects;
};

#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)

class lcObject
{
public:
	lcObject(lcObjectType ObjectType);
	virtual ~lcObject();

	lcObject(const lcObject&) = delete;
	lcObject(lcObject&&) = delete;
	lcObject& operator=(const lcObject&) = delete;
	lcObject& operator=(lcObject&&) = delete;

public:
	bool IsPiece() const
	{
		return mObjectType == lcObjectType::Piece;
	}

	bool IsCamera() const
	{
		return mObjectType == lcObjectType::Camera;
	}

	bool IsLight() const
	{
		return mObjectType == lcObjectType::Light;
	}

	lcObjectType GetType() const
	{
		return mObjectType;
	}

	virtual bool IsSelected() const = 0;
	virtual bool IsSelected(quint32 Section) const = 0;
	virtual void SetSelected(bool Selected) = 0;
	virtual void SetSelected(quint32 Section, bool Selected) = 0;
	virtual bool IsFocused() const = 0;
	virtual bool IsFocused(quint32 Section) const = 0;
	virtual void SetFocused(quint32 Section, bool Focused) = 0;
	virtual quint32 GetFocusSection() const = 0;

	virtual void UpdatePosition(lcStep Step) = 0;
	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;
	virtual QVariant GetPropertyValue(lcObjectPropertyId PropertyId) const = 0;
	virtual bool SetPropertyValue(lcObjectPropertyId PropertyId, lcStep Step, bool AddKey, QVariant Value) = 0;
	virtual bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const = 0;
	virtual bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) = 0;
	virtual void RemoveKeyFrames() = 0;
	virtual QString GetName() const = 0;
	static QString GetCheckpointString(lcObjectPropertyId PropertyId);

private:
	lcObjectType mObjectType;
};