コード例 #1
0
    void EnqueNeighbor(Matrix4x4 fromSpace, Vector3 neighOffset)
    {
        var pnt = fromSpace.MultiplyPoint(neighOffset);
        //Debug.DrawLine (fromSpace.MultiplyPoint (Vector3.zero), pnt, Color.red);
        var curStepSize = this.StepSize;

        if (this.ScaleFromStartIntensity)
        {
            float pntIntensity = Controller.MagneticField(this.transform.position).magnitude;
            curStepSize = (this.StepSize * (StartingPointIntensity / pntIntensity));
        }
        Matrix4x4 mat;

        this.Controller.MagneticFieldLocalSpaceX(pnt, out mat, true, curStepSize);
        NextPoints.Enqueue(mat);
    }
コード例 #2
0
    void FixedUpdate()
    {
        // Accelerate the particles under the action of the electric and magnetic fields by replacing the velocities.

        int numParticles = theParticleSystem.GetParticles(particles);

        for (int i = 0; i < numParticles; i++)
        {
            Vector3 E = controller.ElectricField(particles[i].position);
            Vector3 B = controller.MagneticField(particles[i].position);
            particles[i].velocity += chargeOverMass * (E + Vector3.Cross(particles[i].velocity, B));
        }
        theParticleSystem.SetParticles(particles, numParticles);
    }