2014-06-16 21:18:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
2016-04-22 18:51:38 +02:00
|
|
|
#include "engine/lumix.h"
|
2019-06-13 17:26:52 +02:00
|
|
|
#include "engine/math.h"
|
2014-06-16 21:18:15 +02:00
|
|
|
|
|
|
|
|
2019-11-04 18:28:18 +01:00
|
|
|
struct lua_State;
|
|
|
|
|
|
|
|
|
2014-06-16 21:18:15 +02:00
|
|
|
namespace Lumix
|
|
|
|
{
|
|
|
|
|
2020-12-10 22:40:13 +01:00
|
|
|
namespace os { enum class MouseButton; }
|
2019-01-05 15:14:34 +01:00
|
|
|
|
2020-02-21 22:09:11 +01:00
|
|
|
template <typename T> struct Array;
|
2020-10-11 15:16:06 +02:00
|
|
|
template <typename T> struct DelegateList;
|
|
|
|
template <typename T> struct UniquePtr;
|
2015-07-30 09:18:37 +02:00
|
|
|
|
2016-01-16 13:47:42 +01:00
|
|
|
|
2020-01-06 17:25:22 +01:00
|
|
|
struct IEditorCommand
|
|
|
|
{
|
|
|
|
virtual ~IEditorCommand() {}
|
|
|
|
|
|
|
|
virtual bool execute() = 0;
|
|
|
|
virtual void undo() = 0;
|
|
|
|
virtual const char* getType() = 0;
|
|
|
|
virtual bool merge(IEditorCommand& command) = 0;
|
|
|
|
};
|
|
|
|
|
2023-03-18 12:12:52 +01:00
|
|
|
struct WorldView {
|
2020-03-07 17:41:55 +01:00
|
|
|
struct RayHit {
|
|
|
|
bool is_hit;
|
|
|
|
float t;
|
|
|
|
EntityPtr entity;
|
|
|
|
DVec3 pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Vertex {
|
|
|
|
Vec3 pos;
|
|
|
|
u32 abgr;
|
|
|
|
};
|
|
|
|
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual ~WorldView() = default;
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual const struct Viewport& getViewport() const = 0;
|
2020-02-03 01:36:24 +01:00
|
|
|
virtual void setViewport(const Viewport& vp) = 0;
|
|
|
|
virtual void lookAtSelected() = 0;
|
|
|
|
virtual void setTopView() = 0;
|
|
|
|
virtual void setFrontView() = 0;
|
|
|
|
virtual void setSideView() = 0;
|
|
|
|
virtual void moveCamera(float forward, float right, float up, float speed) = 0;
|
|
|
|
virtual void copyTransform() = 0;
|
2021-02-14 20:04:00 +01:00
|
|
|
virtual void refreshIcons() = 0;
|
2020-02-03 22:20:11 +01:00
|
|
|
|
2020-12-10 22:40:13 +01:00
|
|
|
virtual bool isMouseDown(os::MouseButton button) const = 0;
|
|
|
|
virtual bool isMouseClick(os::MouseButton button) const = 0;
|
2020-02-03 22:20:11 +01:00
|
|
|
virtual Vec2 getMousePos() const = 0;
|
|
|
|
virtual void setMouseSensitivity(float x, float y) = 0;
|
|
|
|
virtual Vec2 getMouseSensitivity() = 0;
|
|
|
|
virtual void setCustomPivot() = 0;
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual void resetPivot() = 0;
|
2020-02-03 22:20:11 +01:00
|
|
|
virtual void setSnapMode(bool enable, bool vertex_snap) = 0;
|
2022-01-21 17:40:00 +01:00
|
|
|
virtual RayHit getCameraRaycastHit(int cam_x, int cam_y, EntityPtr ignore) = 0;
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual Vertex* render(bool lines, u32 vertex_count) = 0;
|
2020-03-07 22:14:30 +01:00
|
|
|
virtual void addText2D(float x, float y, Color color, const char* text) = 0;
|
2021-03-25 20:37:47 +01:00
|
|
|
virtual struct WorldEditor& getEditor() = 0;
|
2020-02-03 01:36:24 +01:00
|
|
|
};
|
2020-01-06 17:25:22 +01:00
|
|
|
|
2023-03-18 12:12:52 +01:00
|
|
|
LUMIX_EDITOR_API void addCircle(WorldView& view, const DVec3& center, float radius, const Vec3& up, Color color);
|
|
|
|
LUMIX_EDITOR_API void addSphere(WorldView& view, const DVec3& center, float radius, Color color);
|
|
|
|
LUMIX_EDITOR_API void addCube(WorldView& view, const DVec3& center, const Vec3& x, const Vec3& y, const Vec3& z, Color color);
|
|
|
|
LUMIX_EDITOR_API void addCube(WorldView& view, const DVec3& min, const DVec3& max, Color color);
|
|
|
|
LUMIX_EDITOR_API void addLine(WorldView& view, const DVec3& a, const DVec3& b, Color color);
|
|
|
|
LUMIX_EDITOR_API void addCylinder(WorldView& view, const DVec3& pos, const Vec3& up, float radius, float height, Color color);
|
|
|
|
LUMIX_EDITOR_API void addCone(WorldView& view, const DVec3& vertex, const Vec3& dir, const Vec3& axis0, const Vec3& axis1, Color color);
|
|
|
|
LUMIX_EDITOR_API void addFrustum(WorldView& view, const struct ShiftedFrustum& frustum, Color color);
|
|
|
|
LUMIX_EDITOR_API void addCapsule(WorldView& view, const DVec3& position, float height, float radius, Color color);
|
2020-03-07 20:56:15 +01:00
|
|
|
|
2020-02-21 22:09:11 +01:00
|
|
|
struct LUMIX_EDITOR_API WorldEditor
|
2015-07-22 00:33:10 +02:00
|
|
|
{
|
2020-03-07 17:41:55 +01:00
|
|
|
enum class Coordinate : i32 {
|
2016-07-25 16:50:26 +02:00
|
|
|
X,
|
|
|
|
Y,
|
2017-11-28 19:37:15 +01:00
|
|
|
Z,
|
|
|
|
NONE
|
2016-07-25 16:50:26 +02:00
|
|
|
};
|
|
|
|
|
2020-10-11 15:16:06 +02:00
|
|
|
static UniquePtr<WorldEditor> create(struct Engine& engine, struct IAllocator& allocator);
|
2015-04-05 18:08:50 +02:00
|
|
|
|
2022-03-13 17:24:49 +01:00
|
|
|
virtual void loadProject() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void update() = 0;
|
|
|
|
virtual Engine& getEngine() = 0;
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual struct World* getWorld() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual IAllocator& getAllocator() = 0;
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual WorldView& getView() = 0;
|
|
|
|
virtual void setView(WorldView* view) = 0;
|
2020-02-03 02:16:08 +01:00
|
|
|
|
2021-02-24 21:25:26 +01:00
|
|
|
virtual void beginCommandGroup(const char* type) = 0;
|
2020-02-03 02:16:08 +01:00
|
|
|
virtual void endCommandGroup() = 0;
|
2022-01-21 17:40:00 +01:00
|
|
|
virtual void lockGroupCommand() = 0;
|
2020-10-14 21:13:29 +02:00
|
|
|
virtual void executeCommand(UniquePtr<IEditorCommand>&& command) = 0;
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual bool isWorldChanged() const = 0;
|
2015-09-19 11:38:53 +02:00
|
|
|
virtual bool canUndo() const = 0;
|
|
|
|
virtual bool canRedo() const = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void undo() = 0;
|
|
|
|
virtual void redo() = 0;
|
2020-01-06 17:25:22 +01:00
|
|
|
virtual void addComponent(Span<const EntityRef> entities, ComponentType type) = 0;
|
|
|
|
virtual void destroyComponent(Span<const EntityRef> entities, ComponentType cmp_type) = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual EntityRef addEntity() = 0;
|
|
|
|
virtual void destroyEntities(const EntityRef* entities, int count) = 0;
|
2020-04-29 20:56:18 +02:00
|
|
|
virtual void selectEntities(Span<const EntityRef> entities, bool toggle) = 0;
|
2020-03-14 00:14:06 +01:00
|
|
|
virtual EntityRef addEntityAt(const DVec3& pos) = 0;
|
2018-09-16 18:35:57 +02:00
|
|
|
virtual void setEntitiesPositions(const EntityRef* entities, const DVec3* positions, int count) = 0;
|
|
|
|
virtual void setEntitiesCoordinate(const EntityRef* entities, int count, double value, Coordinate coord) = 0;
|
|
|
|
virtual void setEntitiesLocalCoordinate(const EntityRef* entities, int count, double value, Coordinate coord) = 0;
|
2023-03-18 11:21:45 +01:00
|
|
|
virtual void setEntitiesScale(const EntityRef* entities, int count, const Vec3& scale) = 0;
|
|
|
|
virtual void setEntitiesScales(const EntityRef* entities, const Vec3* scales, int count) = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual void setEntitiesRotations(const EntityRef* entity, const Quat* rotations, int count) = 0;
|
|
|
|
virtual void setEntitiesPositionsAndRotations(const EntityRef* entity,
|
2018-09-16 18:35:57 +02:00
|
|
|
const DVec3* position,
|
2015-09-21 00:11:12 +02:00
|
|
|
const Quat* rotation,
|
2018-02-09 17:06:35 +01:00
|
|
|
int count) = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual void setEntityName(EntityRef entity, const char* name) = 0;
|
2020-03-05 01:11:41 +01:00
|
|
|
|
2020-04-29 19:13:16 +02:00
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, float value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, i32 value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, u32 value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, EntityPtr value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const char* value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const struct Path& value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, bool value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const Vec2& value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const Vec3& value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const Vec4& value) = 0;
|
|
|
|
virtual void setProperty(ComponentType component, const char* array, int index, const char* property, Span<const EntityRef> entities, const IVec3& value) = 0;
|
2020-03-05 01:11:41 +01:00
|
|
|
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual void addArrayPropertyItem(const struct ComponentUID& cmp, const char* property) = 0;
|
|
|
|
virtual void removeArrayPropertyItem(const ComponentUID& cmp, int index, const char* property) = 0;
|
2020-02-03 02:16:08 +01:00
|
|
|
virtual const Array<EntityRef>& getSelectedEntities() const = 0;
|
|
|
|
virtual bool isEntitySelected(EntityRef entity) const = 0;
|
|
|
|
virtual void makeParent(EntityPtr parent, EntityRef child) = 0;
|
|
|
|
|
|
|
|
virtual void copyEntities() = 0;
|
|
|
|
virtual bool canPasteEntities() const = 0;
|
|
|
|
virtual void pasteEntities() = 0;
|
|
|
|
virtual void duplicateEntities() = 0;
|
|
|
|
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual void loadWorld(const char* basename) = 0;
|
|
|
|
virtual void saveWorld(const char* basename, bool save_path) = 0;
|
2021-02-14 20:04:00 +01:00
|
|
|
virtual bool isLoading() const = 0;
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual void newWorld() = 0;
|
2020-02-03 02:16:08 +01:00
|
|
|
virtual void toggleGameMode() = 0;
|
|
|
|
|
2023-03-18 12:12:52 +01:00
|
|
|
virtual DelegateList<void()>& worldCreated() = 0;
|
|
|
|
virtual DelegateList<void()>& worldDestroyed() = 0;
|
2022-10-23 11:30:29 +02:00
|
|
|
virtual DelegateList<void()>& entitySelectionChanged() = 0;
|
2016-02-24 20:46:14 +01:00
|
|
|
|
2021-02-23 21:17:32 +01:00
|
|
|
virtual u16 createEntityFolder(u16 parent) = 0;
|
|
|
|
virtual void destroyEntityFolder(u16 folder) = 0;
|
|
|
|
virtual void renameEntityFolder(u16 folder, const char* new_name) = 0;
|
|
|
|
virtual void moveEntityToFolder(EntityRef entity, u16 folder) = 0;
|
|
|
|
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual struct PrefabSystem& getPrefabSystem() = 0;
|
2021-02-23 21:17:32 +01:00
|
|
|
virtual struct EntityFolders& getEntityFolders() = 0;
|
2020-03-07 17:41:55 +01:00
|
|
|
virtual void snapEntities(const DVec3& hit_pos, bool translate_mode) = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual bool isGameMode() const = 0;
|
|
|
|
virtual ~WorldEditor() {}
|
|
|
|
};
|
2020-10-11 15:16:06 +02:00
|
|
|
|
2013-12-02 01:24:53 +01:00
|
|
|
}
|