/// <summary> /// This function adds (if necessary) a particle to the physics engine as a representation of the node passed in argument /// </summary> /// <param name="x">the x coordinate</param> /// <param name="y">the y coordinate</param> /// <param name="z">the z coordinate</param> /// <param name="node">the node you want to represent in the physics engine</param> /// <param name="model">the model manager. It's used to create interactions</param> public void AddPhysicRepresentation(float x, float y, float z, model.Node node, model.ModelManager model) { // if the node already exists and already has a physic representation then don't do anything, go back to where you come from. if (node.PhysicRepresentation != null) { return; } // else we create a physic representation Particle particle = this.particleSystem.MakeParticle(x, y, z); // create some space between the nodes foreach (model.Node otherNode in model.NodeList) { if (otherNode.PhysicRepresentation != null) { physics.Attraction repulsion = this.particleSystem.MakeAttraction( otherNode.PhysicRepresentation, particle, -1 * this.settings.RepultionForce, PhysicsConstants.AttractionEffectMinimalDistance); node.SetRepulsion(otherNode, repulsion); otherNode.SetRepulsion(node, repulsion); } } // finally set the particle node.PhysicRepresentation = particle; }