Compare commits
2 Commits
f7d69eb21d
...
88ba321f68
Author | SHA1 | Date | |
---|---|---|---|
88ba321f68 | |||
ea8420f0d8 |
@ -1,13 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "Deer/Components.h"
|
#include "Deer/Components.h"
|
||||||
#include "Deer/Log.h"
|
#include "Deer/Log.h"
|
||||||
#include "Deer/Memory.h"
|
#include "Deer/Memory.h"
|
||||||
|
|
||||||
#include "entt/entt.hpp"
|
#include "entt/entt.hpp"
|
||||||
|
|
||||||
#ifdef DEER_RENDER
|
#ifdef DEER_RENDER
|
||||||
@ -15,13 +10,18 @@
|
|||||||
#include "DeerRender/SceneCamera.h"
|
#include "DeerRender/SceneCamera.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ENVIRONMENT_MAX_ENTITIES 2048
|
#include <algorithm>
|
||||||
#define MAX_ENVIRONMENT_COUNT 64
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
class Entity;
|
class Entity;
|
||||||
|
|
||||||
class Environment {
|
class Environment {
|
||||||
|
// Note: Outdated note
|
||||||
///////// NOTES ///////////
|
///////// NOTES ///////////
|
||||||
// - The entity id means the position in a array defined in Environment
|
// - The entity id means the position in a array defined in Environment
|
||||||
// - The entity id is relative to a Environment so it can be a complete
|
// - The entity id is relative to a Environment so it can be a complete
|
||||||
@ -39,22 +39,25 @@ namespace Deer {
|
|||||||
|
|
||||||
// Clears all entities
|
// Clears all entities
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Obtains the entity
|
// Obtains the entity
|
||||||
Entity& getEntity(uint16_t id) const;
|
Entity& getEntity(uint16_t id);
|
||||||
bool entityExists(uint16_t id) const;
|
bool entityExists(uint16_t id) const;
|
||||||
uint16_t getEntityCount() const { return m_entityCount; }
|
uint16_t getEntityCount() const;
|
||||||
|
|
||||||
// Creates a entity child at root
|
// Creates a entity child at root
|
||||||
|
// WARNING: This method can change internal pointers and invalidate entitiy references
|
||||||
Entity& createEntity(const std::string& name = "");
|
Entity& createEntity(const std::string& name = "");
|
||||||
|
// Can be slow! This has to empty the stack of empty entities in case its necessary so use it in ascendent order!
|
||||||
|
// WARNING: This method can change internal pointers and invalidate entitiy references
|
||||||
Entity& createEntityWithId(uint16_t id, const std::string& name = "");
|
Entity& createEntityWithId(uint16_t id, const std::string& name = "");
|
||||||
void destroyEntity(uint16_t id);
|
void destroyEntity(uint16_t id);
|
||||||
|
|
||||||
// Special behaviour
|
// Special behaviour
|
||||||
|
// WARNING: This method can change internal pointers and invalidate entitiy references
|
||||||
Entity createEmptyEntity();
|
Entity createEmptyEntity();
|
||||||
|
|
||||||
// FEO
|
// FEO
|
||||||
uint16_t tryGetMainCamera();
|
uint16_t tryGetMainCamera() const;
|
||||||
void setMainCamera(Entity& entity);
|
void setMainCamera(Entity& entity);
|
||||||
|
|
||||||
// Obtains the entity that is on the root of the environment
|
// Obtains the entity that is on the root of the environment
|
||||||
@ -62,112 +65,89 @@ namespace Deer {
|
|||||||
#ifdef DEER_RENDER
|
#ifdef DEER_RENDER
|
||||||
void render(SceneCamera& camera);
|
void render(SceneCamera& camera);
|
||||||
#endif
|
#endif
|
||||||
entt::registry m_registry;
|
Scope<entt::registry> m_registry;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t m_mainCamera = 0;
|
uint16_t m_mainCamera = 0;
|
||||||
// To avoid inecessary loop we set this variable that means that smaller
|
|
||||||
// id's than this numbers are not null, empty or used
|
|
||||||
uint16_t m_idCreationOffset = 0;
|
|
||||||
// Since we don't initialize Entity in the big array for performance we
|
|
||||||
// want to keep track the ones we initialized defined by this value, it
|
|
||||||
// the id is greater it means that any information that it has can't be
|
|
||||||
// seen as valid
|
|
||||||
uint16_t m_maxIdValue = 0;
|
|
||||||
// Number of entities that exists inside
|
|
||||||
uint16_t m_entityCount = 0;
|
|
||||||
// This is where we save the entities, in a const list defined by
|
|
||||||
// ENVIRONMENT_MAX_ENTITIES, we have to make sure this system is as fast
|
|
||||||
// as possible
|
|
||||||
Scope<std::array<Entity, ENVIRONMENT_MAX_ENTITIES>> entities;
|
|
||||||
|
|
||||||
inline uint16_t pullEntityID() {
|
std::stack<u_int16_t> unused_entities_spaces;
|
||||||
m_idCreationOffset++;
|
std::vector<Entity> entities;
|
||||||
if (m_idCreationOffset > m_maxIdValue)
|
|
||||||
m_maxIdValue = m_idCreationOffset;
|
|
||||||
return m_idCreationOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend class Entity;
|
friend class Entity;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Warning: This calss does not initialize for performance
|
// Warning: This calss does not initialize for performance
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
// This class can not be copied
|
|
||||||
Entity(const Entity&) = delete;
|
|
||||||
Entity() {}
|
Entity() {}
|
||||||
|
Entity(const Entity&) = delete;
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
Entity(Entity&&) noexcept;
|
||||||
T& addComponent(Args&&... args) const {
|
Entity& operator=(Entity&&) noexcept;
|
||||||
DEER_CORE_ASSERT(
|
|
||||||
!m_environment->m_registry.all_of<T>(m_entityHandle),
|
|
||||||
"Entity already have component {0}", typeid(T).name());
|
|
||||||
|
|
||||||
return m_environment->m_registry.emplace<T>(
|
|
||||||
m_entityHandle, std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T& getComponent() const {
|
|
||||||
DEER_CORE_ASSERT(
|
|
||||||
m_environment->m_registry.all_of<T>(m_entityHandle),
|
|
||||||
"Entity has no component {0}", typeid(T).name());
|
|
||||||
|
|
||||||
return m_environment->m_registry.get<T>(m_entityHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool hasComponent() const {
|
|
||||||
return m_environment->m_registry.all_of<T>(m_entityHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void removeComponent() const {
|
|
||||||
DEER_CORE_ASSERT(
|
|
||||||
m_environment->m_registry.all_of<T>(m_entityHandle),
|
|
||||||
"Entity does not have component {0}", typeid(T).name());
|
|
||||||
|
|
||||||
m_environment->m_registry.remove<T>(m_entityHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity& duplicate();
|
Entity& duplicate();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
uint16_t getId() const { return m_entityID; }
|
uint16_t getId() const { return entId; }
|
||||||
Entity& getParent() const;
|
Entity& getParent() const;
|
||||||
inline uint16_t getParentId() const { return m_parentID; }
|
inline uint16_t getParentId() const { return parentId; }
|
||||||
|
|
||||||
// TODO, enable transfer entitys from difrent environments
|
// TODO, enable transfer entitys from difrent environments
|
||||||
void setParent(Entity& parent);
|
void setParent(Entity& parent);
|
||||||
bool isDescendantOf(Entity& parent) const;
|
bool isDescendantOf(Entity& parent) const;
|
||||||
|
|
||||||
Environment* getEnvironment() const { return m_environment; }
|
Environment* getEnvironment() const { return environment; }
|
||||||
|
|
||||||
bool isRoot() const { return m_entityID == 0; }
|
bool isRoot() const { return entId == 0; }
|
||||||
glm::mat4 getWorldMatrix();
|
glm::mat4 getWorldMatrix() const;
|
||||||
glm::mat4 getRelativeMatrix();
|
glm::mat4 getRelativeMatrix() const;
|
||||||
|
|
||||||
void tickExecution();
|
void tickExecution();
|
||||||
|
void clear();
|
||||||
|
|
||||||
inline bool isValid() const { return m_exists; }
|
bool isValid() const;
|
||||||
|
private:
|
||||||
private:
|
Environment* environment = nullptr;
|
||||||
Environment* m_environment = nullptr;
|
entt::entity entHandle = entt::null;
|
||||||
entt::entity m_entityHandle = entt::null;
|
uint16_t entId = 0;
|
||||||
uint16_t m_entityID = 0;
|
uint16_t parentId = 0;
|
||||||
uint16_t m_parentID = 0;
|
|
||||||
bool m_exists = false;
|
|
||||||
|
|
||||||
Entity(entt::entity handle, Environment* scene, uint16_t entityID);
|
Entity(entt::entity handle, Environment* scene, uint16_t entityID);
|
||||||
|
|
||||||
friend class Environment;
|
friend class Environment;
|
||||||
|
public:
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
T& addComponent(Args&&... args) const {
|
||||||
|
DEER_CORE_ASSERT(
|
||||||
|
!environment->m_registry->all_of<T>(entHandle),
|
||||||
|
"Entity already have component {0}", typeid(T).name());
|
||||||
|
|
||||||
|
return environment->m_registry->emplace<T>(
|
||||||
|
entHandle, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T& getComponent() const {
|
||||||
|
DEER_CORE_ASSERT(
|
||||||
|
environment->m_registry->all_of<T>(entHandle),
|
||||||
|
"Entity has no component {0}", typeid(T).name());
|
||||||
|
|
||||||
|
return environment->m_registry->get<T>(entHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool hasComponent() const {
|
||||||
|
return environment->m_registry->all_of<T>(entHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void removeComponent() const {
|
||||||
|
DEER_CORE_ASSERT(
|
||||||
|
environment->m_registry->all_of<T>(entHandle),
|
||||||
|
"Entity does not have component {0}", typeid(T).name());
|
||||||
|
|
||||||
|
environment->m_registry->remove<T>(entHandle);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace EnvironmentManager {
|
|
||||||
uint16_t createEnvironment();
|
|
||||||
Environment& getEnvironment(uint16_t);
|
|
||||||
|
|
||||||
void clearAllEnvironments();
|
|
||||||
}
|
|
||||||
} // namespace Deer
|
} // namespace Deer
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "glm/gtc/quaternion.hpp"
|
#include "glm/gtc/quaternion.hpp"
|
||||||
#include "glm/glm.hpp"
|
#include "glm/glm.hpp"
|
||||||
#include "glm/gtc/matrix_transform.hpp"
|
#include "glm/gtc/matrix_transform.hpp"
|
||||||
|
|
||||||
#define MAX_TEXTURE_BINDINGS 4
|
#define MAX_TEXTURE_BINDINGS 4
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
|
@ -1,16 +1,46 @@
|
|||||||
#include "Deer/Components.h"
|
#include "Deer/Components.h"
|
||||||
#include "Deer/Enviroment.h"
|
#include "Deer/Enviroment.h"
|
||||||
|
#include "Deer/Log.h"
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
Entity::Entity(entt::entity handle, Environment* scene, uint16_t entityID)
|
Entity::Entity(entt::entity handle, Environment* scene, uint16_t entityID)
|
||||||
: m_entityHandle(handle),
|
: entHandle(handle),
|
||||||
m_environment(scene),
|
environment(scene),
|
||||||
m_entityID(entityID),
|
entId(entityID) { }
|
||||||
m_exists(true) {}
|
|
||||||
|
Entity::Entity(Entity&& ent) noexcept {
|
||||||
|
environment = ent.environment;
|
||||||
|
entHandle = ent.entHandle;
|
||||||
|
parentId = ent.parentId;
|
||||||
|
entId = ent.entId;
|
||||||
|
|
||||||
|
ent.environment = nullptr;
|
||||||
|
ent.entHandle = entt::null;
|
||||||
|
ent.parentId = 0;
|
||||||
|
ent.entId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity& Entity::operator=(Entity&& ent) noexcept {
|
||||||
|
environment = ent.environment;
|
||||||
|
entHandle = ent.entHandle;
|
||||||
|
parentId = ent.parentId;
|
||||||
|
entId = ent.entId;
|
||||||
|
|
||||||
|
ent.environment = nullptr;
|
||||||
|
ent.entHandle = entt::null;
|
||||||
|
ent.parentId = 0;
|
||||||
|
ent.entId = 0;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool Entity::isValid() const {
|
||||||
|
return environment != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Entity::setParent(Entity& parent) {
|
void Entity::setParent(Entity& parent) {
|
||||||
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
||||||
DEER_CORE_ASSERT(parent.m_environment == m_environment,
|
DEER_CORE_ASSERT(parent.environment == environment,
|
||||||
"Can not set parent from diferent environments");
|
"Can not set parent from diferent environments");
|
||||||
DEER_CORE_ASSERT(parent.isValid(), "Parent is not valid");
|
DEER_CORE_ASSERT(parent.isValid(), "Parent is not valid");
|
||||||
if (parent.getId() == getId()) return;
|
if (parent.getId() == getId()) return;
|
||||||
@ -29,7 +59,7 @@ namespace Deer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parentID = parent.getId();
|
parentId = parent.getId();
|
||||||
current_parent.getComponent<RelationshipComponent>().removeChildren(
|
current_parent.getComponent<RelationshipComponent>().removeChildren(
|
||||||
getId());
|
getId());
|
||||||
|
|
||||||
@ -46,7 +76,7 @@ namespace Deer {
|
|||||||
|
|
||||||
Entity& Entity::duplicate() {
|
Entity& Entity::duplicate() {
|
||||||
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
||||||
Entity& creation = m_environment->createEntity(
|
Entity& creation = environment->createEntity(
|
||||||
getComponent<TagComponent>().tag + "(d)");
|
getComponent<TagComponent>().tag + "(d)");
|
||||||
|
|
||||||
creation.setParent(getParent());
|
creation.setParent(getParent());
|
||||||
@ -55,12 +85,12 @@ namespace Deer {
|
|||||||
getComponent<TransformComponent>();
|
getComponent<TransformComponent>();
|
||||||
|
|
||||||
#ifdef DEER_RENDER
|
#ifdef DEER_RENDER
|
||||||
if (m_environment->m_registry.any_of<MeshComponent>(
|
if (environment->m_registry->any_of<MeshComponent>(
|
||||||
m_entityHandle))
|
entHandle))
|
||||||
creation.addComponent<MeshComponent>(
|
creation.addComponent<MeshComponent>(
|
||||||
getComponent<MeshComponent>());
|
getComponent<MeshComponent>());
|
||||||
|
|
||||||
if (m_environment->m_registry.any_of<CameraComponent>(m_entityHandle))
|
if (environment->m_registry->any_of<CameraComponent>(entHandle))
|
||||||
creation.addComponent<CameraComponent>(
|
creation.addComponent<CameraComponent>(
|
||||||
getComponent<CameraComponent>());
|
getComponent<CameraComponent>());
|
||||||
#endif
|
#endif
|
||||||
@ -70,21 +100,28 @@ namespace Deer {
|
|||||||
void Entity::destroy() {
|
void Entity::destroy() {
|
||||||
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
||||||
DEER_CORE_ASSERT(!isRoot(), "Can not destroy the root");
|
DEER_CORE_ASSERT(!isRoot(), "Can not destroy the root");
|
||||||
m_environment->destroyEntity(getId());
|
environment->destroyEntity(getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity& Entity::getParent() const {
|
Entity& Entity::getParent() const {
|
||||||
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
DEER_CORE_ASSERT(isValid(), "Entity is not valid");
|
||||||
return m_environment->getEntity(m_parentID);
|
return environment->getEntity(parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Entity::getWorldMatrix() {
|
glm::mat4 Entity::getWorldMatrix() const {
|
||||||
if (isRoot()) return glm::mat4(1.0f);
|
if (isRoot()) return glm::mat4(1.0f);
|
||||||
|
|
||||||
return getParent().getWorldMatrix() * getRelativeMatrix();
|
return getParent().getWorldMatrix() * getRelativeMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Entity::getRelativeMatrix() {
|
void Entity::clear() {
|
||||||
|
environment = nullptr;
|
||||||
|
entHandle = entt::null;
|
||||||
|
parentId = 0;
|
||||||
|
entId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 Entity::getRelativeMatrix() const {
|
||||||
return getComponent<TransformComponent>().getMatrix();
|
return getComponent<TransformComponent>().getMatrix();
|
||||||
}
|
}
|
||||||
} // namespace Deer
|
} // namespace Deer
|
||||||
|
@ -9,86 +9,111 @@
|
|||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
Environment::Environment() {
|
Environment::Environment() {
|
||||||
entities = MakeScope<std::array<Entity, ENVIRONMENT_MAX_ENTITIES>>();
|
m_registry = MakeScope<entt::registry>();
|
||||||
clear();
|
createEntityWithId(0, "root");
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment::~Environment() {}
|
Environment::~Environment() {}
|
||||||
|
|
||||||
void Environment::clear() {
|
void Environment::clear() {
|
||||||
// Clear all existing entities and map
|
// Clear all existing entities and map
|
||||||
m_registry.clear();
|
m_registry->clear();
|
||||||
|
|
||||||
m_mainCamera = 0;
|
while (!unused_entities_spaces.empty()) {
|
||||||
m_idCreationOffset = 0;
|
unused_entities_spaces.pop();
|
||||||
m_maxIdValue = 0;
|
}
|
||||||
// We set it to one because we count root
|
entities.clear();
|
||||||
m_entityCount = 1;
|
|
||||||
|
|
||||||
createEntityWithId(0, "root");
|
createEntityWithId(0, "root");
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity& Environment::getEntity(uint16_t id) const {
|
uint16_t Environment::getEntityCount() const {
|
||||||
|
return entities.size() - unused_entities_spaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity& Environment::getEntity(uint16_t id) {
|
||||||
DEER_CORE_ASSERT(entityExists(id), "Entity id {0} does not exist", id);
|
DEER_CORE_ASSERT(entityExists(id), "Entity id {0} does not exist", id);
|
||||||
Entity& refEntity = (*entities)[id];
|
return entities[id];
|
||||||
return refEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Environment::entityExists(uint16_t id) const {
|
bool Environment::entityExists(uint16_t id) const {
|
||||||
if (id < 0) return false;
|
if (id >= entities.size()) return false;
|
||||||
if (id > m_maxIdValue) return false;
|
const Entity& refEntity = entities[id];
|
||||||
if (id >= ENVIRONMENT_MAX_ENTITIES) return false;
|
|
||||||
Entity& refEntity = (*entities)[id];
|
|
||||||
return refEntity.isValid();
|
return refEntity.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity& Environment::createEntity(const std::string& name) {
|
Entity& Environment::createEntity(const std::string& name) {
|
||||||
uint16_t id;
|
uint16_t id;
|
||||||
do {
|
|
||||||
id = pullEntityID();
|
|
||||||
DEER_CORE_ASSERT(id < ENVIRONMENT_MAX_ENTITIES,
|
|
||||||
"Fatal error, max number of entities exited");
|
|
||||||
} while (entityExists(id));
|
|
||||||
|
|
||||||
entt::entity entityID = m_registry.create();
|
entt::entity entityID = m_registry->create();
|
||||||
Entity& entity = (*entities)[id];
|
if (unused_entities_spaces.empty()) {
|
||||||
|
id = entities.size();
|
||||||
|
entities.push_back({});
|
||||||
|
} else {
|
||||||
|
id = unused_entities_spaces.top();
|
||||||
|
unused_entities_spaces.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity& entity = entities[id];
|
||||||
entity = {entityID, this, id};
|
entity = {entityID, this, id};
|
||||||
|
|
||||||
entity.addComponent<TagComponent>(name, id);
|
entity.addComponent<TagComponent>(name, id);
|
||||||
entity.addComponent<RelationshipComponent>();
|
entity.addComponent<RelationshipComponent>();
|
||||||
entity.addComponent<TransformComponent>();
|
entity.addComponent<TransformComponent>();
|
||||||
entity.m_exists = true;
|
|
||||||
|
|
||||||
m_entityCount++;
|
entity.parentId = 0;
|
||||||
entity.m_parentID = 0;
|
if (!getRoot().getComponent<RelationshipComponent>().addChildrenId(id)) {
|
||||||
if (!getRoot().getComponent<RelationshipComponent>().addChildrenId(
|
|
||||||
id)) {
|
|
||||||
DEER_CORE_ERROR("Root is full!");
|
DEER_CORE_ERROR("Root is full!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity& Environment::createEntityWithId(uint16_t id,
|
Entity& Environment::createEntityWithId(uint16_t id, const std::string& name) {
|
||||||
const std::string& name) {
|
entt::entity entityID = m_registry->create();
|
||||||
// We want to initialize all entities that are not initialized to a
|
|
||||||
// default state of invalid
|
|
||||||
for (int i = m_maxIdValue + 1; i < id; i++) {
|
|
||||||
Entity& nullEntity = (*entities)[i];
|
|
||||||
nullEntity.m_exists = false;
|
|
||||||
}
|
|
||||||
if (m_maxIdValue < id) m_maxIdValue = id;
|
|
||||||
|
|
||||||
Entity& entity = (*entities)[id];
|
// We allocate all the memory until that id
|
||||||
entt::entity entityID = m_registry.create();
|
if (id >= entities.size()) {
|
||||||
entity = {entityID, this, id};
|
if (entities.capacity() <= id)
|
||||||
entity.m_exists = true;
|
entities.reserve(id + 1);
|
||||||
|
|
||||||
|
for (int i = entities.size(); i < id; i++) {
|
||||||
|
entities.push_back({});
|
||||||
|
unused_entities_spaces.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
entities.push_back({});
|
||||||
|
} else {
|
||||||
|
static std::stack<uint16_t> unused_entities_spaces_cache;
|
||||||
|
|
||||||
|
// This code its to remove a specific element from a stack
|
||||||
|
// We pop the stack until we find the id or we empty it to
|
||||||
|
// completly remove the target id and then we fill it again with the cache
|
||||||
|
while (!unused_entities_spaces.empty()) {
|
||||||
|
uint16_t topId = unused_entities_spaces.top();
|
||||||
|
unused_entities_spaces.pop();
|
||||||
|
|
||||||
|
if (topId == id)
|
||||||
|
break;
|
||||||
|
unused_entities_spaces_cache.push(topId);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!unused_entities_spaces_cache.empty()) {
|
||||||
|
uint16_t refillId = unused_entities_spaces_cache.top();
|
||||||
|
unused_entities_spaces_cache.pop();
|
||||||
|
|
||||||
|
unused_entities_spaces.push(refillId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity& entity = entities[id];
|
||||||
|
entt::entity _entityId = m_registry->create();
|
||||||
|
entity = {_entityId, this, id};
|
||||||
|
|
||||||
entity.addComponent<TagComponent>(name, id);
|
entity.addComponent<TagComponent>(name, id);
|
||||||
entity.addComponent<RelationshipComponent>();
|
entity.addComponent<RelationshipComponent>();
|
||||||
entity.addComponent<TransformComponent>();
|
entity.addComponent<TransformComponent>();
|
||||||
|
|
||||||
m_entityCount++;
|
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
if (!getRoot().getComponent<RelationshipComponent>().addChildrenId(
|
if (!getRoot().getComponent<RelationshipComponent>().addChildrenId(
|
||||||
id)) {
|
id)) {
|
||||||
@ -99,16 +124,13 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Environment::destroyEntity(uint16_t entityID) {
|
void Environment::destroyEntity(uint16_t entityID) {
|
||||||
DEER_CORE_ASSERT(entityExists(entityID), "Entity id {0} does not exist",
|
DEER_CORE_ASSERT(entityExists(entityID), "Entity id {0} does not exist", entityID);
|
||||||
entityID);
|
DEER_CORE_ASSERT(entityID != 0, "Cannot destroy root");
|
||||||
DEER_CORE_ASSERT(entityID != 0, "Can not destroy root");
|
|
||||||
|
|
||||||
Entity& entity = (*entities)[entityID];
|
Entity& entity = entities[entityID];
|
||||||
entity.getParent().getComponent<RelationshipComponent>().removeChildren(
|
entity.getParent().getComponent<RelationshipComponent>().removeChildren(entityID);
|
||||||
entityID);
|
|
||||||
|
|
||||||
RelationshipComponent& relationship =
|
RelationshipComponent& relationship = entity.getComponent<RelationshipComponent>();
|
||||||
entity.getComponent<RelationshipComponent>();
|
|
||||||
// We want to delete all childrens
|
// We want to delete all childrens
|
||||||
for (int i = 0; i < relationship.childCount; i++) {
|
for (int i = 0; i < relationship.childCount; i++) {
|
||||||
uint16_t childID = relationship.getChildrenId(i);
|
uint16_t childID = relationship.getChildrenId(i);
|
||||||
@ -116,14 +138,14 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_mainCamera == entityID) m_mainCamera = 0;
|
if (m_mainCamera == entityID) m_mainCamera = 0;
|
||||||
if (entityID <= m_idCreationOffset) m_idCreationOffset = entityID - 1;
|
|
||||||
|
|
||||||
m_registry.destroy(entity.m_entityHandle);
|
m_registry->destroy(entity.entHandle);
|
||||||
entity.m_exists = false;
|
entity.clear();
|
||||||
m_entityCount--;
|
|
||||||
|
unused_entities_spaces.push(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Environment::tryGetMainCamera() { return m_mainCamera; }
|
uint16_t Environment::tryGetMainCamera() const { return m_mainCamera; }
|
||||||
|
|
||||||
void Environment::setMainCamera(Entity& entity) {
|
void Environment::setMainCamera(Entity& entity) {
|
||||||
if (!entity.isValid()) m_mainCamera = 0;
|
if (!entity.isValid()) m_mainCamera = 0;
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
#include "Deer/Enviroment.h"
|
|
||||||
#include "Deer/Scene.h"
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace Deer {
|
|
||||||
namespace EnvironmentManager {
|
|
||||||
struct EnvironmentContainer {
|
|
||||||
Environment* env_data = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
EnvironmentContainer environments[MAX_ENVIRONMENT_COUNT]{};
|
|
||||||
uint16_t maxEnvironmentId = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t EnvironmentManager::createEnvironment() {
|
|
||||||
if (maxEnvironmentId >= MAX_ENVIRONMENT_COUNT) {
|
|
||||||
DEER_CORE_ERROR("Max environment count");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t envId = maxEnvironmentId;
|
|
||||||
maxEnvironmentId++;
|
|
||||||
|
|
||||||
environments[envId].env_data = new Environment();
|
|
||||||
return envId;
|
|
||||||
}
|
|
||||||
|
|
||||||
Environment& EnvironmentManager::getEnvironment(uint16_t id) {
|
|
||||||
DEER_CORE_ASSERT(id >= 0 && id < MAX_ENVIRONMENT_COUNT, "Invalid environment id {0}", id);
|
|
||||||
|
|
||||||
if (id == 0)
|
|
||||||
return Scene::environment;
|
|
||||||
|
|
||||||
return *environments[id].env_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EnvironmentManager::clearAllEnvironments() {
|
|
||||||
for (int i = 1; i < maxEnvironmentId; i++) {
|
|
||||||
delete environments[i].env_data;
|
|
||||||
environments[i].env_data = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
environments[0].env_data = &Scene::environment;
|
|
||||||
maxEnvironmentId = 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ namespace Deer {
|
|||||||
// Lets invert the z axis for engine convenience
|
// Lets invert the z axis for engine convenience
|
||||||
glm::mat4 cameraProjectionMatrix = projectionMatrix * invertZ * camMatrix;
|
glm::mat4 cameraProjectionMatrix = projectionMatrix * invertZ * camMatrix;
|
||||||
{
|
{
|
||||||
auto view = m_registry.view<MeshComponent, ShaderComponent, TagComponent>();
|
auto view = m_registry->view<MeshComponent, ShaderComponent, TagComponent>();
|
||||||
for (auto entityId : view) {
|
for (auto entityId : view) {
|
||||||
auto& meshComponent = view.get<MeshComponent>(entityId);
|
auto& meshComponent = view.get<MeshComponent>(entityId);
|
||||||
auto& shaderComponent = view.get<ShaderComponent>(entityId);
|
auto& shaderComponent = view.get<ShaderComponent>(entityId);
|
||||||
@ -75,7 +75,7 @@ namespace Deer {
|
|||||||
RenderUtils::m_lineShader->uploadUniformMat4("u_viewMatrix", cameraProjectionMatrix);
|
RenderUtils::m_lineShader->uploadUniformMat4("u_viewMatrix", cameraProjectionMatrix);
|
||||||
RenderUtils::m_lineShader->uploadUniformFloat3("u_color", glm::vec3(.7f, .85f, 1));
|
RenderUtils::m_lineShader->uploadUniformFloat3("u_color", glm::vec3(.7f, .85f, 1));
|
||||||
|
|
||||||
auto view = m_registry.view<CameraComponent, TagComponent>();
|
auto view = m_registry->view<CameraComponent, TagComponent>();
|
||||||
for (auto entityId : view) {
|
for (auto entityId : view) {
|
||||||
CameraComponent cameraComponent = view.get<CameraComponent>(entityId);
|
CameraComponent cameraComponent = view.get<CameraComponent>(entityId);
|
||||||
cameraComponent.nearZ = .5f;
|
cameraComponent.nearZ = .5f;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1741,1159
|
Size=2560,1371
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@ -9,53 +9,59 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Terrain Editor]
|
[Window][Terrain Editor]
|
||||||
Pos=1315,24
|
Pos=2249,24
|
||||||
Size=426,893
|
Size=311,1128
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,1
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=361,24
|
Pos=299,24
|
||||||
Size=952,893
|
Size=668,477
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,1
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][ViewportPannel]
|
[Window][ViewportPannel]
|
||||||
Pos=361,24
|
Pos=312,24
|
||||||
Size=952,893
|
Size=1935,1128
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][ShaderExplorer]
|
[Window][ShaderExplorer]
|
||||||
Pos=0,919
|
Pos=0,1154
|
||||||
Size=1741,240
|
Size=2560,217
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,1
|
||||||
|
|
||||||
[Window][TreePannel]
|
[Window][TreePannel]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=359,893
|
Size=310,1128
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
[Window][MeshExplorer]
|
[Window][MeshExplorer]
|
||||||
Pos=0,919
|
Pos=0,1154
|
||||||
Size=1741,240
|
Size=2560,217
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][PropertiesPannel]
|
[Window][PropertiesPannel]
|
||||||
Pos=1315,24
|
Pos=2249,24
|
||||||
Size=426,893
|
Size=311,1128
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,1
|
||||||
|
|
||||||
|
[Window][CameraPannel]
|
||||||
|
Pos=312,24
|
||||||
|
Size=1935,1128
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000005,1
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1741,1135 Split=Y Selected=0x34A4C10F
|
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=2560,1347 Split=Y Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,454 Split=X
|
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,477 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=359,696 Selected=0xE45B9F93
|
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=310,696 Selected=0xE45B9F93
|
||||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1380,696 Split=X Selected=0x34A4C10F
|
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=2248,696 Split=X Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=952,454 CentralNode=1 Selected=0x34A4C10F
|
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1935,454 CentralNode=1 Selected=0x34A4C10F
|
||||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=426,454 Selected=0x2A2C795E
|
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=311,454 Selected=0xA35A27E3
|
||||||
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,240 Selected=0xD962995A
|
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,217 Selected=0xD962995A
|
||||||
|
|
||||||
|
@ -98,13 +98,18 @@ namespace Deer {
|
|||||||
ImGuiID dockspace_id = ImGui::GetID("DockSpace Demo");
|
ImGuiID dockspace_id = ImGui::GetID("DockSpace Demo");
|
||||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
// MENUBAR
|
if (ImGui::BeginMenu("Pannel")) {
|
||||||
|
onPannelMenuBar();
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
TerrainEditor::onImGui();
|
TerrainEditor::onImGui();
|
||||||
viewport_onImGui();
|
//viewport_onImGui();
|
||||||
EditorEngine::render();
|
EditorEngine::render();
|
||||||
|
|
||||||
Scene::gizmoRenderer.refresh();
|
Scene::gizmoRenderer.refresh();
|
||||||
@ -112,7 +117,7 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onEvent(Event& e) {
|
void onEvent(Event& e) {
|
||||||
viewport_onEvent(e);
|
//viewport_onEvent(e);
|
||||||
|
|
||||||
EventDispatcher ed(e);
|
EventDispatcher ed(e);
|
||||||
|
|
||||||
|
@ -13,5 +13,8 @@ namespace Deer {
|
|||||||
void main();
|
void main();
|
||||||
|
|
||||||
bool onWindowCloseEvent(WindowCloseEvent&);
|
bool onWindowCloseEvent(WindowCloseEvent&);
|
||||||
|
|
||||||
|
// Other
|
||||||
|
void onPannelMenuBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
class asIScriptEngine;
|
class asIScriptEngine;
|
||||||
class asIScriptModule;
|
class asIScriptModule;
|
||||||
class asIScriptContext;
|
class asIScriptContext;
|
||||||
|
class CScriptBuilder;
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
|
// This namespace implements all interface ported from c++ ImGui to an easier lua aproach with simplifications
|
||||||
@ -16,9 +17,11 @@ namespace Deer {
|
|||||||
|
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
// INTERNAL
|
||||||
extern asIScriptEngine* scriptEngine;
|
extern asIScriptEngine* scriptEngine;
|
||||||
extern asIScriptModule* scriptModule;
|
extern asIScriptModule* scriptModule;
|
||||||
extern asIScriptContext* scriptContext;
|
extern asIScriptContext* scriptContext;
|
||||||
|
extern CScriptBuilder builtContext;
|
||||||
extern std::vector<DockPanelObject> dockPanels;
|
extern std::vector<DockPanelObject> dockPanels;
|
||||||
extern DockPanelObject* currentDockPanelExecution;
|
extern DockPanelObject* currentDockPanelExecution;
|
||||||
|
|
||||||
|
@ -1,24 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "GenericRefStructs.h"
|
#include "GenericRefStructs.h"
|
||||||
#include "DeerRender/SceneCamera.h"
|
//#include "DeerRender/SceneCamera.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
|
class SceneCamera;
|
||||||
|
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
struct EnvironmentStruct : EnvironmentHandleStruct {
|
struct EnvironmentStruct : EnvironmentHandleStruct {
|
||||||
void render(FrameBufferHandleStruct, SceneCamera&);
|
void render(FrameBufferHandleStruct, SceneCamera&);
|
||||||
|
|
||||||
EntityHandleStruct getRootEntity();
|
EntityHandleStruct getRootEntity();
|
||||||
EntityHandleStruct getEntity(int);
|
EntityHandleStruct getEntity(int);
|
||||||
|
|
||||||
std::string getName();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EnvironmentHandleStruct getMainEnvironment();
|
EnvironmentHandleStruct getMainEnvironment();
|
||||||
|
EnvironmentHandleStruct createEnvironment();
|
||||||
EnvironmentHandleStruct createEnvironment(std::string&);
|
|
||||||
EnvironmentHandleStruct getEnvironment(std::string&);
|
|
||||||
|
|
||||||
void registerEnvironmentStructs();
|
void registerEnvironmentStructs();
|
||||||
void registerEnvironmentFunctions();
|
void registerEnvironmentFunctions();
|
||||||
|
@ -7,10 +7,14 @@
|
|||||||
#include "Deer/Enviroment.h"
|
#include "Deer/Enviroment.h"
|
||||||
#include "Deer/Scene.h"
|
#include "Deer/Scene.h"
|
||||||
|
|
||||||
#define GET_ENTITY(id) Scene::environment.getEntity(id)
|
#include <vector>
|
||||||
#define GET_MESH_COMPONENT(id) Scene::environment.getEntity(id).getComponent<MeshComponent>()
|
|
||||||
#define GET_SHADER_COMPONENT(id) Scene::environment.getEntity(id).getComponent<ShaderComponent>()
|
#define GET_ENV(env) (*Deer::EditorEngine::environments[env])
|
||||||
#define GET_CAMERA_COMPONENT(id) Scene::environment.getEntity(id).getComponent<CameraComponent>()
|
|
||||||
|
#define GET_ENTITY(env, id) GET_ENV(env).getEntity(id)
|
||||||
|
#define GET_MESH_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent<MeshComponent>()
|
||||||
|
#define GET_SHADER_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent<ShaderComponent>()
|
||||||
|
#define GET_CAMERA_COMPONENT(env, id) GET_ENV(env).getEntity(id).getComponent<CameraComponent>()
|
||||||
|
|
||||||
#define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret;
|
#define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret;
|
||||||
#define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret;
|
#define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret;
|
||||||
@ -20,6 +24,8 @@
|
|||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
|
extern std::vector <Scope<Environment>> environments;
|
||||||
|
|
||||||
EntityHandleStruct getRoot() {
|
EntityHandleStruct getRoot() {
|
||||||
return EntityStruct(0);
|
return EntityStruct(0);
|
||||||
}
|
}
|
||||||
@ -45,7 +51,7 @@ namespace Deer {
|
|||||||
std::string EntityStruct::getName() {
|
std::string EntityStruct::getName() {
|
||||||
ASSERT_ENTITY("getName()", return "NULL");
|
ASSERT_ENTITY("getName()", return "NULL");
|
||||||
|
|
||||||
return GET_ENTITY(entityId)
|
return GET_ENTITY(environmentId, entityId)
|
||||||
.getComponent<TagComponent>()
|
.getComponent<TagComponent>()
|
||||||
.tag;
|
.tag;
|
||||||
}
|
}
|
||||||
@ -54,7 +60,7 @@ namespace Deer {
|
|||||||
void EntityStruct::setName(std::string& name) {
|
void EntityStruct::setName(std::string& name) {
|
||||||
ASSERT_ENTITY("setName()", return);
|
ASSERT_ENTITY("setName()", return);
|
||||||
|
|
||||||
GET_ENTITY(entityId)
|
GET_ENTITY(environmentId, entityId)
|
||||||
.getComponent<TagComponent>()
|
.getComponent<TagComponent>()
|
||||||
.tag = name;
|
.tag = name;
|
||||||
}
|
}
|
||||||
@ -62,7 +68,7 @@ namespace Deer {
|
|||||||
void EntityStruct::destroy() {
|
void EntityStruct::destroy() {
|
||||||
ASSERT_ENTITY("destroy()", return);
|
ASSERT_ENTITY("destroy()", return);
|
||||||
|
|
||||||
GET_ENTITY(entityId)
|
GET_ENTITY(environmentId, entityId)
|
||||||
.destroy();
|
.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,16 +88,16 @@ namespace Deer {
|
|||||||
void EntityStruct::setParent(EntityHandleStruct parent_struct) {
|
void EntityStruct::setParent(EntityHandleStruct parent_struct) {
|
||||||
ASSERT_ENTITY("setParent()", return);
|
ASSERT_ENTITY("setParent()", return);
|
||||||
|
|
||||||
Entity& parent = GET_ENTITY(parent_struct.entityId);
|
Entity& parent = GET_ENTITY(parent_struct.environmentId, parent_struct.entityId);
|
||||||
|
|
||||||
GET_ENTITY(entityId)
|
GET_ENTITY(environmentId, entityId)
|
||||||
.setParent(parent);
|
.setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityHandleStruct EntityStruct::getParent() {
|
EntityHandleStruct EntityStruct::getParent() {
|
||||||
ASSERT_ENTITY("getParent()", return *this);
|
ASSERT_ENTITY("getParent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
if (self.isRoot())
|
if (self.isRoot())
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
@ -101,9 +107,9 @@ namespace Deer {
|
|||||||
bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) {
|
bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) {
|
||||||
ASSERT_ENTITY("isDescendantOf()", return false);
|
ASSERT_ENTITY("isDescendantOf()", return false);
|
||||||
|
|
||||||
Entity& parent = GET_ENTITY(parent_struct.entityId);
|
Entity& parent = GET_ENTITY(parent_struct.environmentId, parent_struct.entityId);
|
||||||
|
|
||||||
return GET_ENTITY(entityId)
|
return GET_ENTITY(environmentId, entityId)
|
||||||
.isDescendantOf(parent);
|
.isDescendantOf(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,43 +128,43 @@ namespace Deer {
|
|||||||
glm::vec3 TransformComponentStruct::getPosition() {
|
glm::vec3 TransformComponentStruct::getPosition() {
|
||||||
ASSERT_ENTITY("getPosition()", return glm::vec3());
|
ASSERT_ENTITY("getPosition()", return glm::vec3());
|
||||||
|
|
||||||
return GET_ENTITY(entityId).getComponent<TransformComponent>().position;
|
return GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().position;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 TransformComponentStruct::getScale() {
|
glm::vec3 TransformComponentStruct::getScale() {
|
||||||
ASSERT_ENTITY("getScale()", return glm::vec3());
|
ASSERT_ENTITY("getScale()", return glm::vec3());
|
||||||
|
|
||||||
return GET_ENTITY(entityId).getComponent<TransformComponent>().scale;
|
return GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 TransformComponentStruct::getRotation() {
|
glm::vec3 TransformComponentStruct::getRotation() {
|
||||||
ASSERT_ENTITY("getRotation()", return glm::vec3());
|
ASSERT_ENTITY("getRotation()", return glm::vec3());
|
||||||
|
|
||||||
return GET_ENTITY(entityId).getComponent<TransformComponent>().getEulerAngles();
|
return GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().getEulerAngles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformComponentStruct::setPosition(glm::vec3 value) {
|
void TransformComponentStruct::setPosition(glm::vec3 value) {
|
||||||
ASSERT_ENTITY("setPosition()", return);
|
ASSERT_ENTITY("setPosition()", return);
|
||||||
|
|
||||||
GET_ENTITY(entityId).getComponent<TransformComponent>().position = value;
|
GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().position = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformComponentStruct::setScale(glm::vec3 value) {
|
void TransformComponentStruct::setScale(glm::vec3 value) {
|
||||||
ASSERT_ENTITY("setScale()", return);
|
ASSERT_ENTITY("setScale()", return);
|
||||||
|
|
||||||
GET_ENTITY(entityId).getComponent<TransformComponent>().scale = value;
|
GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().scale = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformComponentStruct::setRotation(glm::vec3 value) {
|
void TransformComponentStruct::setRotation(glm::vec3 value) {
|
||||||
ASSERT_ENTITY("setRotation()", return);
|
ASSERT_ENTITY("setRotation()", return);
|
||||||
|
|
||||||
GET_ENTITY(entityId).getComponent<TransformComponent>().setEulerAngles(value);
|
GET_ENTITY(environmentId, entityId).getComponent<TransformComponent>().setEulerAngles(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EntityChildArrayStruct::getChildCount() {
|
int EntityChildArrayStruct::getChildCount() {
|
||||||
ASSERT_ENTITY("getChildCount()", return 0);
|
ASSERT_ENTITY("getChildCount()", return 0);
|
||||||
|
|
||||||
return GET_ENTITY(entityId)
|
return GET_ENTITY(environmentId, entityId)
|
||||||
.getComponent<RelationshipComponent>()
|
.getComponent<RelationshipComponent>()
|
||||||
.childCount;
|
.childCount;
|
||||||
}
|
}
|
||||||
@ -185,7 +191,7 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityChildArrayStruct::getChild(int i) {
|
EntityHandleStruct EntityChildArrayStruct::getChild(int i) {
|
||||||
ASSERT_ENTITY("getChild()", return *this);
|
ASSERT_ENTITY("getChild()", return *this);
|
||||||
|
|
||||||
RelationshipComponent& rc = GET_ENTITY(entityId)
|
RelationshipComponent& rc = GET_ENTITY(environmentId, entityId)
|
||||||
.getComponent<RelationshipComponent>();
|
.getComponent<RelationshipComponent>();
|
||||||
|
|
||||||
if (i < 0 || i >= rc.childCount) {
|
if (i < 0 || i >= rc.childCount) {
|
||||||
@ -202,10 +208,8 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::createChild(std::string& name) {
|
EntityHandleStruct EntityStruct::createChild(std::string& name) {
|
||||||
ASSERT_ENTITY("createChild()", return *this);
|
ASSERT_ENTITY("createChild()", return *this);
|
||||||
|
|
||||||
Entity& me = GET_ENTITY(entityId);
|
Entity& newEnt = Scene::environment.createEntity(name);
|
||||||
|
Entity& me = GET_ENTITY(environmentId, entityId);
|
||||||
Entity& newEnt = Scene::environment
|
|
||||||
.createEntity(name);
|
|
||||||
|
|
||||||
newEnt.setParent(me);
|
newEnt.setParent(me);
|
||||||
|
|
||||||
@ -215,11 +219,11 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::getMeshComponent() {
|
EntityHandleStruct EntityStruct::getMeshComponent() {
|
||||||
ASSERT_ENTITY("getMeshComponent()", return *this);
|
ASSERT_ENTITY("getMeshComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<MeshComponent>()) {
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have MeshComponent",
|
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have MeshComponent",
|
||||||
GET_ENTITY(entityId).getComponent<TagComponent>().tag.c_str(),
|
GET_ENTITY(environmentId, entityId).getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -233,7 +237,7 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::createMeshComponent() {
|
EntityHandleStruct EntityStruct::createMeshComponent() {
|
||||||
ASSERT_ENTITY("createMeshComponent()", return *this);
|
ASSERT_ENTITY("createMeshComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<MeshComponent>()) {
|
if (!self.hasComponent<MeshComponent>()) {
|
||||||
self.addComponent<MeshComponent>();
|
self.addComponent<MeshComponent>();
|
||||||
@ -245,7 +249,7 @@ namespace Deer {
|
|||||||
bool EntityStruct::hasMeshComponent() {
|
bool EntityStruct::hasMeshComponent() {
|
||||||
ASSERT_ENTITY("hasMeshComponent()", return false);
|
ASSERT_ENTITY("hasMeshComponent()", return false);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
return self.hasComponent<MeshComponent>();
|
return self.hasComponent<MeshComponent>();
|
||||||
}
|
}
|
||||||
@ -253,7 +257,7 @@ namespace Deer {
|
|||||||
void EntityStruct::removeMeshComponent() {
|
void EntityStruct::removeMeshComponent() {
|
||||||
ASSERT_ENTITY("removeMeshComponent()", return);
|
ASSERT_ENTITY("removeMeshComponent()", return);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (self.hasComponent<MeshComponent>()) {
|
if (self.hasComponent<MeshComponent>()) {
|
||||||
self.removeComponent<MeshComponent>();
|
self.removeComponent<MeshComponent>();
|
||||||
@ -263,11 +267,11 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::getCameraComponent() {
|
EntityHandleStruct EntityStruct::getCameraComponent() {
|
||||||
ASSERT_ENTITY("getCameraComponent()", return *this);
|
ASSERT_ENTITY("getCameraComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<CameraComponent>()) {
|
if (!self.hasComponent<CameraComponent>()) {
|
||||||
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Camera Component",
|
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Camera Component",
|
||||||
GET_ENTITY(entityId).getComponent<TagComponent>().tag.c_str(),
|
GET_ENTITY(environmentId, entityId).getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -281,7 +285,7 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::createCameraComponent() {
|
EntityHandleStruct EntityStruct::createCameraComponent() {
|
||||||
ASSERT_ENTITY("createCameraComponent()", return *this);
|
ASSERT_ENTITY("createCameraComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<CameraComponent>()) {
|
if (!self.hasComponent<CameraComponent>()) {
|
||||||
self.addComponent<CameraComponent>();
|
self.addComponent<CameraComponent>();
|
||||||
@ -293,7 +297,7 @@ namespace Deer {
|
|||||||
bool EntityStruct::hasCameraComponent() {
|
bool EntityStruct::hasCameraComponent() {
|
||||||
ASSERT_ENTITY("hasCameraComponent()", return false);
|
ASSERT_ENTITY("hasCameraComponent()", return false);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
return self.hasComponent<CameraComponent>();
|
return self.hasComponent<CameraComponent>();
|
||||||
}
|
}
|
||||||
@ -301,7 +305,7 @@ namespace Deer {
|
|||||||
void EntityStruct::removeCameraComponent() {
|
void EntityStruct::removeCameraComponent() {
|
||||||
ASSERT_ENTITY("removeMeshComponent()", return);
|
ASSERT_ENTITY("removeMeshComponent()", return);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (self.hasComponent<CameraComponent>()) {
|
if (self.hasComponent<CameraComponent>()) {
|
||||||
self.removeComponent<CameraComponent>();
|
self.removeComponent<CameraComponent>();
|
||||||
@ -311,11 +315,11 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::getShaderComponent() {
|
EntityHandleStruct EntityStruct::getShaderComponent() {
|
||||||
ASSERT_ENTITY("getShaderComponent()", return *this);
|
ASSERT_ENTITY("getShaderComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<ShaderComponent>()) {
|
if (!self.hasComponent<ShaderComponent>()) {
|
||||||
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Shader Component",
|
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Shader Component",
|
||||||
GET_ENTITY(entityId).getComponent<TagComponent>().tag.c_str(),
|
GET_ENTITY(environmentId, entityId).getComponent<TagComponent>().tag.c_str(),
|
||||||
entityId
|
entityId
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -329,7 +333,7 @@ namespace Deer {
|
|||||||
EntityHandleStruct EntityStruct::createShaderComponent() {
|
EntityHandleStruct EntityStruct::createShaderComponent() {
|
||||||
ASSERT_ENTITY("createShaderComponent()", return *this);
|
ASSERT_ENTITY("createShaderComponent()", return *this);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (!self.hasComponent<ShaderComponent>()) {
|
if (!self.hasComponent<ShaderComponent>()) {
|
||||||
self.addComponent<ShaderComponent>();
|
self.addComponent<ShaderComponent>();
|
||||||
@ -341,14 +345,14 @@ namespace Deer {
|
|||||||
bool EntityStruct::hasShaderComponent() {
|
bool EntityStruct::hasShaderComponent() {
|
||||||
ASSERT_ENTITY("hasShaderComponent()", return false);
|
ASSERT_ENTITY("hasShaderComponent()", return false);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
return self.hasComponent<ShaderComponent>();
|
return self.hasComponent<ShaderComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityStruct::removeShaderComponent() {
|
void EntityStruct::removeShaderComponent() {
|
||||||
ASSERT_ENTITY("removeShaderComponent()", return);
|
ASSERT_ENTITY("removeShaderComponent()", return);
|
||||||
|
|
||||||
Entity& self = GET_ENTITY(entityId);
|
Entity& self = GET_ENTITY(environmentId, entityId);
|
||||||
|
|
||||||
if (self.hasComponent<ShaderComponent>()) {
|
if (self.hasComponent<ShaderComponent>()) {
|
||||||
self.removeComponent<ShaderComponent>();
|
self.removeComponent<ShaderComponent>();
|
||||||
@ -357,44 +361,44 @@ namespace Deer {
|
|||||||
|
|
||||||
bool MeshComponentStruct::isActive() {
|
bool MeshComponentStruct::isActive() {
|
||||||
ASSERT_MESH_COMPONENT("isActive()", return false);
|
ASSERT_MESH_COMPONENT("isActive()", return false);
|
||||||
return GET_MESH_COMPONENT(entityId).isActive();
|
return GET_MESH_COMPONENT(environmentId, entityId).isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshComponentStruct::setActive(bool value) {
|
void MeshComponentStruct::setActive(bool value) {
|
||||||
ASSERT_MESH_COMPONENT("setActive(bool)", return);
|
ASSERT_MESH_COMPONENT("setActive(bool)", return);
|
||||||
|
|
||||||
GET_MESH_COMPONENT(entityId).setActive(value);
|
GET_MESH_COMPONENT(environmentId, entityId).setActive(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MeshComponentStruct::hasMesh() {
|
bool MeshComponentStruct::hasMesh() {
|
||||||
ASSERT_MESH_COMPONENT("hasMesh()", return false);
|
ASSERT_MESH_COMPONENT("hasMesh()", return false);
|
||||||
|
|
||||||
return GET_MESH_COMPONENT(entityId).hasMesh();
|
return GET_MESH_COMPONENT(environmentId, entityId).hasMesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshComponentStruct::clear() {
|
void MeshComponentStruct::clear() {
|
||||||
ASSERT_MESH_COMPONENT("clear()", return);
|
ASSERT_MESH_COMPONENT("clear()", return);
|
||||||
|
|
||||||
GET_MESH_COMPONENT(entityId).clear();
|
GET_MESH_COMPONENT(environmentId, entityId).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MeshComponentStruct::getMesh() {
|
std::string MeshComponentStruct::getMesh() {
|
||||||
ASSERT_MESH_COMPONENT("getMesh()", return "NULL");
|
ASSERT_MESH_COMPONENT("getMesh()", return "NULL");
|
||||||
|
|
||||||
return GET_MESH_COMPONENT(entityId).getMeshName();
|
return GET_MESH_COMPONENT(environmentId, entityId).getMeshName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshComponentStruct::setMesh(std::string& name) {
|
void MeshComponentStruct::setMesh(std::string& name) {
|
||||||
ASSERT_MESH_COMPONENT("setMesh()", return);
|
ASSERT_MESH_COMPONENT("setMesh()", return);
|
||||||
|
|
||||||
uint16_t meshId = MeshManager::loadModel(name);
|
uint16_t meshId = MeshManager::loadModel(name);
|
||||||
GET_MESH_COMPONENT(entityId).setMesh(meshId);
|
GET_MESH_COMPONENT(environmentId, entityId).setMesh(meshId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderComponentStruct::hasShader() {
|
bool ShaderComponentStruct::hasShader() {
|
||||||
ASSERT_ENTITY("hasShader()", return false);
|
ASSERT_ENTITY("hasShader()", return false);
|
||||||
|
|
||||||
return GET_SHADER_COMPONENT(entityId).hasShader();
|
return GET_SHADER_COMPONENT(environmentId, entityId).hasShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderComponentStruct::assertShaderComponent(const char* funcName) {
|
bool ShaderComponentStruct::assertShaderComponent(const char* funcName) {
|
||||||
@ -419,20 +423,20 @@ namespace Deer {
|
|||||||
void ShaderComponentStruct::clear() {
|
void ShaderComponentStruct::clear() {
|
||||||
ASSERT_SHADER_COMPONENT("clear()", return);
|
ASSERT_SHADER_COMPONENT("clear()", return);
|
||||||
|
|
||||||
GET_SHADER_COMPONENT(entityId).clear();
|
GET_SHADER_COMPONENT(environmentId, entityId).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ShaderComponentStruct::getShader() {
|
std::string ShaderComponentStruct::getShader() {
|
||||||
ASSERT_SHADER_COMPONENT("getShader()", return "NULL");
|
ASSERT_SHADER_COMPONENT("getShader()", return "NULL");
|
||||||
|
|
||||||
return GET_SHADER_COMPONENT(entityId).getName();
|
return GET_SHADER_COMPONENT(environmentId, entityId).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderComponentStruct::setShader(std::string& name) {
|
void ShaderComponentStruct::setShader(std::string& name) {
|
||||||
ASSERT_SHADER_COMPONENT("getShader()", return);
|
ASSERT_SHADER_COMPONENT("getShader()", return);
|
||||||
|
|
||||||
uint16_t shaderId = ShaderManager::loadShader(name);
|
uint16_t shaderId = ShaderManager::loadShader(name);
|
||||||
GET_SHADER_COMPONENT(entityId).setShader(shaderId);
|
GET_SHADER_COMPONENT(environmentId, entityId).setShader(shaderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -458,46 +462,46 @@ namespace Deer {
|
|||||||
float CameraComponentStruct::getFov() {
|
float CameraComponentStruct::getFov() {
|
||||||
ASSERT_CAMERA_COMPONENT("getFov()", return 0);
|
ASSERT_CAMERA_COMPONENT("getFov()", return 0);
|
||||||
|
|
||||||
return GET_CAMERA_COMPONENT(entityId).fov / 3.141f * 180.0f;
|
return GET_CAMERA_COMPONENT(environmentId, entityId).fov / 3.141f * 180.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CameraComponentStruct::getAspectRation() {
|
float CameraComponentStruct::getAspectRation() {
|
||||||
ASSERT_CAMERA_COMPONENT("getAspectRation()", return 0);
|
ASSERT_CAMERA_COMPONENT("getAspectRation()", return 0);
|
||||||
|
|
||||||
return GET_CAMERA_COMPONENT(entityId).aspect;
|
return GET_CAMERA_COMPONENT(environmentId, entityId).aspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CameraComponentStruct::getNearZ() {
|
float CameraComponentStruct::getNearZ() {
|
||||||
ASSERT_CAMERA_COMPONENT("getNearZ()", return 0);
|
ASSERT_CAMERA_COMPONENT("getNearZ()", return 0);
|
||||||
|
|
||||||
return GET_CAMERA_COMPONENT(entityId).nearZ;
|
return GET_CAMERA_COMPONENT(environmentId, entityId).nearZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CameraComponentStruct::getFarZ() {
|
float CameraComponentStruct::getFarZ() {
|
||||||
ASSERT_CAMERA_COMPONENT("getFarZ()", return 0);
|
ASSERT_CAMERA_COMPONENT("getFarZ()", return 0);
|
||||||
|
|
||||||
return GET_CAMERA_COMPONENT(entityId).farZ;
|
return GET_CAMERA_COMPONENT(environmentId, entityId).farZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraComponentStruct::setFov(float v) {
|
void CameraComponentStruct::setFov(float v) {
|
||||||
ASSERT_CAMERA_COMPONENT("getFarZ()", return);
|
ASSERT_CAMERA_COMPONENT("getFarZ()", return);
|
||||||
|
|
||||||
GET_CAMERA_COMPONENT(entityId).fov = v * 3.141f / 180.0f;
|
GET_CAMERA_COMPONENT(environmentId, entityId).fov = v * 3.141f / 180.0f;
|
||||||
}
|
}
|
||||||
void CameraComponentStruct::setAspectRation(float v) {
|
void CameraComponentStruct::setAspectRation(float v) {
|
||||||
ASSERT_CAMERA_COMPONENT("setAspectRation()", return);
|
ASSERT_CAMERA_COMPONENT("setAspectRation()", return);
|
||||||
|
|
||||||
GET_CAMERA_COMPONENT(entityId).aspect = v;
|
GET_CAMERA_COMPONENT(environmentId, entityId).aspect = v;
|
||||||
}
|
}
|
||||||
void CameraComponentStruct::setNearZ(float v) {
|
void CameraComponentStruct::setNearZ(float v) {
|
||||||
ASSERT_CAMERA_COMPONENT("setNearZ()", return);
|
ASSERT_CAMERA_COMPONENT("setNearZ()", return);
|
||||||
|
|
||||||
GET_CAMERA_COMPONENT(entityId).nearZ = v;
|
GET_CAMERA_COMPONENT(environmentId, entityId).nearZ = v;
|
||||||
}
|
}
|
||||||
void CameraComponentStruct::setFarZ(float v) {
|
void CameraComponentStruct::setFarZ(float v) {
|
||||||
ASSERT_CAMERA_COMPONENT("setFarZ()", return);
|
ASSERT_CAMERA_COMPONENT("setFarZ()", return);
|
||||||
|
|
||||||
GET_CAMERA_COMPONENT(entityId).farZ = v;
|
GET_CAMERA_COMPONENT(environmentId, entityId).farZ = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,20 +1,27 @@
|
|||||||
#include "DeerStudio/EditorEngine/API/Environment.h"
|
|
||||||
#include "Deer/Enviroment.h"
|
#include "Deer/Enviroment.h"
|
||||||
|
#include "Deer/Scene.h"
|
||||||
|
#include "Deer/Memory.h"
|
||||||
|
|
||||||
|
#include "DeerStudio/EditorEngine/API/Environment.h"
|
||||||
|
|
||||||
#include "DeerRender/FrameBuffer.h"
|
#include "DeerRender/FrameBuffer.h"
|
||||||
#include "DeerRender/SceneCamera.h"
|
#include "DeerRender/SceneCamera.h"
|
||||||
#include "Deer/Scene.h"
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
namespace EditorEngine {
|
namespace EditorEngine {
|
||||||
|
// The first element has to allways point to the main scene env
|
||||||
|
std::vector <Environment*> environments { &Scene::environment };
|
||||||
|
|
||||||
void EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) {
|
void EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) {
|
||||||
FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId);
|
FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId);
|
||||||
Environment& env = EnvironmentManager::getEnvironment(environmentId);
|
Environment& env = *environments[environmentId];
|
||||||
|
|
||||||
frameBuffer.bind();
|
frameBuffer.bind();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
Scene::render(sc);
|
env.render(sc);
|
||||||
//env.render(sceneCamera);
|
|
||||||
|
|
||||||
frameBuffer.unbind();
|
frameBuffer.unbind();
|
||||||
}
|
}
|
||||||
@ -27,20 +34,15 @@ namespace Deer {
|
|||||||
return EntityHandleStruct(id, environmentId);
|
return EntityHandleStruct(id, environmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string EnvironmentStruct::getName() {
|
|
||||||
return EnvironmentManager::getEnvironmentName(environmentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
EnvironmentHandleStruct getMainEnvironment() {
|
EnvironmentHandleStruct getMainEnvironment() {
|
||||||
return EnvironmentHandleStruct(0);
|
return EnvironmentHandleStruct(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentHandleStruct createEnvironment(std::string& name) {
|
EnvironmentHandleStruct createEnvironment() {
|
||||||
return EnvironmentHandleStruct(EnvironmentManager::createEnvironment(name));
|
uint16_t envId = environments.size();
|
||||||
}
|
environments.push_back({});
|
||||||
|
|
||||||
EnvironmentHandleStruct getEnvironment(std::string& name) {
|
return EnvironmentHandleStruct(envId);
|
||||||
return EnvironmentHandleStruct(EnvironmentManager::getEnvironmentId(name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,15 +18,12 @@ namespace Deer {
|
|||||||
void registerEnvironmentFunctions() {
|
void registerEnvironmentFunctions() {
|
||||||
scriptEngine->SetDefaultNamespace("Engine");
|
scriptEngine->SetDefaultNamespace("Engine");
|
||||||
REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", getMainEnvironment);
|
REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", getMainEnvironment);
|
||||||
REGISTER_GLOBAL_FUNC("Environment createEnvironment(const string&in)", createEnvironment);
|
REGISTER_GLOBAL_FUNC("Environment createEnvironment()", createEnvironment);
|
||||||
REGISTER_GLOBAL_FUNC("Environment getEnvironment(const string&in)", getEnvironment);
|
|
||||||
scriptEngine->SetDefaultNamespace("");
|
scriptEngine->SetDefaultNamespace("");
|
||||||
|
|
||||||
REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", EnvironmentStruct, render);
|
REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", EnvironmentStruct, render);
|
||||||
REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", EnvironmentStruct, getRootEntity);
|
REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", EnvironmentStruct, getRootEntity);
|
||||||
REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", EnvironmentStruct, getEntity);
|
REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", EnvironmentStruct, getEntity);
|
||||||
REGISTER_OBJECT_METHOD("Environment", "string get_name() const property", EnvironmentStruct, getName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,10 @@ namespace Deer {
|
|||||||
isValid = true;
|
isValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* EditorEngine::DockPanelObject::getName() {
|
||||||
|
return type->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
EditorEngine::DockPanelObject::~DockPanelObject() {
|
EditorEngine::DockPanelObject::~DockPanelObject() {
|
||||||
if (object)
|
if (object)
|
||||||
object->Release();
|
object->Release();
|
||||||
|
@ -27,10 +27,13 @@ namespace Deer {
|
|||||||
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
||||||
|
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
bool enabled = true;
|
||||||
|
|
||||||
void executeRender();
|
void executeRender();
|
||||||
void invalidate();
|
void invalidate();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
const char* getName();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace Deer {
|
namespace Deer {
|
||||||
|
namespace EditorEngine {
|
||||||
|
CScriptBuilder builtContext;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorEngine::loadScripts() {
|
void EditorEngine::loadScripts() {
|
||||||
Path path = DataStore::rootPath / DEER_EDITOR_PATH;
|
Path path = DataStore::rootPath / DEER_EDITOR_PATH;
|
||||||
CScriptBuilder builder;
|
|
||||||
|
|
||||||
AS_RET_CHECK(builder.StartNewModule(scriptEngine, "DeerModule"));
|
AS_RET_CHECK(builtContext.StartNewModule(scriptEngine, "DeerModule"));
|
||||||
|
|
||||||
DEER_CORE_TRACE("Extracting UI Engine Scripts ");
|
DEER_CORE_TRACE("Extracting UI Engine Scripts ");
|
||||||
for (const auto& entry : fs::recursive_directory_iterator(path)) {
|
for (const auto& entry : fs::recursive_directory_iterator(path)) {
|
||||||
@ -27,12 +30,12 @@ namespace Deer {
|
|||||||
//DEER_UI_ENGINE_TRACE("\t{0}", entry.path().stem().string().c_str());
|
//DEER_UI_ENGINE_TRACE("\t{0}", entry.path().stem().string().c_str());
|
||||||
// We add aditional info to check who caused the error
|
// We add aditional info to check who caused the error
|
||||||
AS_CHECK_ADDITIONAL_INFO(
|
AS_CHECK_ADDITIONAL_INFO(
|
||||||
builder.AddSectionFromFile(entry.path().string().c_str());,
|
builtContext.AddSectionFromFile(entry.path().string().c_str());,
|
||||||
entry.path().string().c_str()
|
entry.path().string().c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AS_RET_CHECK(builder.BuildModule());
|
AS_RET_CHECK(builtContext.BuildModule());
|
||||||
}
|
}
|
||||||
}
|
}
|
20
DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp
Normal file
20
DeerStudio/src/DeerStudio/PannelMenuBarManagment.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "DeerStudio/DeerStudio.h"
|
||||||
|
#include "DeerStudio/EditorEngine.h"
|
||||||
|
#include "DeerStudio/EditorEngine/DockPanelObject.h"
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
|
||||||
|
namespace Deer {
|
||||||
|
namespace DeerStudio {
|
||||||
|
void onPannelMenuBar() {
|
||||||
|
if (ImGui::BeginMenu("Show/Hide")) {
|
||||||
|
for (EditorEngine::DockPanelObject& pannel : EditorEngine::dockPanels) {
|
||||||
|
const char* name = pannel.getName();
|
||||||
|
|
||||||
|
ImGui::MenuItem(name, nullptr, &pannel.enabled);
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,10 +22,19 @@
|
|||||||
#include "Deer/Path.h"
|
#include "Deer/Path.h"
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
|
||||||
void printEnumList(const asIScriptEngine& engine)
|
void printFuncList(const asIScriptEngine& engine) {
|
||||||
{
|
for (int i = 0; i < engine.GetFuncdefCount(); ++i) {
|
||||||
for (int i = 0; i < engine.GetEnumCount(); ++i)
|
asITypeInfo* t = engine.GetFuncdefByIndex(i);
|
||||||
{
|
if (!t) continue;
|
||||||
|
|
||||||
|
asIScriptFunction* f = t->GetFuncdefSignature();
|
||||||
|
|
||||||
|
stream << "funcdef "<< f->GetDeclaration(true, false, true) << ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printEnumList(const asIScriptEngine& engine) {
|
||||||
|
for (int i = 0; i < engine.GetEnumCount(); ++i) {
|
||||||
const auto e = engine.GetEnumByIndex(i);
|
const auto e = engine.GetEnumByIndex(i);
|
||||||
if (!e) continue;
|
if (!e) continue;
|
||||||
|
|
||||||
@ -41,7 +50,7 @@ void printEnumList(const asIScriptEngine& engine)
|
|||||||
stream << "\n";
|
stream << "\n";
|
||||||
}
|
}
|
||||||
stream << "}\n";
|
stream << "}\n";
|
||||||
if (!ns.empty()) stream << "}\n";
|
if (!ns.empty()) stream << "}\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,13 +58,15 @@ void printClassTypeList(const asIScriptEngine& engine)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < engine.GetObjectTypeCount(); ++i)
|
for (int i = 0; i < engine.GetObjectTypeCount(); ++i)
|
||||||
{
|
{
|
||||||
const auto t = engine.GetObjectTypeByIndex(i);
|
asITypeInfo* t = engine.GetObjectTypeByIndex(i);
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
|
|
||||||
std::string_view ns = t->GetNamespace();
|
std::string_view ns = t->GetNamespace();
|
||||||
if (!ns.empty()) stream << "namespace " << ns << " {\n";
|
if (!ns.empty()) stream << "namespace " << ns << " {\n";
|
||||||
|
|
||||||
stream << "class " << t->GetName();
|
stream << "class " << t->GetName();
|
||||||
|
if (std::string("any") == t->GetName())
|
||||||
|
stream << " " ;
|
||||||
if (t->GetSubTypeCount() > 0)
|
if (t->GetSubTypeCount() > 0)
|
||||||
{
|
{
|
||||||
stream << "<";
|
stream << "<";
|
||||||
@ -70,26 +81,36 @@ void printClassTypeList(const asIScriptEngine& engine)
|
|||||||
|
|
||||||
stream << " {\n";
|
stream << " {\n";
|
||||||
|
|
||||||
|
for (int j = 0; j < t->GetFactoryCount(); ++j)
|
||||||
|
{
|
||||||
|
asIScriptFunction* f = t->GetFactoryByIndex(j);
|
||||||
|
|
||||||
|
stream << "\t" << f->GetDeclaration(false, false, true) << ";\n";
|
||||||
|
}
|
||||||
|
|
||||||
for (int j = 0; j < t->GetBehaviourCount(); ++j)
|
for (int j = 0; j < t->GetBehaviourCount(); ++j)
|
||||||
{
|
{
|
||||||
asEBehaviours behaviours;
|
asEBehaviours behaviours;
|
||||||
const auto f = t->GetBehaviourByIndex(j, &behaviours);
|
const auto f = t->GetBehaviourByIndex(j, &behaviours);
|
||||||
|
|
||||||
if (behaviours == asBEHAVE_CONSTRUCT ||
|
if (behaviours == asBEHAVE_CONSTRUCT ||
|
||||||
behaviours == asBEHAVE_DESTRUCT)
|
behaviours == asBEHAVE_DESTRUCT ||
|
||||||
{
|
behaviours == asBEHAVE_FACTORY)
|
||||||
stream << "\t" << f->GetDeclaration(false, true, true) << ";\n";
|
stream << "\t" << f->GetDeclaration(false, false, true) << ";\n";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < t->GetMethodCount(); ++j)
|
for (int j = 0; j < t->GetMethodCount(); ++j)
|
||||||
{
|
{
|
||||||
const auto m = t->GetMethodByIndex(j);
|
const auto m = t->GetMethodByIndex(j);
|
||||||
stream << "\t" << m->GetDeclaration(false, true, true) << ";\n";
|
stream << "\t" << m->GetDeclaration(false, false, true);
|
||||||
|
if (m->IsProperty())
|
||||||
|
stream << " property";
|
||||||
|
stream << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < t->GetPropertyCount(); ++j)
|
for (int j = 0; j < t->GetPropertyCount(); ++j)
|
||||||
{
|
{
|
||||||
stream << "\t" << t->GetPropertyDeclaration(j, true) << ";\n";
|
stream << "\t" << t->GetPropertyDeclaration(j, false) << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < t->GetChildFuncdefCount(); ++j)
|
for (int j = 0; j < t->GetChildFuncdefCount(); ++j)
|
||||||
@ -98,7 +119,7 @@ void printClassTypeList(const asIScriptEngine& engine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream << "}\n";
|
stream << "}\n";
|
||||||
if (!ns.empty()) stream << "}\n";
|
if (!ns.empty()) stream << "}\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +176,8 @@ void printGlobalTypedef(const asIScriptEngine& engine)
|
|||||||
|
|
||||||
void printAngelInfo(const asIScriptEngine& engine)
|
void printAngelInfo(const asIScriptEngine& engine)
|
||||||
{
|
{
|
||||||
|
printFuncList(engine);
|
||||||
|
|
||||||
printEnumList(engine);
|
printEnumList(engine);
|
||||||
|
|
||||||
printClassTypeList(engine);
|
printClassTypeList(engine);
|
||||||
@ -173,7 +196,7 @@ void extract_angelScript() {
|
|||||||
|
|
||||||
std::string str = stream.str();
|
std::string str = stream.str();
|
||||||
|
|
||||||
Deer::Path filePath = Deer::DataStore::rootPath / DEER_EDITOR_PATH / "as.predefined_tmp";
|
Deer::Path filePath = Deer::DataStore::rootPath / DEER_EDITOR_PATH / "as.predefined";
|
||||||
|
|
||||||
std::ofstream file(filePath, std::ios::out | std::ios::binary);
|
std::ofstream file(filePath, std::ios::out | std::ios::binary);
|
||||||
file.write(reinterpret_cast<const char*>(str.c_str()), str.size());
|
file.write(reinterpret_cast<const char*>(str.c_str()), str.size());
|
||||||
|
30
roe/Editor/CameraViewport/CameraPannel.as
Normal file
30
roe/Editor/CameraViewport/CameraPannel.as
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
class CameraPannel : DockPanel {
|
||||||
|
FrameBuffer frameBuffer;
|
||||||
|
Environment mainEnv;
|
||||||
|
|
||||||
|
void onRender() {
|
||||||
|
if (!frameBuffer.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int x = UI::getAvailableSizeX();
|
||||||
|
int y = UI::getAvailableSizeY();
|
||||||
|
|
||||||
|
if (x < 10 || y < 10)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frameBuffer.resize(x, y);
|
||||||
|
frameBuffer.clearRGBA(0, 0, 0, 255);
|
||||||
|
|
||||||
|
UI::drawFrameBufferCentered(frameBuffer, x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onInit() {
|
||||||
|
frameBuffer = Engine::createRGBA8FrameBuffer("MainFrameBuffer", 400, 400);
|
||||||
|
mainEnv = Engine::getMainEnvironment();
|
||||||
|
|
||||||
|
UI::disablePannelPadding(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
class MeshExplorer : DockPanel {
|
class MeshExplorer : DockPanel {
|
||||||
string currentPath = "";
|
string currentPath = "";
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
dictionary meshFrameBuffer;
|
dictionary meshFrameBuffer;
|
||||||
|
Environment renderEnvironment;
|
||||||
|
|
||||||
FrameBuffer getMeshFrameBuffer(string mesh) {
|
FrameBuffer getMeshFrameBuffer(string mesh) {
|
||||||
if (meshFrameBuffer.exists(mesh))
|
|
||||||
return cast<FrameBuffer>(meshFrameBuffer[mesh]);
|
return generateMeshFrameBuffer(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer generateMeshFrameBuffer(string mesh) {
|
FrameBuffer generateMeshFrameBuffer(string mesh) {
|
||||||
FrameBuffer fb = Engine::createRGBA8FrameBuffer(mesh, 64, 64);
|
FrameBuffer fb = Engine::createRGBA8FrameBuffer(mesh, 64, 64);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return fb;
|
return fb;
|
||||||
}
|
}
|
@ -7,6 +7,9 @@ class PropertiesPannel : DockPanel {
|
|||||||
void onRender() {
|
void onRender() {
|
||||||
Entity entity = activeEntity;
|
Entity entity = activeEntity;
|
||||||
|
|
||||||
|
// We don't want to change root options
|
||||||
|
if (entity.isRoot)
|
||||||
|
return;
|
||||||
// NAME
|
// NAME
|
||||||
// -------
|
// -------
|
||||||
// Id:0 [+ add component]
|
// Id:0 [+ add component]
|
||||||
@ -16,9 +19,6 @@ class PropertiesPannel : DockPanel {
|
|||||||
UI::separator();
|
UI::separator();
|
||||||
UI::textColor(0.5, 0.5, 0.5f, "Id : " + entity.id);
|
UI::textColor(0.5, 0.5, 0.5f, "Id : " + entity.id);
|
||||||
|
|
||||||
// We don't want to change root options
|
|
||||||
if (entity.isRoot)
|
|
||||||
return;
|
|
||||||
|
|
||||||
UI::sameline();
|
UI::sameline();
|
||||||
if (UI::buttonEnd("Add Component")) {
|
if (UI::buttonEnd("Add Component")) {
|
||||||
|
@ -1,23 +1,71 @@
|
|||||||
|
|
||||||
funcdef void ReciverFunc(any@ value);
|
|
||||||
funcdef void TransferFunc(any@ from, any@ data);
|
|
||||||
|
|
||||||
|
|
||||||
enum key
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
A, B, C, D, E, F, G, H, I, J, K, L, M,
|
|
||||||
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
|
||||||
K0, K1, K2, K3, K4, K5, K6, K7, K8, K9,
|
|
||||||
Tab, Enter, Escape, Backspace, Space, Delete, Insert, Home, End, PageUp, PageDown,
|
|
||||||
Right, Up, Down, Left,
|
|
||||||
RightCtrl, LeftShift, RightShift,
|
|
||||||
LeftAlt, RightAlt, LeftSuper,
|
|
||||||
RightSuper, LeftCtrl,
|
|
||||||
MouseLeft,MouseRight,MouseMiddle
|
|
||||||
};
|
|
||||||
|
|
||||||
//This file was generated automatically
|
//This file was generated automatically
|
||||||
|
funcdef bool T[]::less(const T&in a, const T&in b);
|
||||||
|
funcdef void ReciverFunc(any@);
|
||||||
|
funcdef void TransferFunc(any@, any@);
|
||||||
|
enum key {
|
||||||
|
A = 546,
|
||||||
|
B = 547,
|
||||||
|
C = 548,
|
||||||
|
D = 549,
|
||||||
|
E = 550,
|
||||||
|
F = 551,
|
||||||
|
G = 552,
|
||||||
|
H = 553,
|
||||||
|
I = 554,
|
||||||
|
J = 555,
|
||||||
|
K = 556,
|
||||||
|
L = 557,
|
||||||
|
M = 558,
|
||||||
|
N = 559,
|
||||||
|
O = 560,
|
||||||
|
P = 561,
|
||||||
|
Q = 562,
|
||||||
|
R = 563,
|
||||||
|
S = 564,
|
||||||
|
T = 565,
|
||||||
|
U = 566,
|
||||||
|
V = 567,
|
||||||
|
W = 568,
|
||||||
|
X = 569,
|
||||||
|
Y = 570,
|
||||||
|
Z = 571,
|
||||||
|
K0 = 536,
|
||||||
|
K1 = 537,
|
||||||
|
K2 = 538,
|
||||||
|
K3 = 539,
|
||||||
|
K4 = 540,
|
||||||
|
K5 = 541,
|
||||||
|
K6 = 542,
|
||||||
|
K7 = 543,
|
||||||
|
K8 = 544,
|
||||||
|
K9 = 545,
|
||||||
|
Tab = 512,
|
||||||
|
Enter = 525,
|
||||||
|
Escape = 526,
|
||||||
|
Backspace = 523,
|
||||||
|
Space = 524,
|
||||||
|
Delete = 522,
|
||||||
|
Insert = 521,
|
||||||
|
Home = 519,
|
||||||
|
End = 520,
|
||||||
|
PageUp = 517,
|
||||||
|
PageDown = 518,
|
||||||
|
Right = 514,
|
||||||
|
Up = 515,
|
||||||
|
Down = 516,
|
||||||
|
Left = 513,
|
||||||
|
RightCtrl = 531,
|
||||||
|
LeftShift = 528,
|
||||||
|
RightShift = 532,
|
||||||
|
LeftAlt = 529,
|
||||||
|
RightAlt = 533,
|
||||||
|
LeftSuper = 530,
|
||||||
|
RightSuper = 534,
|
||||||
|
LeftCtrl = 527,
|
||||||
|
MouseLeft = 641,
|
||||||
|
MouseRight = 642,
|
||||||
|
MouseMiddle = 643
|
||||||
|
}
|
||||||
enum ResourceType {
|
enum ResourceType {
|
||||||
Mesh = 1,
|
Mesh = 1,
|
||||||
Shader = 2
|
Shader = 2
|
||||||
@ -66,448 +114,10 @@ class string {
|
|||||||
void insert(uint pos, const string&in other);
|
void insert(uint pos, const string&in other);
|
||||||
void erase(uint pos, int count = - 1);
|
void erase(uint pos, int count = - 1);
|
||||||
}
|
}
|
||||||
class ref {
|
|
||||||
~ref();
|
|
||||||
ref();
|
|
||||||
ref(const ref&in);
|
|
||||||
ref(const ?&in);
|
|
||||||
void opCast(?&out);
|
|
||||||
ref& opHndlAssign(const ref&in);
|
|
||||||
ref& opHndlAssign(const ?&in);
|
|
||||||
bool opEquals(const ref&in) const;
|
|
||||||
bool opEquals(const ?&in) const;
|
|
||||||
}
|
|
||||||
class any {
|
|
||||||
any& opAssign(any&in);
|
|
||||||
any();
|
|
||||||
any(?&in);
|
|
||||||
void store(?&in);
|
|
||||||
void store(const int64&in);
|
|
||||||
void store(const double&in);
|
|
||||||
bool retrieve(?&out);
|
|
||||||
bool retrieve(int64&out);
|
|
||||||
bool retrieve(double&out);
|
|
||||||
}
|
|
||||||
class Entity {
|
|
||||||
// Gets the entity's name
|
|
||||||
string get_name() const property;
|
|
||||||
// Sets the entity's name
|
|
||||||
void set_name(string&in) property;
|
|
||||||
|
|
||||||
// Gets the unique entity ID
|
|
||||||
int get_id() const property;
|
|
||||||
|
|
||||||
// Creates a new child entity with the given name
|
|
||||||
Entity createChild(const string&in);
|
|
||||||
|
|
||||||
// Returns true if this entity is the root entity
|
|
||||||
bool get_isRoot() const property;
|
|
||||||
|
|
||||||
// Destroys this entity
|
|
||||||
void destroy();
|
|
||||||
|
|
||||||
// Returns true if the entity currently exists
|
|
||||||
bool get_exists() const property;
|
|
||||||
|
|
||||||
// Gets the parent entity
|
|
||||||
Entity get_parent() property;
|
|
||||||
// Sets the parent entity
|
|
||||||
void set_parent(Entity) property;
|
|
||||||
|
|
||||||
// Checks if this entity is a descendant of the given entity
|
|
||||||
bool isDescendantOf(Entity);
|
|
||||||
|
|
||||||
// Compares this entity with another entity for equality
|
|
||||||
bool opEquals(const Entity&in) const;
|
|
||||||
|
|
||||||
// Gets the collection of child entities
|
|
||||||
EntityChilds get_childs() const property;
|
|
||||||
|
|
||||||
// Gets the transform component of the entity
|
|
||||||
TransformComponent get_transform() const property;
|
|
||||||
|
|
||||||
// Mesh component methods
|
|
||||||
MeshComponent getMeshComponent();
|
|
||||||
MeshComponent createMeshComponent();
|
|
||||||
bool hasMeshComponent();
|
|
||||||
void removeMeshComponent();
|
|
||||||
|
|
||||||
// Shader component methods
|
|
||||||
ShaderComponent getShaderComponent();
|
|
||||||
ShaderComponent createShaderComponent();
|
|
||||||
bool hasShaderComponent();
|
|
||||||
void removeShaderComponent();
|
|
||||||
|
|
||||||
// Camera component methods
|
|
||||||
CameraComponent getCameraComponent();
|
|
||||||
CameraComponent createCameraComponent();
|
|
||||||
bool hasCameraComponent();
|
|
||||||
void removeCameraComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
class EntityChilds {
|
|
||||||
// Gets the number of child entities
|
|
||||||
int get_count() const property;
|
|
||||||
|
|
||||||
// Access child entity by index
|
|
||||||
Entity opIndex(int) const;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TransformComponent {
|
|
||||||
// Gets/sets position vector
|
|
||||||
vec3 get_position() const property;
|
|
||||||
void set_position(const vec3) property;
|
|
||||||
|
|
||||||
// Gets/sets scale vector
|
|
||||||
vec3 get_scale() const property;
|
|
||||||
void set_scale(const vec3) property;
|
|
||||||
|
|
||||||
// Gets/sets rotation vector (Euler angles)
|
|
||||||
vec3 get_rotation() const property;
|
|
||||||
void set_rotation(const vec3) property;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class MeshComponent {
|
|
||||||
// Is mesh component active?
|
|
||||||
bool get_isActive() const property;
|
|
||||||
void set_isActive(const bool) property;
|
|
||||||
|
|
||||||
// Does this component have a mesh assigned?
|
|
||||||
bool get_hasMesh() const property;
|
|
||||||
|
|
||||||
// Clears the mesh data
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
// Gets/sets mesh identifier
|
|
||||||
string getMesh();
|
|
||||||
void setMesh(string&in);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ShaderComponent {
|
|
||||||
// Does this component have a shader assigned?
|
|
||||||
bool get_hasShader() const property;
|
|
||||||
|
|
||||||
// Clears the shader data
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
// Gets/sets shader identifier
|
|
||||||
string getShader();
|
|
||||||
void setShader(const string&in);
|
|
||||||
}
|
|
||||||
|
|
||||||
class CameraComponent {
|
|
||||||
// Gets/sets field of view
|
|
||||||
float get_fov() const property;
|
|
||||||
void set_fov(float) property;
|
|
||||||
|
|
||||||
// Gets/sets aspect ratio
|
|
||||||
float get_aspectRatio() const property;
|
|
||||||
void set_aspectRatio(float) property;
|
|
||||||
|
|
||||||
// Gets/sets near clipping plane distance
|
|
||||||
float get_nearZ() const property;
|
|
||||||
void set_nearZ(float) property;
|
|
||||||
|
|
||||||
// Gets/sets far clipping plane distance
|
|
||||||
float get_farZ() const property;
|
|
||||||
void set_farZ(float) property;
|
|
||||||
}
|
|
||||||
|
|
||||||
class vec3 {
|
|
||||||
// Default constructor (zero vector)
|
|
||||||
vec3();
|
|
||||||
// Constructor with components (y,z default to 0)
|
|
||||||
vec3(float, float = 0, float = 0);
|
|
||||||
|
|
||||||
// Vector addition
|
|
||||||
vec3 opAdd(const vec3&in);
|
|
||||||
// Vector subtraction
|
|
||||||
vec3 opSub(const vec3&in) const;
|
|
||||||
// Negation
|
|
||||||
vec3 opNeg() const;
|
|
||||||
// Multiply by scalar
|
|
||||||
vec3 opMul(float) const;
|
|
||||||
vec3 opMul_r(float) const;
|
|
||||||
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
}
|
|
||||||
|
|
||||||
class quat {
|
|
||||||
~quat();
|
|
||||||
quat();
|
|
||||||
quat(const quat&in);
|
|
||||||
quat(float, float, float, float);
|
|
||||||
|
|
||||||
// Quaternion multiplication
|
|
||||||
quat opMul(const quat&in) const;
|
|
||||||
|
|
||||||
// Gets/sets Euler angles representation of the quaternion
|
|
||||||
vec3 getEuler() const;
|
|
||||||
void setEuler(vec3);
|
|
||||||
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float w;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Transform {
|
|
||||||
Transform();
|
|
||||||
|
|
||||||
vec3 position;
|
|
||||||
vec3 scale;
|
|
||||||
quat rotation;
|
|
||||||
|
|
||||||
// Returns a vec3 relative to the transform
|
|
||||||
vec3 relative(vec3);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Camera {
|
|
||||||
~Camera();
|
|
||||||
|
|
||||||
float fov;
|
|
||||||
float aspect;
|
|
||||||
float nearZ;
|
|
||||||
float farZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SceneCamera {
|
|
||||||
~SceneCamera();
|
|
||||||
|
|
||||||
Camera camera;
|
|
||||||
Transform transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
class FrameBuffer {
|
|
||||||
// Clears the framebuffer with RGBA color
|
|
||||||
void clearRGBA(int, int, int, int);
|
|
||||||
// Gets the height of the framebuffer
|
|
||||||
int get_height() const property;
|
|
||||||
// Resizes the framebuffer
|
|
||||||
void resize(int, int);
|
|
||||||
// Gets the framebuffer's name
|
|
||||||
string get_name() const property;
|
|
||||||
bool isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
class Environment {
|
|
||||||
// Renders the scene with the given camera and framebuffer target
|
|
||||||
void render(FrameBuffer, SceneCamera);
|
|
||||||
// Gets the root entity of the environment
|
|
||||||
Entity getRootEntity();
|
|
||||||
// Gets an entity by its ID
|
|
||||||
Entity getEntity(int);
|
|
||||||
// Gets the environment's name
|
|
||||||
string get_name() const property;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DockPanel {
|
|
||||||
// Called to render the dock panel UI
|
|
||||||
void onRender();
|
|
||||||
void onInit();
|
|
||||||
void onMenuBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Format a signed 64-bit integer to string with optional formatting and width
|
|
||||||
string formatInt(int64 val, const string& in options = "", uint width = 0);
|
|
||||||
// Format an unsigned 64-bit integer to string with optional formatting and width
|
|
||||||
string formatUInt(uint64 val, const string& in options = "", uint width = 0);
|
|
||||||
// Format a double-precision float to string with options, width, and precision
|
|
||||||
string formatFloat(double val, const string& in options = "", uint width = 0, uint precision = 0);
|
|
||||||
|
|
||||||
// Parse a signed 64-bit integer from string with base, returning byte count parsed
|
|
||||||
int64 parseInt(const string& in str, uint base = 10, uint& out byteCount = 0);
|
|
||||||
// Parse an unsigned 64-bit integer from string with base, returning byte count parsed
|
|
||||||
uint64 parseUInt(const string& in str, uint base = 10, uint& out byteCount = 0);
|
|
||||||
// Parse a double-precision float from string, returning byte count parsed
|
|
||||||
double parseFloat(const string& in str, uint& out byteCount = 0);
|
|
||||||
|
|
||||||
namespace Engine {
|
|
||||||
// Print a message to the engine's console or log
|
|
||||||
void print(const string& in message);
|
|
||||||
// Retrieve the root entity of the scene or hierarchy
|
|
||||||
Entity getRoot();
|
|
||||||
// Create an RGBA8 framebuffer with a name and size
|
|
||||||
FrameBuffer createRGBA8FrameBuffer(const string& in name, int width, int height);
|
|
||||||
// Retrieve an existing framebuffer by name
|
|
||||||
FrameBuffer getFrameBuffer(const string& in name);
|
|
||||||
|
|
||||||
// Get the main environment instance
|
|
||||||
Environment getMainEnvironment();
|
|
||||||
// Create a new environment with the given name
|
|
||||||
Environment createEnvironment(const string& in name);
|
|
||||||
// Retrieve an environment by name
|
|
||||||
Environment getEnvironment(const string& in name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Resource {
|
|
||||||
// Get the number of resources of a given type and category
|
|
||||||
int getResourceCount(ResourceType type, const string& in category);
|
|
||||||
// Get the name of a resource by type, category, and resource ID
|
|
||||||
string getResourceNameById(ResourceType type, const string& in category, int id);
|
|
||||||
// Get the file path of a resource by type, category, and resource ID
|
|
||||||
string getResourcePathById(ResourceType type, const string& in category, int id);
|
|
||||||
|
|
||||||
// Get the number of directories of a given resource type and category
|
|
||||||
int getDirCount(ResourceType type, const string& in category);
|
|
||||||
// Get the path of a directory by resource type, category, and directory ID
|
|
||||||
string getDirPathById(ResourceType type, const string& in category, int id);
|
|
||||||
// Get the name of a directory by resource type, category, and directory ID
|
|
||||||
string getDirNameById(ResourceType type, const string& in category, int id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace UI {
|
|
||||||
// Columns
|
|
||||||
|
|
||||||
// Setup automatic columns with given count
|
|
||||||
void setupAutomaticColumns(int count);
|
|
||||||
// Setup fixed columns count
|
|
||||||
void setupColumns(int count);
|
|
||||||
// End columns layout
|
|
||||||
void endColumns();
|
|
||||||
// Move to next column
|
|
||||||
void nextColumn();
|
|
||||||
|
|
||||||
// Tree nodes
|
|
||||||
|
|
||||||
// Draw leaf node with label and open state
|
|
||||||
void treeNodeLeaf(const string& in label, bool open);
|
|
||||||
// Draw tree node with label, open state, data, and callback
|
|
||||||
bool treeNode(const string& in label, bool open, any@ data, ReciverFunc@ cb);
|
|
||||||
// Draw component node with label, data, and callback
|
|
||||||
bool componentNode(const string& in label, any@ data, ReciverFunc@ cb);
|
|
||||||
// Draw component node with context menu support
|
|
||||||
bool componentNode_contextMenu(const string& in label, any@ data, ReciverFunc@ cb, ReciverFunc@ ctxMenu);
|
|
||||||
|
|
||||||
// Popups & Context menus
|
|
||||||
|
|
||||||
// Show a context menu popup with callback
|
|
||||||
void contextMenuPopup(const string& in label, any@ data, ReciverFunc@ cb);
|
|
||||||
// Popup attached to an item with label, data, and callback
|
|
||||||
void contextItemPopup(const string& in label, any@ data, ReciverFunc@ cb);
|
|
||||||
// Show a modal popup blocking interaction until closed
|
|
||||||
void modalPopup(const string& in label, ReciverFunc@ cb);
|
|
||||||
// Show a simple popup window with callback
|
|
||||||
void simplePopup(const string& in label, ReciverFunc@ cb);
|
|
||||||
// Open a popup with label and associated data
|
|
||||||
void openPopup(const string& in label, any@ data);
|
|
||||||
// Close the currently opened popup
|
|
||||||
void closePopup();
|
|
||||||
|
|
||||||
// Drag & Drop
|
|
||||||
|
|
||||||
// Start a drag-drop source with type, data, and payload string
|
|
||||||
void dragDropSource(const string& in type, any@ data, const string& in payload);
|
|
||||||
// Define a drag-drop target with type, data, and transfer callback
|
|
||||||
void dragDropTarget(const string& in type, any@ data, TransferFunc@ transfer);
|
|
||||||
|
|
||||||
// Buttons & Controls
|
|
||||||
|
|
||||||
// Create a clickable button with label
|
|
||||||
bool button(const string& in label);
|
|
||||||
// Create a centered button
|
|
||||||
bool buttonCenter(const string& in label);
|
|
||||||
// Create a button aligned to the end of the line
|
|
||||||
bool buttonEnd(const string& in label);
|
|
||||||
// Checkbox toggle with label and current value
|
|
||||||
bool checkbox(const string& in label, bool val);
|
|
||||||
// Disabled checkbox with label and current value
|
|
||||||
bool checkboxDisabled(const string& in label, bool val);
|
|
||||||
|
|
||||||
// Drawing
|
|
||||||
|
|
||||||
// Draw a framebuffer with given width and height
|
|
||||||
void drawFrameBuffer(FrameBuffer fb, int w, int h);
|
|
||||||
// Draw a framebuffer centered with given dimensions
|
|
||||||
void drawFrameBufferCentered(FrameBuffer fb, int w, int h);
|
|
||||||
// Draw an icon with name and size
|
|
||||||
void drawIcon(const string& in icon, int size);
|
|
||||||
// Draw a centered icon with name and size
|
|
||||||
void drawIconCentered(const string& in icon, int size);
|
|
||||||
|
|
||||||
// Input & Interaction
|
|
||||||
|
|
||||||
// Text input field with label, initial value, and output string
|
|
||||||
bool inputText(const string& in label, const string& in initial, string& out result);
|
|
||||||
// Check if an item was clicked with specific mouse button
|
|
||||||
bool isItemClicked(int button);
|
|
||||||
// Check if mouse was double-clicked with specific button
|
|
||||||
bool isMouseDoubleClicked(int button);
|
|
||||||
|
|
||||||
// Sliders
|
|
||||||
|
|
||||||
// Slider for a float value with step increment
|
|
||||||
float magicSlider(const string& in label, float val, float step);
|
|
||||||
// Slider for a vec3 value with step increment
|
|
||||||
vec3 magicSlider3(const string& in label, vec3 val, float step);
|
|
||||||
|
|
||||||
// Menu Items
|
|
||||||
|
|
||||||
// Selectable menu item with label
|
|
||||||
bool menuItem(const string& in label);
|
|
||||||
// Disabled (non-selectable) menu item with label
|
|
||||||
void menuItemDisabled(const string& in label);
|
|
||||||
// Menu space with label, data, and callback
|
|
||||||
void menuSpace(const string& in label, any@ data, ReciverFunc@ cb);
|
|
||||||
|
|
||||||
// Layout
|
|
||||||
|
|
||||||
// Place next UI element on the same line
|
|
||||||
void sameline();
|
|
||||||
// Draw a horizontal separator line
|
|
||||||
void separator();
|
|
||||||
// Add vertical space
|
|
||||||
void space();
|
|
||||||
// Add multiple vertical spaces with optional spacing
|
|
||||||
void space(int count, int spacing=10);
|
|
||||||
|
|
||||||
// Text
|
|
||||||
|
|
||||||
// Draw normal text
|
|
||||||
void text(const string& in txt);
|
|
||||||
// Draw centered text
|
|
||||||
void textCenter(const string& in txt);
|
|
||||||
// Draw colored text with RGB and string
|
|
||||||
void textColor(float r, float g, float b, const string& in txt);
|
|
||||||
// Draw text aligned to end
|
|
||||||
void textEnd(const string& in txt);
|
|
||||||
|
|
||||||
// Titles
|
|
||||||
|
|
||||||
// Draw a title text
|
|
||||||
void title(const string& in txt);
|
|
||||||
// Draw a centered title
|
|
||||||
void titleCenter(const string& in txt);
|
|
||||||
// Draw a vertically offset centered title
|
|
||||||
void titleCenterY(const string& in txt, int yOffset);
|
|
||||||
// Draw a title aligned to the end
|
|
||||||
void titleEnd(const string& in txt);
|
|
||||||
|
|
||||||
bool isPannelActive();
|
|
||||||
|
|
||||||
bool isKeyDown(key);
|
|
||||||
bool isKeyPressed(key);
|
|
||||||
|
|
||||||
bool isMouseDraggin(key);
|
|
||||||
float getMouseDragDeltaX();
|
|
||||||
float getMouseDragDeltaY();
|
|
||||||
float getMouseDeltaX();
|
|
||||||
float getMouseDeltaY();
|
|
||||||
int getAvailableSizeX();
|
|
||||||
int getAvailableSizeY();
|
|
||||||
void disablePannelPadding(bool);
|
|
||||||
|
|
||||||
int sliderInt(string&in, int value, int min, int max);
|
|
||||||
float slider(string&in, float value, float min, float max);
|
|
||||||
}
|
|
||||||
|
|
||||||
class array<T> {
|
class array<T> {
|
||||||
|
T[]@ array(int&in);
|
||||||
|
T[]@ array(int&in, uint length);
|
||||||
|
T[]@ array(int&in, uint length, const T&in value);
|
||||||
T& opIndex(uint index);
|
T& opIndex(uint index);
|
||||||
const T& opIndex(uint index) const;
|
const T& opIndex(uint index) const;
|
||||||
T[]& opAssign(const T[]&in);
|
T[]& opAssign(const T[]&in);
|
||||||
@ -531,10 +141,9 @@ class array<T> {
|
|||||||
int findByRef(uint startAt, const T&in value) const;
|
int findByRef(uint startAt, const T&in value) const;
|
||||||
bool opEquals(const T[]&in) const;
|
bool opEquals(const T[]&in) const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
//void sort(T[]::less&in, uint startAt = 0, uint count = uint ( - 1 ));
|
void sort(T[]::less&in, uint startAt = 0, uint count = uint ( - 1 ));
|
||||||
funcdef bool less(const T&in, const T&in);
|
funcdef bool less(const T&in, const T&in);
|
||||||
}
|
}
|
||||||
|
|
||||||
class dictionaryValue {
|
class dictionaryValue {
|
||||||
~dictionaryValue();
|
~dictionaryValue();
|
||||||
dictionaryValue();
|
dictionaryValue();
|
||||||
@ -550,6 +159,7 @@ class dictionaryValue {
|
|||||||
double opConv();
|
double opConv();
|
||||||
}
|
}
|
||||||
class dictionary {
|
class dictionary {
|
||||||
|
dictionary@ dictionary();
|
||||||
dictionary& opAssign(const dictionary&in);
|
dictionary& opAssign(const dictionary&in);
|
||||||
void set(const string&in, const ?&in);
|
void set(const string&in, const ?&in);
|
||||||
bool get(const string&in, ?&out) const;
|
bool get(const string&in, ?&out) const;
|
||||||
@ -566,3 +176,225 @@ class dictionary {
|
|||||||
dictionaryValue& opIndex(const string&in);
|
dictionaryValue& opIndex(const string&in);
|
||||||
const dictionaryValue& opIndex(const string&in) const;
|
const dictionaryValue& opIndex(const string&in) const;
|
||||||
}
|
}
|
||||||
|
class ref {
|
||||||
|
~ref();
|
||||||
|
ref();
|
||||||
|
ref(const ref&in);
|
||||||
|
ref(const ?&in);
|
||||||
|
void opCast(?&out);
|
||||||
|
ref& opHndlAssign(const ref&in);
|
||||||
|
ref& opHndlAssign(const ?&in);
|
||||||
|
bool opEquals(const ref&in) const;
|
||||||
|
bool opEquals(const ?&in) const;
|
||||||
|
}
|
||||||
|
class any {
|
||||||
|
any@ any();
|
||||||
|
any@ any(?&in);
|
||||||
|
any@ any(const int64&in);
|
||||||
|
any@ any(const double&in);
|
||||||
|
any& opAssign(any&in);
|
||||||
|
void store(?&in);
|
||||||
|
void store(const int64&in);
|
||||||
|
void store(const double&in);
|
||||||
|
bool retrieve(?&out);
|
||||||
|
bool retrieve(int64&out);
|
||||||
|
bool retrieve(double&out);
|
||||||
|
}
|
||||||
|
class Entity {
|
||||||
|
string get_name() const property;
|
||||||
|
void set_name(string&in) property;
|
||||||
|
int get_id() const property;
|
||||||
|
Entity createChild(const string&in);
|
||||||
|
bool get_isRoot() const property;
|
||||||
|
void destroy();
|
||||||
|
bool get_exists() const property;
|
||||||
|
Entity get_parent() property;
|
||||||
|
void set_parent(Entity) property;
|
||||||
|
bool isDescendantOf(Entity);
|
||||||
|
bool opEquals(const Entity&in) const;
|
||||||
|
EntityChilds get_childs() const property;
|
||||||
|
TransformComponent get_transform() const property;
|
||||||
|
MeshComponent getMeshComponent();
|
||||||
|
MeshComponent createMeshComponent();
|
||||||
|
bool hasMeshComponent();
|
||||||
|
void removeMeshComponent();
|
||||||
|
ShaderComponent getShaderComponent();
|
||||||
|
ShaderComponent createShaderComponent();
|
||||||
|
bool hasShaderComponent();
|
||||||
|
void removeShaderComponent();
|
||||||
|
CameraComponent getCameraComponent();
|
||||||
|
CameraComponent createCameraComponent();
|
||||||
|
bool hasCameraComponent();
|
||||||
|
void removeCameraComponent();
|
||||||
|
}
|
||||||
|
class EntityChilds {
|
||||||
|
int get_count() const property;
|
||||||
|
Entity opIndex(int) const;
|
||||||
|
}
|
||||||
|
class TransformComponent {
|
||||||
|
vec3 get_position() const property;
|
||||||
|
vec3 get_scale() const property;
|
||||||
|
vec3 get_rotation() const property;
|
||||||
|
void set_position(const vec3) property;
|
||||||
|
void set_scale(const vec3) property;
|
||||||
|
void set_rotation(const vec3) property;
|
||||||
|
}
|
||||||
|
class MeshComponent {
|
||||||
|
bool get_isActive() const property;
|
||||||
|
bool get_hasMesh() const property;
|
||||||
|
void clear();
|
||||||
|
string getMesh();
|
||||||
|
void setMesh(string&in);
|
||||||
|
void set_isActive(const bool) property;
|
||||||
|
}
|
||||||
|
class ShaderComponent {
|
||||||
|
bool get_hasShader() const property;
|
||||||
|
void clear();
|
||||||
|
string getShader();
|
||||||
|
void setShader(const string&in);
|
||||||
|
}
|
||||||
|
class CameraComponent {
|
||||||
|
float get_fov() const property;
|
||||||
|
float get_aspectRatio() const property;
|
||||||
|
float get_nearZ() const property;
|
||||||
|
float get_farZ() const property;
|
||||||
|
void set_fov(float) property;
|
||||||
|
void set_aspectRatio(float) property;
|
||||||
|
void set_nearZ(float) property;
|
||||||
|
void set_farZ(float) property;
|
||||||
|
}
|
||||||
|
class vec3 {
|
||||||
|
vec3();
|
||||||
|
vec3(float, float = 0, float = 0);
|
||||||
|
vec3 opAdd(const vec3&in);
|
||||||
|
vec3 opSub(const vec3&in) const;
|
||||||
|
vec3 opNeg() const;
|
||||||
|
vec3 opMul(float) const;
|
||||||
|
vec3 opMul_r(float) const;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
}
|
||||||
|
class quat {
|
||||||
|
~quat();
|
||||||
|
quat();
|
||||||
|
quat(float, float, float, float);
|
||||||
|
quat opMul(const quat&in) const;
|
||||||
|
vec3 getEuler() const;
|
||||||
|
void setEuler(vec3);
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float w;
|
||||||
|
}
|
||||||
|
class Transform {
|
||||||
|
Transform();
|
||||||
|
vec3 relative(vec3);
|
||||||
|
vec3 position;
|
||||||
|
vec3 scale;
|
||||||
|
quat rotation;
|
||||||
|
}
|
||||||
|
class Camera {
|
||||||
|
Camera();
|
||||||
|
float fov;
|
||||||
|
float aspect;
|
||||||
|
float nearZ;
|
||||||
|
float farZ;
|
||||||
|
}
|
||||||
|
class SceneCamera {
|
||||||
|
SceneCamera();
|
||||||
|
Camera camera;
|
||||||
|
Transform transform;
|
||||||
|
}
|
||||||
|
class FrameBuffer {
|
||||||
|
FrameBuffer();
|
||||||
|
void clearRGBA(int, int, int, int);
|
||||||
|
int get_height() const property;
|
||||||
|
void resize(int, int);
|
||||||
|
string get_name() const property;
|
||||||
|
bool isValid();
|
||||||
|
}
|
||||||
|
class Environment {
|
||||||
|
void render(FrameBuffer, SceneCamera&in);
|
||||||
|
Entity getRootEntity();
|
||||||
|
Entity getEntity(int);
|
||||||
|
}
|
||||||
|
class DockPanel {
|
||||||
|
void onRender();
|
||||||
|
}
|
||||||
|
string formatInt(int64 val, const string&in options = "", uint width = 0);
|
||||||
|
string formatUInt(uint64 val, const string&in options = "", uint width = 0);
|
||||||
|
string formatFloat(double val, const string&in options = "", uint width = 0, uint precision = 0);
|
||||||
|
int64 parseInt(const string&in, uint base = 10, uint&out byteCount = 0);
|
||||||
|
uint64 parseUInt(const string&in, uint base = 10, uint&out byteCount = 0);
|
||||||
|
double parseFloat(const string&in, uint&out byteCount = 0);
|
||||||
|
namespace Engine { Entity getRoot(); }
|
||||||
|
namespace UI { bool button(const string&in); }
|
||||||
|
namespace UI { bool buttonCenter(const string&in); }
|
||||||
|
namespace UI { bool buttonEnd(const string&in); }
|
||||||
|
namespace UI { bool checkbox(const string&in, bool); }
|
||||||
|
namespace UI { bool checkboxDisabled(const string&in, bool); }
|
||||||
|
namespace UI { void drawFrameBuffer(FrameBuffer, int, int); }
|
||||||
|
namespace UI { void drawFrameBufferCentered(FrameBuffer, int, int); }
|
||||||
|
namespace UI { void drawIcon(const string&in, int); }
|
||||||
|
namespace UI { void drawIconCentered(const string&in, int); }
|
||||||
|
namespace UI { bool inputText(const string&in, const string&in, string&out); }
|
||||||
|
namespace UI { bool isItemClicked(int); }
|
||||||
|
namespace UI { bool isMouseDoubleClicked(int); }
|
||||||
|
namespace UI { float magicSlider(const string&in, float, float); }
|
||||||
|
namespace UI { vec3 magicSlider3(const string&in, vec3, float); }
|
||||||
|
namespace UI { bool menuItem(const string&in); }
|
||||||
|
namespace UI { void menuItemDisabled(const string&in); }
|
||||||
|
namespace UI { void menuSpace(const string&in, any@, ReciverFunc@); }
|
||||||
|
namespace UI { void sameline(); }
|
||||||
|
namespace UI { void separator(); }
|
||||||
|
namespace UI { void space(); }
|
||||||
|
namespace UI { void space(int, int = 10); }
|
||||||
|
namespace UI { void text(const string&in); }
|
||||||
|
namespace UI { void textCenter(const string&in); }
|
||||||
|
namespace UI { void textColor(float, float, float, const string&in); }
|
||||||
|
namespace UI { void textEnd(const string&in); }
|
||||||
|
namespace UI { void title(const string&in); }
|
||||||
|
namespace UI { void titleCenter(const string&in); }
|
||||||
|
namespace UI { void titleCenterY(const string&in, int); }
|
||||||
|
namespace UI { void titleEnd(const string&in); }
|
||||||
|
namespace UI { bool isKeyDown(key); }
|
||||||
|
namespace UI { bool isKeyPressed(key); }
|
||||||
|
namespace UI { bool isMouseDraggin(key); }
|
||||||
|
namespace UI { bool isPannelActive(); }
|
||||||
|
namespace UI { float getMouseDragDeltaX(); }
|
||||||
|
namespace UI { float getMouseDragDeltaY(); }
|
||||||
|
namespace UI { float getMouseDeltaX(); }
|
||||||
|
namespace UI { float getMouseDeltaY(); }
|
||||||
|
namespace UI { int getAvailableSizeX(); }
|
||||||
|
namespace UI { int getAvailableSizeY(); }
|
||||||
|
namespace UI { void disablePannelPadding(bool); }
|
||||||
|
namespace UI { int sliderInt(string&in, int, int, int); }
|
||||||
|
namespace UI { float slider(string&in, float, float, float); }
|
||||||
|
namespace Engine { FrameBuffer createRGBA8FrameBuffer(const string&in, int, int); }
|
||||||
|
namespace Engine { FrameBuffer getFrameBuffer(const string&in); }
|
||||||
|
namespace Engine { Environment getMainEnvironment(); }
|
||||||
|
namespace Engine { Environment createEnvironment(); }
|
||||||
|
namespace UI { void setupAutomaticColumns(int); }
|
||||||
|
namespace UI { void setupColumns(int); }
|
||||||
|
namespace UI { void endColumns(); }
|
||||||
|
namespace UI { void nextColumn(); }
|
||||||
|
namespace Resource { int getResourceCount(ResourceType, const string&in); }
|
||||||
|
namespace Resource { string getResourceNameById(ResourceType, const string&in, int); }
|
||||||
|
namespace Resource { string getResourcePathById(ResourceType, const string&in, int); }
|
||||||
|
namespace Resource { int getDirCount(ResourceType, const string&in); }
|
||||||
|
namespace Resource { string getDirPathById(ResourceType, const string&in, int); }
|
||||||
|
namespace Resource { string getDirNameById(ResourceType, const string&in, int); }
|
||||||
|
namespace Engine { void print(const string&in); }
|
||||||
|
namespace UI { void treeNodeLeaf(const string&in, bool); }
|
||||||
|
namespace UI { bool treeNode(const string&in, bool, any@, ReciverFunc@); }
|
||||||
|
namespace UI { bool componentNode(const string&in, any@, ReciverFunc@); }
|
||||||
|
namespace UI { bool componentNode_contextMenu(const string&in, any@, ReciverFunc@, ReciverFunc@); }
|
||||||
|
namespace UI { void contextItemPopup(const string&in, any@, ReciverFunc@); }
|
||||||
|
namespace UI { void contextMenuPopup(const string&in, any@, ReciverFunc@); }
|
||||||
|
namespace UI { void modalPopup(const string&in, ReciverFunc@); }
|
||||||
|
namespace UI { void simplePopup(const string&in, ReciverFunc@); }
|
||||||
|
namespace UI { void openPopup(const string&in, any@); }
|
||||||
|
namespace UI { void closePopup(); }
|
||||||
|
namespace UI { void dragDropSource(const string&in, any@, const string&in); }
|
||||||
|
namespace UI { void dragDropTarget(const string&in, any@, TransferFunc@); }
|
||||||
|
564
roe/Editor/as.predefined_old
Normal file
564
roe/Editor/as.predefined_old
Normal file
@ -0,0 +1,564 @@
|
|||||||
|
|
||||||
|
funcdef void ReciverFunc(any@ value);
|
||||||
|
funcdef void TransferFunc(any@ from, any@ data);
|
||||||
|
|
||||||
|
|
||||||
|
enum key
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
A, B, C, D, E, F, G, H, I, J, K, L, M,
|
||||||
|
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
||||||
|
K0, K1, K2, K3, K4, K5, K6, K7, K8, K9,
|
||||||
|
Tab, Enter, Escape, Backspace, Space, Delete, Insert, Home, End, PageUp, PageDown,
|
||||||
|
Right, Up, Down, Left,
|
||||||
|
RightCtrl, LeftShift, RightShift,
|
||||||
|
LeftAlt, RightAlt, LeftSuper,
|
||||||
|
RightSuper, LeftCtrl,
|
||||||
|
MouseLeft,MouseRight,MouseMiddle
|
||||||
|
};
|
||||||
|
|
||||||
|
//This file was generated automatically
|
||||||
|
enum ResourceType {
|
||||||
|
Mesh = 1,
|
||||||
|
Shader = 2
|
||||||
|
}
|
||||||
|
class string {
|
||||||
|
~string();
|
||||||
|
string();
|
||||||
|
string(const string&in);
|
||||||
|
string& opAssign(const string&in);
|
||||||
|
string& opAddAssign(const string&in);
|
||||||
|
bool opEquals(const string&in) const;
|
||||||
|
int opCmp(const string&in) const;
|
||||||
|
string opAdd(const string&in) const;
|
||||||
|
uint length() const;
|
||||||
|
void resize(uint);
|
||||||
|
bool isEmpty() const;
|
||||||
|
uint8& opIndex(uint);
|
||||||
|
const uint8& opIndex(uint) const;
|
||||||
|
string& opAssign(double);
|
||||||
|
string& opAddAssign(double);
|
||||||
|
string opAdd(double) const;
|
||||||
|
string opAdd_r(double) const;
|
||||||
|
string& opAssign(float);
|
||||||
|
string& opAddAssign(float);
|
||||||
|
string opAdd(float) const;
|
||||||
|
string opAdd_r(float) const;
|
||||||
|
string& opAssign(int64);
|
||||||
|
string& opAddAssign(int64);
|
||||||
|
string opAdd(int64) const;
|
||||||
|
string opAdd_r(int64) const;
|
||||||
|
string& opAssign(uint64);
|
||||||
|
string& opAddAssign(uint64);
|
||||||
|
string opAdd(uint64) const;
|
||||||
|
string opAdd_r(uint64) const;
|
||||||
|
string& opAssign(bool);
|
||||||
|
string& opAddAssign(bool);
|
||||||
|
string opAdd(bool) const;
|
||||||
|
string opAdd_r(bool) const;
|
||||||
|
string substr(uint start = 0, int count = - 1) const;
|
||||||
|
int findFirst(const string&in, uint start = 0) const;
|
||||||
|
int findFirstOf(const string&in, uint start = 0) const;
|
||||||
|
int findFirstNotOf(const string&in, uint start = 0) const;
|
||||||
|
int findLast(const string&in, int start = - 1) const;
|
||||||
|
int findLastOf(const string&in, int start = - 1) const;
|
||||||
|
int findLastNotOf(const string&in, int start = - 1) const;
|
||||||
|
void insert(uint pos, const string&in other);
|
||||||
|
void erase(uint pos, int count = - 1);
|
||||||
|
}
|
||||||
|
class ref {
|
||||||
|
~ref();
|
||||||
|
ref();
|
||||||
|
ref(const ref&in);
|
||||||
|
ref(const ?&in);
|
||||||
|
void opCast(?&out);
|
||||||
|
ref& opHndlAssign(const ref&in);
|
||||||
|
ref& opHndlAssign(const ?&in);
|
||||||
|
bool opEquals(const ref&in) const;
|
||||||
|
bool opEquals(const ?&in) const;
|
||||||
|
}
|
||||||
|
class any {
|
||||||
|
any& opAssign(any&in);
|
||||||
|
any();
|
||||||
|
any(?&in);
|
||||||
|
void store(?&in);
|
||||||
|
void store(const int64&in);
|
||||||
|
void store(const double&in);
|
||||||
|
bool retrieve(?&out);
|
||||||
|
bool retrieve(int64&out);
|
||||||
|
bool retrieve(double&out);
|
||||||
|
}
|
||||||
|
class Entity {
|
||||||
|
// Gets the entity's name
|
||||||
|
string get_name() const property;
|
||||||
|
// Sets the entity's name
|
||||||
|
void set_name(string&in) property;
|
||||||
|
|
||||||
|
// Gets the unique entity ID
|
||||||
|
int get_id() const property;
|
||||||
|
|
||||||
|
// Creates a new child entity with the given name
|
||||||
|
Entity createChild(const string&in);
|
||||||
|
|
||||||
|
// Returns true if this entity is the root entity
|
||||||
|
bool get_isRoot() const property;
|
||||||
|
|
||||||
|
// Destroys this entity
|
||||||
|
void destroy();
|
||||||
|
|
||||||
|
// Returns true if the entity currently exists
|
||||||
|
bool get_exists() const property;
|
||||||
|
|
||||||
|
// Gets the parent entity
|
||||||
|
Entity get_parent() property;
|
||||||
|
// Sets the parent entity
|
||||||
|
void set_parent(Entity) property;
|
||||||
|
|
||||||
|
// Checks if this entity is a descendant of the given entity
|
||||||
|
bool isDescendantOf(Entity);
|
||||||
|
|
||||||
|
// Compares this entity with another entity for equality
|
||||||
|
bool opEquals(const Entity&in) const;
|
||||||
|
|
||||||
|
// Gets the collection of child entities
|
||||||
|
EntityChilds get_childs() const property;
|
||||||
|
|
||||||
|
// Gets the transform component of the entity
|
||||||
|
TransformComponent get_transform() const property;
|
||||||
|
|
||||||
|
// Mesh component methods
|
||||||
|
MeshComponent getMeshComponent();
|
||||||
|
MeshComponent createMeshComponent();
|
||||||
|
bool hasMeshComponent();
|
||||||
|
void removeMeshComponent();
|
||||||
|
|
||||||
|
// Shader component methods
|
||||||
|
ShaderComponent getShaderComponent();
|
||||||
|
ShaderComponent createShaderComponent();
|
||||||
|
bool hasShaderComponent();
|
||||||
|
void removeShaderComponent();
|
||||||
|
|
||||||
|
// Camera component methods
|
||||||
|
CameraComponent getCameraComponent();
|
||||||
|
CameraComponent createCameraComponent();
|
||||||
|
bool hasCameraComponent();
|
||||||
|
void removeCameraComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
class EntityChilds {
|
||||||
|
// Gets the number of child entities
|
||||||
|
int get_count() const property;
|
||||||
|
|
||||||
|
// Access child entity by index
|
||||||
|
Entity opIndex(int) const;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TransformComponent {
|
||||||
|
// Gets/sets position vector
|
||||||
|
vec3 get_position() const property;
|
||||||
|
void set_position(const vec3) property;
|
||||||
|
|
||||||
|
// Gets/sets scale vector
|
||||||
|
vec3 get_scale() const property;
|
||||||
|
void set_scale(const vec3) property;
|
||||||
|
|
||||||
|
// Gets/sets rotation vector (Euler angles)
|
||||||
|
vec3 get_rotation() const property;
|
||||||
|
void set_rotation(const vec3) property;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class MeshComponent {
|
||||||
|
// Is mesh component active?
|
||||||
|
bool get_isActive() const property;
|
||||||
|
void set_isActive(const bool) property;
|
||||||
|
|
||||||
|
// Does this component have a mesh assigned?
|
||||||
|
bool get_hasMesh() const property;
|
||||||
|
|
||||||
|
// Clears the mesh data
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
// Gets/sets mesh identifier
|
||||||
|
string getMesh();
|
||||||
|
void setMesh(string&in);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ShaderComponent {
|
||||||
|
// Does this component have a shader assigned?
|
||||||
|
bool get_hasShader() const property;
|
||||||
|
|
||||||
|
// Clears the shader data
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
// Gets/sets shader identifier
|
||||||
|
string getShader();
|
||||||
|
void setShader(const string&in);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CameraComponent {
|
||||||
|
// Gets/sets field of view
|
||||||
|
float get_fov() const property;
|
||||||
|
void set_fov(float) property;
|
||||||
|
|
||||||
|
// Gets/sets aspect ratio
|
||||||
|
float get_aspectRatio() const property;
|
||||||
|
void set_aspectRatio(float) property;
|
||||||
|
|
||||||
|
// Gets/sets near clipping plane distance
|
||||||
|
float get_nearZ() const property;
|
||||||
|
void set_nearZ(float) property;
|
||||||
|
|
||||||
|
// Gets/sets far clipping plane distance
|
||||||
|
float get_farZ() const property;
|
||||||
|
void set_farZ(float) property;
|
||||||
|
}
|
||||||
|
|
||||||
|
class vec3 {
|
||||||
|
// Default constructor (zero vector)
|
||||||
|
vec3();
|
||||||
|
// Constructor with components (y,z default to 0)
|
||||||
|
vec3(float, float = 0, float = 0);
|
||||||
|
|
||||||
|
// Vector addition
|
||||||
|
vec3 opAdd(const vec3&in);
|
||||||
|
// Vector subtraction
|
||||||
|
vec3 opSub(const vec3&in) const;
|
||||||
|
// Negation
|
||||||
|
vec3 opNeg() const;
|
||||||
|
// Multiply by scalar
|
||||||
|
vec3 opMul(float) const;
|
||||||
|
vec3 opMul_r(float) const;
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
}
|
||||||
|
|
||||||
|
class quat {
|
||||||
|
~quat();
|
||||||
|
quat();
|
||||||
|
quat(const quat&in);
|
||||||
|
quat(float, float, float, float);
|
||||||
|
|
||||||
|
// Quaternion multiplication
|
||||||
|
quat opMul(const quat&in) const;
|
||||||
|
|
||||||
|
// Gets/sets Euler angles representation of the quaternion
|
||||||
|
vec3 getEuler() const;
|
||||||
|
void setEuler(vec3);
|
||||||
|
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float w;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Transform {
|
||||||
|
Transform();
|
||||||
|
|
||||||
|
vec3 position;
|
||||||
|
vec3 scale;
|
||||||
|
quat rotation;
|
||||||
|
|
||||||
|
// Returns a vec3 relative to the transform
|
||||||
|
vec3 relative(vec3);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Camera {
|
||||||
|
~Camera();
|
||||||
|
|
||||||
|
float fov;
|
||||||
|
float aspect;
|
||||||
|
float nearZ;
|
||||||
|
float farZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SceneCamera {
|
||||||
|
~SceneCamera();
|
||||||
|
|
||||||
|
Camera camera;
|
||||||
|
Transform transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FrameBuffer {
|
||||||
|
// Clears the framebuffer with RGBA color
|
||||||
|
void clearRGBA(int, int, int, int);
|
||||||
|
// Gets the height of the framebuffer
|
||||||
|
int get_height() const property;
|
||||||
|
// Resizes the framebuffer
|
||||||
|
void resize(int, int);
|
||||||
|
// Gets the framebuffer's name
|
||||||
|
string get_name() const property;
|
||||||
|
bool isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Environment {
|
||||||
|
// Renders the scene with the given camera and framebuffer target
|
||||||
|
void render(FrameBuffer, SceneCamera);
|
||||||
|
// Gets the root entity of the environment
|
||||||
|
Entity getRootEntity();
|
||||||
|
// Gets an entity by its ID
|
||||||
|
Entity getEntity(int);
|
||||||
|
}
|
||||||
|
|
||||||
|
class DockPanel {
|
||||||
|
// Called to render the dock panel UI
|
||||||
|
void onRender();
|
||||||
|
void onInit();
|
||||||
|
void onMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Format a signed 64-bit integer to string with optional formatting and width
|
||||||
|
string formatInt(int64 val, const string& in options = "", uint width = 0);
|
||||||
|
// Format an unsigned 64-bit integer to string with optional formatting and width
|
||||||
|
string formatUInt(uint64 val, const string& in options = "", uint width = 0);
|
||||||
|
// Format a double-precision float to string with options, width, and precision
|
||||||
|
string formatFloat(double val, const string& in options = "", uint width = 0, uint precision = 0);
|
||||||
|
|
||||||
|
// Parse a signed 64-bit integer from string with base, returning byte count parsed
|
||||||
|
int64 parseInt(const string& in str, uint base = 10, uint& out byteCount = 0);
|
||||||
|
// Parse an unsigned 64-bit integer from string with base, returning byte count parsed
|
||||||
|
uint64 parseUInt(const string& in str, uint base = 10, uint& out byteCount = 0);
|
||||||
|
// Parse a double-precision float from string, returning byte count parsed
|
||||||
|
double parseFloat(const string& in str, uint& out byteCount = 0);
|
||||||
|
|
||||||
|
namespace Engine {
|
||||||
|
// Print a message to the engine's console or log
|
||||||
|
void print(const string& in message);
|
||||||
|
// Retrieve the root entity of the scene or hierarchy
|
||||||
|
Entity getRoot();
|
||||||
|
// Create an RGBA8 framebuffer with a name and size
|
||||||
|
FrameBuffer createRGBA8FrameBuffer(const string& in name, int width, int height);
|
||||||
|
// Retrieve an existing framebuffer by name
|
||||||
|
FrameBuffer getFrameBuffer(const string& in name);
|
||||||
|
|
||||||
|
// Get the main environment instance
|
||||||
|
Environment getMainEnvironment();
|
||||||
|
// Create a new environment
|
||||||
|
Environment createEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Resource {
|
||||||
|
// Get the number of resources of a given type and category
|
||||||
|
int getResourceCount(ResourceType type, const string& in category);
|
||||||
|
// Get the name of a resource by type, category, and resource ID
|
||||||
|
string getResourceNameById(ResourceType type, const string& in category, int id);
|
||||||
|
// Get the file path of a resource by type, category, and resource ID
|
||||||
|
string getResourcePathById(ResourceType type, const string& in category, int id);
|
||||||
|
|
||||||
|
// Get the number of directories of a given resource type and category
|
||||||
|
int getDirCount(ResourceType type, const string& in category);
|
||||||
|
// Get the path of a directory by resource type, category, and directory ID
|
||||||
|
string getDirPathById(ResourceType type, const string& in category, int id);
|
||||||
|
// Get the name of a directory by resource type, category, and directory ID
|
||||||
|
string getDirNameById(ResourceType type, const string& in category, int id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace UI {
|
||||||
|
// Columns
|
||||||
|
|
||||||
|
// Setup automatic columns with given count
|
||||||
|
void setupAutomaticColumns(int count);
|
||||||
|
// Setup fixed columns count
|
||||||
|
void setupColumns(int count);
|
||||||
|
// End columns layout
|
||||||
|
void endColumns();
|
||||||
|
// Move to next column
|
||||||
|
void nextColumn();
|
||||||
|
|
||||||
|
// Tree nodes
|
||||||
|
|
||||||
|
// Draw leaf node with label and open state
|
||||||
|
void treeNodeLeaf(const string& in label, bool open);
|
||||||
|
// Draw tree node with label, open state, data, and callback
|
||||||
|
bool treeNode(const string& in label, bool open, any@ data, ReciverFunc@ cb);
|
||||||
|
// Draw component node with label, data, and callback
|
||||||
|
bool componentNode(const string& in label, any@ data, ReciverFunc@ cb);
|
||||||
|
// Draw component node with context menu support
|
||||||
|
bool componentNode_contextMenu(const string& in label, any@ data, ReciverFunc@ cb, ReciverFunc@ ctxMenu);
|
||||||
|
|
||||||
|
// Popups & Context menus
|
||||||
|
|
||||||
|
// Show a context menu popup with callback
|
||||||
|
void contextMenuPopup(const string& in label, any@ data, ReciverFunc@ cb);
|
||||||
|
// Popup attached to an item with label, data, and callback
|
||||||
|
void contextItemPopup(const string& in label, any@ data, ReciverFunc@ cb);
|
||||||
|
// Show a modal popup blocking interaction until closed
|
||||||
|
void modalPopup(const string& in label, ReciverFunc@ cb);
|
||||||
|
// Show a simple popup window with callback
|
||||||
|
void simplePopup(const string& in label, ReciverFunc@ cb);
|
||||||
|
// Open a popup with label and associated data
|
||||||
|
void openPopup(const string& in label, any@ data);
|
||||||
|
// Close the currently opened popup
|
||||||
|
void closePopup();
|
||||||
|
|
||||||
|
// Drag & Drop
|
||||||
|
|
||||||
|
// Start a drag-drop source with type, data, and payload string
|
||||||
|
void dragDropSource(const string& in type, any@ data, const string& in payload);
|
||||||
|
// Define a drag-drop target with type, data, and transfer callback
|
||||||
|
void dragDropTarget(const string& in type, any@ data, TransferFunc@ transfer);
|
||||||
|
|
||||||
|
// Buttons & Controls
|
||||||
|
|
||||||
|
// Create a clickable button with label
|
||||||
|
bool button(const string& in label);
|
||||||
|
// Create a centered button
|
||||||
|
bool buttonCenter(const string& in label);
|
||||||
|
// Create a button aligned to the end of the line
|
||||||
|
bool buttonEnd(const string& in label);
|
||||||
|
// Checkbox toggle with label and current value
|
||||||
|
bool checkbox(const string& in label, bool val);
|
||||||
|
// Disabled checkbox with label and current value
|
||||||
|
bool checkboxDisabled(const string& in label, bool val);
|
||||||
|
|
||||||
|
// Drawing
|
||||||
|
|
||||||
|
// Draw a framebuffer with given width and height
|
||||||
|
void drawFrameBuffer(FrameBuffer fb, int w, int h);
|
||||||
|
// Draw a framebuffer centered with given dimensions
|
||||||
|
void drawFrameBufferCentered(FrameBuffer fb, int w, int h);
|
||||||
|
// Draw an icon with name and size
|
||||||
|
void drawIcon(const string& in icon, int size);
|
||||||
|
// Draw a centered icon with name and size
|
||||||
|
void drawIconCentered(const string& in icon, int size);
|
||||||
|
|
||||||
|
// Input & Interaction
|
||||||
|
|
||||||
|
// Text input field with label, initial value, and output string
|
||||||
|
bool inputText(const string& in label, const string& in initial, string& out result);
|
||||||
|
// Check if an item was clicked with specific mouse button
|
||||||
|
bool isItemClicked(int button);
|
||||||
|
// Check if mouse was double-clicked with specific button
|
||||||
|
bool isMouseDoubleClicked(int button);
|
||||||
|
|
||||||
|
// Sliders
|
||||||
|
|
||||||
|
// Slider for a float value with step increment
|
||||||
|
float magicSlider(const string& in label, float val, float step);
|
||||||
|
// Slider for a vec3 value with step increment
|
||||||
|
vec3 magicSlider3(const string& in label, vec3 val, float step);
|
||||||
|
|
||||||
|
// Menu Items
|
||||||
|
|
||||||
|
// Selectable menu item with label
|
||||||
|
bool menuItem(const string& in label);
|
||||||
|
// Disabled (non-selectable) menu item with label
|
||||||
|
void menuItemDisabled(const string& in label);
|
||||||
|
// Menu space with label, data, and callback
|
||||||
|
void menuSpace(const string& in label, any@ data, ReciverFunc@ cb);
|
||||||
|
|
||||||
|
// Layout
|
||||||
|
|
||||||
|
// Place next UI element on the same line
|
||||||
|
void sameline();
|
||||||
|
// Draw a horizontal separator line
|
||||||
|
void separator();
|
||||||
|
// Add vertical space
|
||||||
|
void space();
|
||||||
|
// Add multiple vertical spaces with optional spacing
|
||||||
|
void space(int count, int spacing=10);
|
||||||
|
|
||||||
|
// Text
|
||||||
|
|
||||||
|
// Draw normal text
|
||||||
|
void text(const string& in txt);
|
||||||
|
// Draw centered text
|
||||||
|
void textCenter(const string& in txt);
|
||||||
|
// Draw colored text with RGB and string
|
||||||
|
void textColor(float r, float g, float b, const string& in txt);
|
||||||
|
// Draw text aligned to end
|
||||||
|
void textEnd(const string& in txt);
|
||||||
|
|
||||||
|
// Titles
|
||||||
|
|
||||||
|
// Draw a title text
|
||||||
|
void title(const string& in txt);
|
||||||
|
// Draw a centered title
|
||||||
|
void titleCenter(const string& in txt);
|
||||||
|
// Draw a vertically offset centered title
|
||||||
|
void titleCenterY(const string& in txt, int yOffset);
|
||||||
|
// Draw a title aligned to the end
|
||||||
|
void titleEnd(const string& in txt);
|
||||||
|
|
||||||
|
bool isPannelActive();
|
||||||
|
|
||||||
|
bool isKeyDown(key);
|
||||||
|
bool isKeyPressed(key);
|
||||||
|
|
||||||
|
bool isMouseDraggin(key);
|
||||||
|
float getMouseDragDeltaX();
|
||||||
|
float getMouseDragDeltaY();
|
||||||
|
float getMouseDeltaX();
|
||||||
|
float getMouseDeltaY();
|
||||||
|
int getAvailableSizeX();
|
||||||
|
int getAvailableSizeY();
|
||||||
|
void disablePannelPadding(bool);
|
||||||
|
|
||||||
|
int sliderInt(string&in, int value, int min, int max);
|
||||||
|
float slider(string&in, float value, float min, float max);
|
||||||
|
}
|
||||||
|
|
||||||
|
class array<T> {
|
||||||
|
T& opIndex(uint index);
|
||||||
|
const T& opIndex(uint index) const;
|
||||||
|
T[]& opAssign(const T[]&in);
|
||||||
|
void insertAt(uint index, const T&in value);
|
||||||
|
void insertAt(uint index, const T[]&inout arr);
|
||||||
|
void insertLast(const T&in value);
|
||||||
|
void removeAt(uint index);
|
||||||
|
void removeLast();
|
||||||
|
void removeRange(uint start, uint count);
|
||||||
|
uint length() const;
|
||||||
|
void reserve(uint length);
|
||||||
|
void resize(uint length);
|
||||||
|
void sortAsc();
|
||||||
|
void sortAsc(uint startAt, uint count);
|
||||||
|
void sortDesc();
|
||||||
|
void sortDesc(uint startAt, uint count);
|
||||||
|
void reverse();
|
||||||
|
int find(const T&in value) const;
|
||||||
|
int find(uint startAt, const T&in value) const;
|
||||||
|
int findByRef(const T&in value) const;
|
||||||
|
int findByRef(uint startAt, const T&in value) const;
|
||||||
|
bool opEquals(const T[]&in) const;
|
||||||
|
bool isEmpty() const;
|
||||||
|
//void sort(T[]::less&in, uint startAt = 0, uint count = uint ( - 1 ));
|
||||||
|
funcdef bool less(const T&in, const T&in);
|
||||||
|
}
|
||||||
|
|
||||||
|
class dictionaryValue {
|
||||||
|
~dictionaryValue();
|
||||||
|
dictionaryValue();
|
||||||
|
dictionaryValue& opAssign(const dictionaryValue&in);
|
||||||
|
dictionaryValue& opHndlAssign(const ?&in);
|
||||||
|
dictionaryValue& opHndlAssign(const dictionaryValue&in);
|
||||||
|
dictionaryValue& opAssign(const ?&in);
|
||||||
|
dictionaryValue& opAssign(double);
|
||||||
|
dictionaryValue& opAssign(int64);
|
||||||
|
void opCast(?&out);
|
||||||
|
void opConv(?&out);
|
||||||
|
int64 opConv();
|
||||||
|
double opConv();
|
||||||
|
}
|
||||||
|
class dictionary {
|
||||||
|
dictionary& opAssign(const dictionary&in);
|
||||||
|
void set(const string&in, const ?&in);
|
||||||
|
bool get(const string&in, ?&out) const;
|
||||||
|
void set(const string&in, const int64&in);
|
||||||
|
bool get(const string&in, int64&out) const;
|
||||||
|
void set(const string&in, const double&in);
|
||||||
|
bool get(const string&in, double&out) const;
|
||||||
|
bool exists(const string&in) const;
|
||||||
|
bool isEmpty() const;
|
||||||
|
uint getSize() const;
|
||||||
|
bool delete(const string&in);
|
||||||
|
void deleteAll();
|
||||||
|
string[]@ getKeys() const;
|
||||||
|
dictionaryValue& opIndex(const string&in);
|
||||||
|
const dictionaryValue& opIndex(const string&in) const;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user