コード例 #1
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     foreach (TreeCrayonInstruction instruction in instructions)
     {
         instruction.Execute(crayon, rnd);
     }
 }
コード例 #2
0
        public void Execute(TreeCrayon crayon, Random rnd)
        {
            Matrix transform = crayon.GetTransform();

            Vector3 branchDir = transform.Up;
            Vector3 axis = Vector3.Up;
            float dot = Vector3.Dot(axis, branchDir);

            // If branch is almost perpendicular to alignment axis,
            // just do nothing
            if (Math.Abs(dot) > 0.999f)
                return;

            // project axis onto the crayon's XZ plane
            Vector3 axisXZ = axis - dot*branchDir;
            axisXZ.Normalize();

            float cosAngle = Vector3.Dot(transform.Backward, axisXZ);

            // The dot product of two normalized vectors is always in range [-1,1],
            // but to account for rounding errors, we have to clamp it.
            // Otherwise, Acos will return NaN in some cases.
            cosAngle = MathHelper.Clamp(cosAngle, -1, 1);

            // calculate the angle between the old Z-axis and axisXZ
            // this is also the twist angle required to align the crayon
            var rotation = (float) Math.Acos(cosAngle);

            // finally, perform the twist
            crayon.Twist(rotation);
        }
コード例 #3
0
        public void Execute(TreeCrayon crayon, Random rnd)
        {
            Matrix transform = crayon.GetTransform();

            Vector3 branchDir = transform.Up;
            Vector3 axis      = Vector3.Up;
            float   dot       = Vector3.Dot(axis, branchDir);

            // If branch is almost perpendicular to alignment axis,
            // just do nothing
            if (Math.Abs(dot) > 0.999f)
            {
                return;
            }

            // project axis onto the crayon's XZ plane
            Vector3 axisXZ = axis - dot * branchDir;

            axisXZ.Normalize();

            float cosAngle = Vector3.Dot(transform.Backward, axisXZ);

            // The dot product of two normalized vectors is always in range [-1,1],
            // but to account for rounding errors, we have to clamp it.
            // Otherwise, Acos will return NaN in some cases.
            cosAngle = MathHelper.Clamp(cosAngle, -1, 1);

            // calculate the angle between the old Z-axis and axisXZ
            // this is also the twist angle required to align the crayon
            float rotation = (float)Math.Acos(cosAngle);

            // finally, perform the twist
            crayon.Twist(rotation);
        }
コード例 #4
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     foreach (TreeCrayonInstruction instruction in instructions)
     {
         instruction.Execute(crayon, rnd);
     }
 }
コード例 #5
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.PushState();
     foreach (TreeCrayonInstruction instruction in instructions)
     {
         instruction.Execute(crayon, rnd);
     }
     crayon.PopState();
 }
コード例 #6
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.PushState();
     foreach (TreeCrayonInstruction instruction in instructions)
     {
         instruction.Execute(crayon, rnd);
     }
     crayon.PopState();
 }
コード例 #7
0
ファイル: RequireLevel.cs プロジェクト: unk1nd/ParagliderSim
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (crayon.Level >= Level && Type == CompareType.Greater || crayon.Level <= Level && Type == CompareType.Less)
     {
         foreach (TreeCrayonInstruction instruction in Instructions)
         {
             instruction.Execute(crayon, rnd);
         }
     }
 }
コード例 #8
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (crayon.Level >= Level && Type == CompareType.Greater || crayon.Level <= Level && Type == CompareType.Less)
     {
         foreach (TreeCrayonInstruction instruction in Instructions)
         {
             instruction.Execute(crayon, rnd);
         }
     }
 }
コード例 #9
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (rnd.NextDouble() < chance)
     {
         foreach (TreeCrayonInstruction child in instructions)
         {
             child.Execute(crayon, rnd);
         }
     }
 }
コード例 #10
0
ファイル: Maybe.cs プロジェクト: unk1nd/ParagliderSim
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (rnd.NextDouble() < chance)
     {
         foreach (TreeCrayonInstruction child in instructions)
         {
             child.Execute(crayon, rnd);
         }
     }
 }
コード例 #11
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (crayon.Level == 0)
     {
         float rotation = 0.0f;
         if (crayon.Skeleton.LeafAxis == null)
             rotation = (float) rnd.NextDouble()*MathHelper.TwoPi;
         crayon.Leaf(rotation,
                     size + sizeVariation*(2.0f*(float) rnd.NextDouble() - 1.0f),
                     color + colorVariation*(2.0f*(float) rnd.NextDouble() - 1.0f),
                     AxisOffset);
     }
 }
コード例 #12
0
        public void Execute(TreeCrayon crayon, Random rnd)
        {
            if (productions.Count == 0)
                throw new InvalidOperationException("No productions exist for call.");

            if (crayon.Level + deltaLevel < 0)
                return;

            crayon.Level = crayon.Level + deltaLevel;

            int i = rnd.Next(0, productions.Count);
            productions[i].Execute(crayon, rnd);

            crayon.Level = crayon.Level - deltaLevel;
        }
コード例 #13
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     if (crayon.Level == 0)
     {
         float rotation = 0.0f;
         if (crayon.Skeleton.LeafAxis == null)
         {
             rotation = (float)rnd.NextDouble() * MathHelper.TwoPi;
         }
         crayon.Leaf(rotation,
                     size + sizeVariation * (2.0f * (float)rnd.NextDouble() - 1.0f),
                     color + colorVariation * (2.0f * (float)rnd.NextDouble() - 1.0f),
                     AxisOffset);
     }
 }
コード例 #14
0
        public void Execute(TreeCrayon crayon, Random rnd)
        {
            if (productions.Count == 0)
            {
                throw new InvalidOperationException("No productions exist for call.");
            }

            if (crayon.Level + deltaLevel < 0)
            {
                return;
            }

            crayon.Level = crayon.Level + deltaLevel;

            int i = rnd.Next(0, productions.Count);

            productions[i].Execute(crayon, rnd);

            crayon.Level = crayon.Level - deltaLevel;
        }
コード例 #15
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Forward(distance + variation*((float) rnd.NextDouble()*2 - 1), radiusScale);
 }
コード例 #16
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Twist(Util.Random(rnd, angle, variation));
 }
コード例 #17
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Scale(Util.Random(rnd, scale, variation));
 }
コード例 #18
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Level = crayon.Level + deltaLevel;
 }
コード例 #19
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Bone(Delta);
 }
コード例 #20
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Backward(Util.Random(rnd, distance, distanceVariation));
 }
コード例 #21
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Backward(Util.Random(rnd, distance, distanceVariation));
 }
コード例 #22
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Level = crayon.Level + deltaLevel;
 }
コード例 #23
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Pitch(Util.Random(rnd, angle, variation));
 }
コード例 #24
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Forward(distance + variation * ((float)rnd.NextDouble() * 2 - 1), radiusScale);
 }
コード例 #25
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Bone(Delta);
 }
コード例 #26
0
 public void Execute(TreeCrayon crayon, Random rnd)
 {
     crayon.Scale(Util.Random(rnd, scale, variation));
 }