Beispiel #1
0
	void updateParticle(ParticleManager& sourceManager, int sourceId, ParticleManager& destinationManager, int destinationId) {
		destinationManager.getParticleMass(destinationId) = sourceManager.getParticleMass(sourceId);
		destinationManager.getParticlePosition(destinationId) = sourceManager.getParticlePosition(sourceId);
		destinationManager.getParticleVelocity(destinationId) = sourceManager.getParticleVelocity(sourceId);
		destinationManager.getParticleForce(destinationId) = sourceManager.getParticleForce(sourceId);
		destinationManager.getParticleColor(destinationId) = sourceManager.getParticleColor(sourceId);
	}
Beispiel #2
0
	// Copy a particle
	int copyParticle(ParticleManager& sourceManager, ParticleManager& destinationManager, int id) {
		int newId = destinationManager.addParticle(sourceManager.getParticleMass(id),
                            sourceManager.getParticlePosition(id),           
                            sourceManager.getParticleVelocity(id),
                            sourceManager.getParticleForce(id),
                            sourceManager.getParticleColor(id));

		return newId;
	}
Beispiel #3
0
	// Add a particle to the Snake
	void addParticletoSnake(ParticleGraph& graph, int id, ParticleManager& foodManager, ParticleManager& snakeManager) {

	    id = snakeManager.addParticleToHead(foodManager.getParticleMass(id), 
	                                    foodManager.getParticlePosition(id),
	                                    foodManager.getParticleVelocity(id),
	                                    foodManager.getParticleForce(id),
	                                    snakeManager.getHeadColor());

	    foodManager.clear();

	    std::pair<unsigned int, unsigned int> pair (id, snakeManager.getCount() - 2);
	    graph.push_back(pair);
	    snakeManager.getParticleColor(1) = snakeManager.getParticleColor(2);

	}