예제 #1
0
    public List <ScatterPhoton> Emit(float duration)
    {
        List <ScatterPhoton> ret = new List <ScatterPhoton>();

        // Debug.LogFormat("Emitting energy {0}",energy);
        for (int i = 0; i < energy; i++)
        {
            Vector3 emitPos = location + radius * TrailmeshMaker.onUnitSphere();
            Vector3 perp    = new Vector3(-directionPreference.y, directionPreference.x, 0);
            if (directionPreference.z > 0.9)
            {
                perp = new Vector3(0, directionPreference.z, -directionPreference.y);
            }
            Quaternion rt = Quaternion.AngleAxis((float)RandomGen3.NextDouble() * 360, directionPreference);
            perp = (rt * perp).normalized;
            float         angl = Mathf.PI * (1 - directionBias) * (float)RandomGen3.NextDouble();
            Vector3       dir  = (directionPreference * Mathf.Cos(angl) + perp * Mathf.Sin(angl)).normalized;
            ScatterPhoton pht  = new ScatterPhoton();
            // Debug.LogFormat("Derection:{0} {1}", dir, angl);
            pht.direction  = dir;
            pht.position   = emitPos;
            pht.timeOffset = timeOffset + duration * (float)RandomGen3.NextDouble();
            ret.Add(pht);
        }
        //  Debug.LogFormat("Emitted energy {0}", energy);
        return(ret);
    }
예제 #2
0
    public void Propagate(float absorbtion, float scatter)// scatter length
    {
        float distance = TrailmeshMaker.DrawExp(scatter);
        //Debug.LogFormat("Ran: {0} {1} {2}", distance, absorbtion, scatter);
        float dur       = distance / speed;
        float decayprob = 1.0f - Mathf.Exp(-distance / absorbtion);

        prevPosition = position;
        prevTime     = timeOffset;
        position     = position + direction * distance;
        timeOffset  += dur;
        if (RandomGen3.NextDouble() <= decayprob)
        {
            decayed = true;
            return;
        }
        direction = TrailmeshMaker.Scatter(direction);
    }