2014-06-16 21:18:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
2016-04-22 18:51:38 +02:00
|
|
|
#include "engine/lumix.h"
|
2016-04-22 18:33:06 +02:00
|
|
|
#include "engine/universe/component.h"
|
2016-05-10 12:27:10 +02:00
|
|
|
#include "engine/vec.h"
|
2014-06-16 21:18:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace Lumix
|
|
|
|
{
|
|
|
|
|
2017-10-18 23:43:02 +02:00
|
|
|
|
2017-11-19 14:04:10 +01:00
|
|
|
namespace Reflection
|
2017-10-18 23:43:02 +02:00
|
|
|
{
|
|
|
|
struct PropertyBase;
|
|
|
|
struct IArrayProperty;
|
|
|
|
}
|
|
|
|
|
2019-03-23 13:34:03 +01:00
|
|
|
namespace OS {
|
|
|
|
enum class MouseButton;
|
|
|
|
using WindowHandle = void*;
|
|
|
|
}
|
2019-01-05 15:14:34 +01:00
|
|
|
|
|
|
|
template <typename T> class DelegateList;
|
|
|
|
template <typename T> class Array;
|
2015-07-22 00:33:10 +02:00
|
|
|
class Engine;
|
2017-01-03 17:04:09 +01:00
|
|
|
struct EntityGUID;
|
2015-08-12 22:57:22 +02:00
|
|
|
class Hierarchy;
|
2019-01-05 15:14:34 +01:00
|
|
|
struct IAllocator;
|
2019-06-11 22:39:39 +02:00
|
|
|
class InputMemoryStream;
|
2017-05-23 21:44:10 +02:00
|
|
|
struct IPlugin;
|
2018-06-09 22:18:03 +02:00
|
|
|
struct ISerializer;
|
2019-06-11 22:39:39 +02:00
|
|
|
class OutputMemoryStream;
|
2015-07-22 00:33:10 +02:00
|
|
|
class Path;
|
2016-01-12 13:52:14 +01:00
|
|
|
class Pipeline;
|
2019-01-05 15:14:34 +01:00
|
|
|
class PrefabSystem;
|
|
|
|
class PropertyDescriptorBase;
|
2016-01-13 23:36:38 +01:00
|
|
|
struct Quat;
|
|
|
|
struct RayCastModelHit;
|
2019-01-05 15:14:34 +01:00
|
|
|
class RenderInterface;
|
2015-07-30 09:18:37 +02:00
|
|
|
class Universe;
|
2018-07-07 15:20:25 +02:00
|
|
|
struct Viewport;
|
2015-07-30 09:18:37 +02:00
|
|
|
|
2016-01-16 13:47:42 +01:00
|
|
|
|
2015-08-17 23:45:26 +02:00
|
|
|
class LUMIX_EDITOR_API WorldEditor
|
2015-07-22 00:33:10 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-07-25 00:09:11 +02:00
|
|
|
typedef Array<ComponentUID> ComponentList;
|
2017-05-23 21:44:10 +02:00
|
|
|
typedef struct IEditorCommand* (*EditorCommandCreator)(WorldEditor&);
|
2014-07-05 23:19:02 +02:00
|
|
|
|
2016-07-25 16:50:26 +02:00
|
|
|
enum class Coordinate : int
|
|
|
|
{
|
|
|
|
X,
|
|
|
|
Y,
|
2017-11-28 19:37:15 +01:00
|
|
|
Z,
|
|
|
|
NONE
|
2016-07-25 16:50:26 +02:00
|
|
|
};
|
|
|
|
|
2016-05-10 12:27:10 +02:00
|
|
|
struct RayHit
|
|
|
|
{
|
|
|
|
bool is_hit;
|
|
|
|
float t;
|
2018-08-19 17:35:37 +02:00
|
|
|
EntityPtr entity;
|
2018-09-16 18:35:57 +02:00
|
|
|
DVec3 pos;
|
2016-05-10 12:27:10 +02:00
|
|
|
};
|
|
|
|
|
2017-02-18 01:37:02 +01:00
|
|
|
struct LUMIX_EDITOR_API Plugin
|
2015-07-22 00:33:10 +02:00
|
|
|
{
|
|
|
|
virtual ~Plugin() {}
|
2014-08-04 23:09:36 +02:00
|
|
|
|
2017-10-03 20:11:20 +02:00
|
|
|
virtual bool onMouseDown(const RayHit& /*hit*/, int /*x*/, int /*y*/) { return false; }
|
2018-12-09 11:36:31 +01:00
|
|
|
virtual void onMouseUp(int /*x*/, int /*y*/, OS::MouseButton /*button*/) {}
|
2015-11-14 00:25:08 +01:00
|
|
|
virtual void onMouseMove(int /*x*/, int /*y*/, int /*rel_x*/, int /*rel_y*/) {}
|
|
|
|
virtual bool showGizmo(ComponentUID /*cmp*/) { return false; }
|
2015-07-22 00:33:10 +02:00
|
|
|
};
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
public:
|
2015-09-21 21:26:49 +02:00
|
|
|
static WorldEditor* create(const char* base_path, Engine& engine, IAllocator& allocator);
|
2015-09-21 21:39:28 +02:00
|
|
|
static void destroy(WorldEditor* editor, IAllocator& allocator);
|
2015-04-05 18:08:50 +02:00
|
|
|
|
2016-01-13 23:36:38 +01:00
|
|
|
virtual void setRenderInterface(RenderInterface* interface) = 0;
|
|
|
|
virtual RenderInterface* getRenderInterface() = 0;
|
2019-03-23 13:34:03 +01:00
|
|
|
virtual OS::WindowHandle getWindow() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void update() = 0;
|
2015-08-14 22:12:51 +02:00
|
|
|
virtual void updateEngine() = 0;
|
2016-11-20 17:27:41 +01:00
|
|
|
virtual void beginCommandGroup(u32 type) = 0;
|
2016-02-02 17:52:59 +01:00
|
|
|
virtual void endCommandGroup() = 0;
|
2017-09-17 11:28:17 +02:00
|
|
|
virtual void executeCommand(IEditorCommand* command) = 0;
|
2016-11-20 17:27:41 +01:00
|
|
|
virtual IEditorCommand* createEditorCommand(u32 command_type) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual Engine& getEngine() = 0;
|
|
|
|
virtual Universe* getUniverse() = 0;
|
|
|
|
virtual IAllocator& getAllocator() = 0;
|
2018-07-07 15:20:25 +02:00
|
|
|
virtual const Viewport& getViewport() const = 0;
|
|
|
|
virtual void setViewport(const Viewport& viewport) = 0;
|
2018-07-14 16:24:17 +02:00
|
|
|
virtual class EditorIcons& getIcons() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual class Gizmo& getGizmo() = 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;
|
2017-01-05 15:40:59 +01:00
|
|
|
virtual void loadUniverse(const char* basename) = 0;
|
|
|
|
virtual void saveUniverse(const char* basename, bool save_path) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void newUniverse() = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual void copyEntities(const EntityRef* entities, int count, ISerializer& serializer) = 0;
|
2016-02-05 22:30:49 +01:00
|
|
|
virtual void copyEntities() = 0;
|
|
|
|
virtual bool canPasteEntities() const = 0;
|
|
|
|
virtual void pasteEntities() = 0;
|
2018-02-09 15:19:55 +01:00
|
|
|
virtual void duplicateEntities() = 0;
|
2016-06-22 00:46:48 +02:00
|
|
|
virtual void addComponent(ComponentType type) = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual void cloneComponent(const ComponentUID& src, EntityRef entity) = 0;
|
|
|
|
virtual void destroyComponent(const EntityRef* entities, int count, ComponentType cmp_type) = 0;
|
|
|
|
virtual void createEntityGUID(EntityRef entity) = 0;
|
|
|
|
virtual void destroyEntityGUID(EntityRef entity) = 0;
|
|
|
|
virtual EntityGUID getEntityGUID(EntityRef entity) = 0;
|
|
|
|
virtual EntityRef addEntity() = 0;
|
|
|
|
virtual void destroyEntities(const EntityRef* entities, int count) = 0;
|
|
|
|
virtual void selectEntities(const EntityRef* entities, int count, bool toggle) = 0;
|
|
|
|
virtual EntityRef addEntityAt(int camera_x, int camera_y) = 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;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual void setEntitiesScale(const EntityRef* entities, int count, float scale) = 0;
|
|
|
|
virtual void setEntitiesScales(const EntityRef* entities, const float* scales, int count) = 0;
|
|
|
|
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;
|
2015-10-20 21:46:13 +02:00
|
|
|
virtual void snapDown() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void toggleGameMode() = 0;
|
2016-03-19 14:01:51 +01:00
|
|
|
virtual void navigate(float forward, float right, float up, float speed) = 0;
|
2016-06-22 00:46:48 +02:00
|
|
|
virtual void setProperty(ComponentType component,
|
2015-09-21 00:11:12 +02:00
|
|
|
int index,
|
2017-11-19 14:04:10 +01:00
|
|
|
const Reflection::PropertyBase& property,
|
2018-08-19 17:35:37 +02:00
|
|
|
const EntityRef* entities,
|
2016-07-25 16:05:33 +02:00
|
|
|
int count,
|
2015-09-21 00:11:12 +02:00
|
|
|
const void* data,
|
|
|
|
int size) = 0;
|
2017-11-23 18:50:27 +01:00
|
|
|
virtual void setCustomPivot() = 0;
|
|
|
|
virtual void setSnapMode(bool enable, bool vertex_snap) = 0;
|
2018-02-11 01:04:19 +01:00
|
|
|
virtual void setToggleSelection(bool is_toggle) = 0;
|
2017-11-19 14:04:10 +01:00
|
|
|
virtual void addArrayPropertyItem(const ComponentUID& cmp, const Reflection::IArrayProperty& property) = 0;
|
|
|
|
virtual void removeArrayPropertyItem(const ComponentUID& cmp, int index, const Reflection::IArrayProperty& property) = 0;
|
2018-12-09 11:36:31 +01:00
|
|
|
virtual bool isMouseDown(OS::MouseButton button) const = 0;
|
|
|
|
virtual bool isMouseClick(OS::MouseButton button) const = 0;
|
2017-02-24 15:20:58 +01:00
|
|
|
virtual void inputFrame() = 0;
|
2018-12-09 11:36:31 +01:00
|
|
|
virtual void onMouseDown(int x, int y, OS::MouseButton button) = 0;
|
2015-10-16 21:27:55 +02:00
|
|
|
virtual void onMouseMove(int x, int y, int relx, int rely) = 0;
|
2018-12-09 11:36:31 +01:00
|
|
|
virtual void onMouseUp(int x, int y, OS::MouseButton button) = 0;
|
2017-10-04 10:47:31 +02:00
|
|
|
virtual Vec2 getMousePos() const = 0;
|
2016-07-13 14:25:46 +02:00
|
|
|
virtual float getMouseRelX() const = 0;
|
|
|
|
virtual float getMouseRelY() const = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void lookAtSelected() = 0;
|
2015-10-12 10:58:22 +02:00
|
|
|
virtual bool isOrbitCamera() const = 0;
|
|
|
|
virtual void setOrbitCamera(bool enable) = 0;
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual const Array<EntityRef>& getSelectedEntities() const = 0;
|
|
|
|
virtual bool isEntitySelected(EntityRef entity) const = 0;
|
|
|
|
virtual void makeParent(EntityPtr parent, EntityRef child) = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2018-08-19 17:35:37 +02:00
|
|
|
virtual DelegateList<void(const Array<EntityRef>&)>& entitySelected() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual DelegateList<void()>& universeCreated() = 0;
|
|
|
|
virtual DelegateList<void()>& universeDestroyed() = 0;
|
2016-02-24 20:46:14 +01:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void addPlugin(Plugin& plugin) = 0;
|
|
|
|
virtual void removePlugin(Plugin& plugin) = 0;
|
2016-12-12 18:00:43 +01:00
|
|
|
virtual PrefabSystem& getPrefabSystem() = 0;
|
2018-09-16 18:35:57 +02:00
|
|
|
virtual DVec3 getCameraRaycastHit() = 0;
|
2015-09-19 11:38:53 +02:00
|
|
|
virtual bool isMeasureToolActive() const = 0;
|
2018-09-16 18:35:57 +02:00
|
|
|
virtual double getMeasuredDistance() const = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void toggleMeasure() = 0;
|
2016-01-06 20:43:26 +01:00
|
|
|
virtual void setTopView() = 0;
|
|
|
|
virtual void setFrontView() = 0;
|
|
|
|
virtual void setSideView() = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual class MeasureTool* getMeasureTool() const = 0;
|
2017-02-12 11:38:43 +01:00
|
|
|
virtual void makeRelative(char* relative, int max_size, const char* absolute) const = 0;
|
2017-07-07 21:28:25 +02:00
|
|
|
virtual void makeAbsolute(char* absolute, int max_size, const char* relative) const = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual void saveUndoStack(const Path& path) = 0;
|
|
|
|
virtual bool executeUndoStack(const Path& path) = 0;
|
2016-12-16 00:44:04 +01:00
|
|
|
virtual bool runTest(const char* dir, const char* name) = 0;
|
2016-05-12 09:11:29 +02:00
|
|
|
virtual void registerEditorCommandCreator(const char* command_type, EditorCommandCreator) = 0;
|
2015-07-22 00:33:10 +02:00
|
|
|
virtual bool isGameMode() const = 0;
|
2016-02-14 21:56:06 +01:00
|
|
|
virtual void setMouseSensitivity(float x, float y) = 0;
|
|
|
|
virtual Vec2 getMouseSensitivity() = 0;
|
2016-03-21 22:04:53 +01:00
|
|
|
virtual bool isUniverseChanged() const = 0;
|
2014-06-16 21:18:15 +02:00
|
|
|
|
2015-07-22 00:33:10 +02:00
|
|
|
protected:
|
|
|
|
virtual ~WorldEditor() {}
|
|
|
|
};
|
2013-12-02 01:24:53 +01:00
|
|
|
}
|