To use the developed swarm simulation system, we need to render individual boids. Since we already have an OpenGL 3D scene graph rendering system, we represent each boid with a triangular mesh and create scene nodes for them. Let's do this:
class clSwarmRenderer { private:
A single clSceneNode
object in the m_Root
field serves as the root scene node of the entire swarm:
clPtr<clSceneNode> m_Root;
A pointer to the clSwarm
object is kept to synchronize boid positions and angles with scene node transformations:
clPtr<clSwarm> m_Swarm;
Scene nodes for each boid are stored in the m_Boids
vector:
std::vector< clPtr<clSceneNode> > m_Boids;
The constructor of the class creates a scene node for each boid in the swarm:
public: explicit clSwarmRenderer( const clPtr<clSwarm> Swarm ) : m_Root( make_intrusive<clSceneNode>() ) , m_Swarm( Swarm ) { m_Boids.reserve( Swarm->m_Boids.size() ); const float Size = 0.05f; for ( const auto...