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;








0















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.










share|improve this question






























    0















    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.










    share|improve this question


























      0












      0








      0








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 6:10







      dragon-kurve

















      asked Mar 8 at 5:58









      dragon-kurvedragon-kurve

      285




      285






















          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
          );



          );













          draft saved

          draft discarded


















          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















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved