Ejemplo n.º 1
0
        /// <summary>
        /// 枝を作成する
        /// </summary>
        /// <returns></returns>
        RefParticle MakeBranch(RefStructure s, int depth, RefParticle parent, float angle, float length)
        {
            var t = 1f - ((float)depth / _maxBranchDepth);

            if (depth > 0)
            {
                depth--;
                var position = parent.position + Utilities.Angle2Vector(angle * Mathf.Deg2Rad) * length;
                var current  = s.AddParticle(position, _branchJointSize, RandomGradient(_leafColor), _branchJointMaterialID);

                // 次の枝へ
                var deltaAngle = _branchAngleDeltaFactor * _branchAngleDeltaMultiplierCurve.Evaluate(t);
                MakeBranch(s, depth, current, angle + deltaAngle, length * _branchDamping);

                s.AddEdge(parent, current, _branchWidth, RandomGradient(_branchColor), _branchMaterialID);

                if (Random.Range(0f, 1f) > 0.5f)
                {
                    MakeBranch(s, depth, current, angle + Random.Range(-60f, 60f), length * _branchDamping);
                }

                return(current);
            }
            else
            {
                var position = parent.position + Utilities.Angle2Vector(angle * Mathf.Deg2Rad) * _leafSize.y;
                var current  = s.AddParticle(position, 0f, RandomGradient(_branchJointColor), _branchJointMaterialID);

                // 本当の葉っぱ
                s.AddEdge(parent, current, _leafSize.x, RandomGradient(_leafColor), _leafMaterialID);

                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 指定した構造体にパーティクルを追加する
        /// </summary>
        /// <param name="s"></param>
        /// <param name="targets"></param>
        static void AddParticles(RefStructure s, RefParticle[] targets)
        {
            Assert.IsNotNull(s);
            Assert.IsNotNull(targets);

            for (var i = 0; i < targets.Length; ++i)
            {
                var t = targets[i];
                s.AddParticle(t.position, t.size, t.color, t.materialID);
            }
        }
Ejemplo n.º 3
0
 public override RefParticle Add(RefStructure s, Vector2 p)
 {
     return(s.AddParticle(p, _size.random, _color.E_Random(), _materialID));
 }
Ejemplo n.º 4
0
 public override RefParticle Add(RefStructure s, Vector2 p, float t)
 {
     return(s.AddParticle(p, _size.Lerp(t), _color.Evaluate(t), _materialID));
 }