Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: particle system inheritance  (Read 873 times)

0 Members and 1 Guest are viewing this topic.

Tojmak

  • Newbie
  • *
  • Posts: 4
    • View Profile
particle system inheritance
« on: May 03, 2020, 12:44:49 pm »
Hi, i'm creating particle system and i want to have possibility to choose what kind of object will be showing on the screen (like just points from primitive types or circle shapes). I have one class in which all parameters are stored (ParticleSettings), but without those entities like points, or circle shapes. I thought that i may create pure virtual class (ParticlesInterface) as a base class, and its derived classes like ParticlesVertex, or ParticlesCircles for storing those drawable objects. It is something like that:

class ParticlesInterface
{
protected:
        std::vector<ParticleSettings>   m_particleAttributes;  

public:
        ParticlesInterface(long int amount = 100, sf::Vector2f position = { 0.0,0.0 });
        const std::vector<ParticleSettings>& getParticleAttributes() { return m_particleAttributes; }
...
}
 

and :
class ParticlesVertex : public ParticlesInterface
{
private:                                                       
        std::vector<sf::Vertex>                 m_particleVertex;
public:
        ParticlesVertex(long int amount = 100, sf::Vector2f position = { 0.0,0.0 });
        std::vector<sf::Vertex>& getParticleVertex() { return m_particleVertex; }
...
}
 

So... I know that i do not have access to getParticleVertex() method by using polimorphism. And I really want to have that access. I want to ask if there is any better solution for that. I have really bad times with decide how to connect all that together. I mean i was thinking also about using template classes, and different types of relations. I thought that this idea will be okay, but i'm really need to have access to that method in that option. Can you please help me how it should be done? I want to know what is the best approach here, and also if there is any good answer to that problem i have if i decide to make that this way that i show you above.

 

anything