Entity Component System - MeshRenderSystem or just MeshRenderer?How to make plugable factory work with lua?Failed to specialize function templateTemplates and runtime component loading in a component-based game engineEntity System in C++std::set.insert won't compile with custom classC++: Best Way To Hold Entity List vector vs setInvalid operands to binary expression ('const' and 'const' )Handling ECS componentsMatrix Template Class passing parameter by const referenceHow to create this generic data structure field for my Vulkan class?
A Journey Through Space and Time
Are tax years 2016 & 2017 back taxes deductible for tax year 2018?
How can I fix this gap between bookcases I made?
Can a German sentence have two subjects?
What makes Graph invariants so useful/important?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
Can I make popcorn with any corn?
How is this relation reflexive?
Simulate Bitwise Cyclic Tag
Extreme, but not acceptable situation and I can't start the work tomorrow morning
whey we use polarized capacitor?
What Brexit solution does the DUP want?
Copycat chess is back
I see my dog run
What is the command to reset a PC without deleting any files
TGV timetables / schedules?
Motorized valve interfering with button?
What would the Romans have called "sorcery"?
What do you call a Matrix-like slowdown and camera movement effect?
How can bays and straits be determined in a procedurally generated map?
Prevent a directory in /tmp from being deleted
Can I interfere when another PC is about to be attacked?
Is it possible to make sharp wind that can cut stuff from afar?
Why was the small council so happy for Tyrion to become the Master of Coin?
Entity Component System - MeshRenderSystem or just MeshRenderer?
How to make plugable factory work with lua?Failed to specialize function templateTemplates and runtime component loading in a component-based game engineEntity System in C++std::set.insert won't compile with custom classC++: Best Way To Hold Entity List vector vs setInvalid operands to binary expression ('const' and 'const' )Handling ECS componentsMatrix Template Class passing parameter by const referenceHow to create this generic data structure field for my Vulkan class?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
First of all, let me describe my terms/implementations.
Component contains just data about something. e.g.
class TransformComponent : public Component<TransformComponent> /*CRTP*/
public:
/*...*/
private:
Transform mTransform;
Also, component can have some handy functions about itself if needed.
Entity is a container of components and responsible of its creation/deletion of the component.
class Entity
public:
template <typename T, typename ...Args>
bool attach(Args ... args);
template <typename T>
bool detach();
template <typename T>
T* get();
/*...*/
private:
ComponentTypeBit mComponentBit;
std::unordered_map<ComponentTypeBit, ComponentIsh> mComponentMap;
System manipulates component(s) of an entity. A system can be interested in one or more component types. Entity can be registered to a system. If an entity has all components that required by a system, then system stores the pointer of entity.
template<typename ... Args>
class System
public:
/*...*/
void registerEntity(Entity& entity);
void deregisterEntity(Entity& entity);
const std::vector<Entity*>& getEntities() const;
/*...*/
private:
ComponentTypeBit mComponentBit;
std::vector<Entity*> mEntities;
class HierarchySystem : public System<HierarchyComponent, TransformComponent>
/*If a entity has HierarchyComponent and TransformComponent,
address of the entity adds to mEntities*/
The question is, well, not just about render class itself.
If I want to render an arbitary (static)mesh, I need view matrix and projection matrix from camera. My confusion started from here.
At first glance, I though mesh renderer can be defined like this:
class MeshRenderSystem : public System<TransformComponent, MeshComponent, MaterialComponent>
/*currently, MaterialComponent holds reference to fragment shader*/
So I can set model matrix uniform and vertex attributes, material uniforms.
But where should I put view and projection matrix? What about draw call?
Idea 1: class Scene
that holds list of entities and camera(s).
Possible issue: The camera is not an entity. That means I need something like CameraTargetComponent
. But to update that component, a system should reference to Scene
Idea 2: CameraComponent
that represents the camera. Thus camera can have parent or children by HierarchyComponent
.
Possible issue: If camera is an entity, where should I store view and projection matrix to render(because my systems don't have event queue or vice versa)? Do I need something like Scene
again?
Idea 3: SceneManager
that has SystemProvider
and EntityProvider
. And If an entity created by EntityProvider
and registered to current scene of SceneManager
then also registered to to system. SceneManager
hold camera(s) and renderers.
c++ rendering entity-component-system
add a comment |
First of all, let me describe my terms/implementations.
Component contains just data about something. e.g.
class TransformComponent : public Component<TransformComponent> /*CRTP*/
public:
/*...*/
private:
Transform mTransform;
Also, component can have some handy functions about itself if needed.
Entity is a container of components and responsible of its creation/deletion of the component.
class Entity
public:
template <typename T, typename ...Args>
bool attach(Args ... args);
template <typename T>
bool detach();
template <typename T>
T* get();
/*...*/
private:
ComponentTypeBit mComponentBit;
std::unordered_map<ComponentTypeBit, ComponentIsh> mComponentMap;
System manipulates component(s) of an entity. A system can be interested in one or more component types. Entity can be registered to a system. If an entity has all components that required by a system, then system stores the pointer of entity.
template<typename ... Args>
class System
public:
/*...*/
void registerEntity(Entity& entity);
void deregisterEntity(Entity& entity);
const std::vector<Entity*>& getEntities() const;
/*...*/
private:
ComponentTypeBit mComponentBit;
std::vector<Entity*> mEntities;
class HierarchySystem : public System<HierarchyComponent, TransformComponent>
/*If a entity has HierarchyComponent and TransformComponent,
address of the entity adds to mEntities*/
The question is, well, not just about render class itself.
If I want to render an arbitary (static)mesh, I need view matrix and projection matrix from camera. My confusion started from here.
At first glance, I though mesh renderer can be defined like this:
class MeshRenderSystem : public System<TransformComponent, MeshComponent, MaterialComponent>
/*currently, MaterialComponent holds reference to fragment shader*/
So I can set model matrix uniform and vertex attributes, material uniforms.
But where should I put view and projection matrix? What about draw call?
Idea 1: class Scene
that holds list of entities and camera(s).
Possible issue: The camera is not an entity. That means I need something like CameraTargetComponent
. But to update that component, a system should reference to Scene
Idea 2: CameraComponent
that represents the camera. Thus camera can have parent or children by HierarchyComponent
.
Possible issue: If camera is an entity, where should I store view and projection matrix to render(because my systems don't have event queue or vice versa)? Do I need something like Scene
again?
Idea 3: SceneManager
that has SystemProvider
and EntityProvider
. And If an entity created by EntityProvider
and registered to current scene of SceneManager
then also registered to to system. SceneManager
hold camera(s) and renderers.
c++ rendering entity-component-system
add a comment |
First of all, let me describe my terms/implementations.
Component contains just data about something. e.g.
class TransformComponent : public Component<TransformComponent> /*CRTP*/
public:
/*...*/
private:
Transform mTransform;
Also, component can have some handy functions about itself if needed.
Entity is a container of components and responsible of its creation/deletion of the component.
class Entity
public:
template <typename T, typename ...Args>
bool attach(Args ... args);
template <typename T>
bool detach();
template <typename T>
T* get();
/*...*/
private:
ComponentTypeBit mComponentBit;
std::unordered_map<ComponentTypeBit, ComponentIsh> mComponentMap;
System manipulates component(s) of an entity. A system can be interested in one or more component types. Entity can be registered to a system. If an entity has all components that required by a system, then system stores the pointer of entity.
template<typename ... Args>
class System
public:
/*...*/
void registerEntity(Entity& entity);
void deregisterEntity(Entity& entity);
const std::vector<Entity*>& getEntities() const;
/*...*/
private:
ComponentTypeBit mComponentBit;
std::vector<Entity*> mEntities;
class HierarchySystem : public System<HierarchyComponent, TransformComponent>
/*If a entity has HierarchyComponent and TransformComponent,
address of the entity adds to mEntities*/
The question is, well, not just about render class itself.
If I want to render an arbitary (static)mesh, I need view matrix and projection matrix from camera. My confusion started from here.
At first glance, I though mesh renderer can be defined like this:
class MeshRenderSystem : public System<TransformComponent, MeshComponent, MaterialComponent>
/*currently, MaterialComponent holds reference to fragment shader*/
So I can set model matrix uniform and vertex attributes, material uniforms.
But where should I put view and projection matrix? What about draw call?
Idea 1: class Scene
that holds list of entities and camera(s).
Possible issue: The camera is not an entity. That means I need something like CameraTargetComponent
. But to update that component, a system should reference to Scene
Idea 2: CameraComponent
that represents the camera. Thus camera can have parent or children by HierarchyComponent
.
Possible issue: If camera is an entity, where should I store view and projection matrix to render(because my systems don't have event queue or vice versa)? Do I need something like Scene
again?
Idea 3: SceneManager
that has SystemProvider
and EntityProvider
. And If an entity created by EntityProvider
and registered to current scene of SceneManager
then also registered to to system. SceneManager
hold camera(s) and renderers.
c++ rendering entity-component-system
First of all, let me describe my terms/implementations.
Component contains just data about something. e.g.
class TransformComponent : public Component<TransformComponent> /*CRTP*/
public:
/*...*/
private:
Transform mTransform;
Also, component can have some handy functions about itself if needed.
Entity is a container of components and responsible of its creation/deletion of the component.
class Entity
public:
template <typename T, typename ...Args>
bool attach(Args ... args);
template <typename T>
bool detach();
template <typename T>
T* get();
/*...*/
private:
ComponentTypeBit mComponentBit;
std::unordered_map<ComponentTypeBit, ComponentIsh> mComponentMap;
System manipulates component(s) of an entity. A system can be interested in one or more component types. Entity can be registered to a system. If an entity has all components that required by a system, then system stores the pointer of entity.
template<typename ... Args>
class System
public:
/*...*/
void registerEntity(Entity& entity);
void deregisterEntity(Entity& entity);
const std::vector<Entity*>& getEntities() const;
/*...*/
private:
ComponentTypeBit mComponentBit;
std::vector<Entity*> mEntities;
class HierarchySystem : public System<HierarchyComponent, TransformComponent>
/*If a entity has HierarchyComponent and TransformComponent,
address of the entity adds to mEntities*/
The question is, well, not just about render class itself.
If I want to render an arbitary (static)mesh, I need view matrix and projection matrix from camera. My confusion started from here.
At first glance, I though mesh renderer can be defined like this:
class MeshRenderSystem : public System<TransformComponent, MeshComponent, MaterialComponent>
/*currently, MaterialComponent holds reference to fragment shader*/
So I can set model matrix uniform and vertex attributes, material uniforms.
But where should I put view and projection matrix? What about draw call?
Idea 1: class Scene
that holds list of entities and camera(s).
Possible issue: The camera is not an entity. That means I need something like CameraTargetComponent
. But to update that component, a system should reference to Scene
Idea 2: CameraComponent
that represents the camera. Thus camera can have parent or children by HierarchyComponent
.
Possible issue: If camera is an entity, where should I store view and projection matrix to render(because my systems don't have event queue or vice versa)? Do I need something like Scene
again?
Idea 3: SceneManager
that has SystemProvider
and EntityProvider
. And If an entity created by EntityProvider
and registered to current scene of SceneManager
then also registered to to system. SceneManager
hold camera(s) and renderers.
c++ rendering entity-component-system
c++ rendering entity-component-system
edited Mar 8 at 6:10
dragon-kurve
asked Mar 8 at 5:58
dragon-kurvedragon-kurve
285
285
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057525%2fentity-component-system-meshrendersystem-or-just-meshrenderer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057525%2fentity-component-system-meshrendersystem-or-just-meshrenderer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown