1 #pragma once 2 3 #include "lc_math.h" 4 #include "lc_array.h" 5 6 enum class lcObjectType 7 { 8 Piece, 9 Camera, 10 Light 11 }; 12 13 template<typename T> 14 struct lcObjectKey 15 { 16 lcStep Step; 17 T Value; 18 }; 19 20 template<typename T> 21 class lcObjectKeyArray 22 { 23 public: GetSize()24 int GetSize() const 25 { 26 return static_cast<int>(mKeys.size()); 27 } 28 IsEmpty()29 bool IsEmpty() const 30 { 31 return mKeys.empty(); 32 } 33 RemoveAll()34 void RemoveAll() 35 { 36 mKeys.clear(); 37 } 38 39 void SaveKeysLDraw(QTextStream& Stream, const char* KeyName) const; 40 void LoadKeysLDraw(QTextStream& Stream); 41 const T& CalculateKey(lcStep Step) const; 42 void ChangeKey(const T& Value, lcStep Step, bool AddKey); 43 void InsertTime(lcStep Start, lcStep Time); 44 void RemoveTime(lcStep Start, lcStep Time); 45 46 protected: 47 std::vector<lcObjectKey<T>> mKeys; 48 }; 49 50 struct lcObjectSection 51 { 52 lcObject* Object; 53 quint32 Section; 54 }; 55 56 struct lcObjectRayTest 57 { 58 lcCamera* ViewCamera; 59 bool PiecesOnly; 60 bool IgnoreSelected; 61 lcVector3 Start; 62 lcVector3 End; 63 float Distance; 64 lcObjectSection ObjectSection; 65 }; 66 67 struct lcObjectBoxTest 68 { 69 lcCamera* ViewCamera; 70 lcVector4 Planes[6]; 71 lcArray<lcObject*> Objects; 72 }; 73 74 #define LC_OBJECT_TRANSFORM_MOVE_X 0x001 75 #define LC_OBJECT_TRANSFORM_MOVE_Y 0x002 76 #define LC_OBJECT_TRANSFORM_MOVE_Z 0x004 77 #define LC_OBJECT_TRANSFORM_ROTATE_X 0x010 78 #define LC_OBJECT_TRANSFORM_ROTATE_Y 0x020 79 #define LC_OBJECT_TRANSFORM_ROTATE_Z 0x040 80 #define LC_OBJECT_TRANSFORM_SCALE_X 0x100 81 #define LC_OBJECT_TRANSFORM_SCALE_Y 0x200 82 #define LC_OBJECT_TRANSFORM_SCALE_Z 0x400 83 84 class lcObject 85 { 86 public: 87 lcObject(lcObjectType ObjectType); 88 virtual ~lcObject(); 89 90 lcObject(const lcObject&) = delete; 91 lcObject& operator=(const lcObject&) = delete; 92 93 public: IsPiece()94 bool IsPiece() const 95 { 96 return mObjectType == lcObjectType::Piece; 97 } 98 IsCamera()99 bool IsCamera() const 100 { 101 return mObjectType == lcObjectType::Camera; 102 } 103 IsLight()104 bool IsLight() const 105 { 106 return mObjectType == lcObjectType::Light; 107 } 108 GetType()109 lcObjectType GetType() const 110 { 111 return mObjectType; 112 } 113 114 virtual bool IsSelected() const = 0; 115 virtual bool IsSelected(quint32 Section) const = 0; 116 virtual void SetSelected(bool Selected) = 0; 117 virtual void SetSelected(quint32 Section, bool Selected) = 0; 118 virtual bool IsFocused() const = 0; 119 virtual bool IsFocused(quint32 Section) const = 0; 120 virtual void SetFocused(quint32 Section, bool Focused) = 0; 121 virtual quint32 GetFocusSection() const = 0; 122 123 virtual quint32 GetAllowedTransforms() const = 0; 124 virtual lcVector3 GetSectionPosition(quint32 Section) const = 0; 125 virtual void RayTest(lcObjectRayTest& ObjectRayTest) const = 0; 126 virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const = 0; 127 virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const = 0; 128 virtual void RemoveKeyFrames() = 0; 129 virtual QString GetName() const = 0; 130 131 private: 132 lcObjectType mObjectType; 133 }; 134 135