Initial commit - restart from existing code

This commit is contained in:
Tom Ray
2026-02-13 19:15:05 +01:00
parent 11df621bb2
commit 7c352bc280
1906 changed files with 491226 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
#include "CScene.hpp"
#include "nlohmann/json_fwd.hpp"
#include "../Component/Graphics/CTestRenderer.hpp"
//#include "../../Controller/Exception/CRuntimeException.hpp"
//#include "Components/CAbstractScript.hpp"
namespace CosmicCore {
CScene::CScene(std::string name) : CSerializable(),
m_name(std::move(name)) {
}
std::string CScene::getName(void) const {
return m_name;
}
unsigned int CScene::getNumEntity(void) const {
return this->m_ecManager.view<CMetaData>()->size();
}
void CScene::removeEntity(unsigned int index, bool destroy)
{
}
void CScene::render(){
auto renderers = m_ecManager.view<CTestRenderer>();
for(auto beg = renderers->begin(); beg != renderers->end(); ++beg)
{
beg->render();
}
//std::chrono::steady_clock::time_point begin1 = std::chrono::steady_clock::now();
//auto eh = m_ecManager.create();
//m_ecManager.emplace<CTestRenderer>(eh, nullptr);
//std::chrono::steady_clock::time_point end1 = std::chrono::steady_clock::now();
//std::cout << "added entity and comptest : " <<std::chrono::duration_cast<std::chrono::seconds>(end1 - begin1).count() << std::endl;
//static unsigned int entitynb = 0;
//entitynb++;
//std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
//m_ecManager.view<CTestRenderer>().each([](auto e, CTestRenderer& comp){comp.render();});
//std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
//std::cout << "render func : " << std::chrono::duration_cast<std::chrono::seconds>(end - begin).count() << std::endl;
//std::cout << "nb : " << entitynb << std::endl;
}
// void CScene::setMask(unsigned int mask)
// {
// m_maskLayer = mask;
// }
// unsigned int CScene::getMask(void)
// {
// return m_maskLayer;
// }
nlohmann::json CScene::to_json()
{
return nlohmann::json();
}
}

View File

@@ -0,0 +1,93 @@
#ifndef CSCENE_HPP
#define CSCENE_HPP
#include "../Component/Geometry/CTransform.hpp"
#include "../Component/Meta/CMetaData.hpp"
#include <entt/entt.hpp>
#include <string>
namespace CosmicCore {;
class CScene : public CSerializable {
using ECManager = entt::registry;
private:
// The name of the scene.
std::string m_name;
ECManager m_ecManager;
public:
CScene() = delete;
CScene(std::string name);
~CScene() = default;
unsigned int getNumEntity() const;
CEntity addEntity(std::string name, std::string description){
auto handle = m_ecManager.create();
CEntity handler(m_ecManager, handle);
m_ecManager.emplace<CTransform>(handle, handler);
m_ecManager.emplace<CMetaData>(handle, handler, std::move(name), std::move(description));
return handler;
}
std::string getName() const;
void removeEntity(unsigned int index, bool destroy = true);
//CEntity* getActiveCamera();
//void setActiveCamera(CEntity* newCamera);
/**
* @brief Getter to the light.
* @return The pointer m_mainLight.
*/
//CEntity* getMainLight();
/**
* @brief Setter of the light.
* @param light : The light to set as main light.
*/
//void setMainLight(CEntity* light);
/**
* @brief Setter of the ODE world handling class.
* @param[in, out] world The pointer to the physical world.
*/
//void setTangibleWorld(CTangibleWorld* world);
/**
* @brief Getter to the physical world of the environment.
* @return The pointer m_tangibleWorld.
*/
//std::weak_ptr<CAbstractTangibleWorld> getTangibleWorld();
/**
* @brief Setter of the layer mask.
* @param[in] mask The new mask value.
*/
void setMask(unsigned int mask);
/**
* @brief Getter to the layer mask.
* @return The value of m_maskLayer.
*/
//unsigned int getMask();
void render();
//void updateScript();
nlohmann::json to_json();
/*static CScene* from_json(nlohmann::json& j)
{
CScene* s = new CScene(j["Name"]);
for (nlohmann::json& entity : j["Entities"])
{
CEntity* e = CEntity::from_json(s, entity);
s->addEntity(e);
}
return s;
};*/
};
}
#endif