示例#1
0
        CGSpot getSpot(int itemID, ref CGBoundsGroup group, ref CGBounds bounds, float startDist, float remainingDistance)
        {
            var     spot  = new CGSpot(itemID);
            float   pathF = Path.DistanceToF(startDist + bounds.Depth / 2);
            Vector3 pos   = Vector3.zero;
            Vector3 tan   = Vector3.forward;
            Vector3 up    = Vector3.up;

            float crossF = getCrossValue((startDist - StartDistance) / Length, group);

            if (group.RotationMode != CGBoundsGroup.RotationModeEnum.Independent)
            {
                if (UseVolume)
                {
                    Volume.InterpolateVolume(pathF, crossF, out pos, out tan, out up);
                }
                else
                {
                    Path.Interpolate(pathF, crossF, out pos, out tan, out up);
                }
                switch (group.RotationMode)
                {
                case CGBoundsGroup.RotationModeEnum.Direction:
                    up = Vector3.up;
                    break;

                case CGBoundsGroup.RotationModeEnum.Horizontal:
                    up    = Vector3.up;
                    tan.y = 0;
                    break;
                }
            }
            else
            {
                pos = (UseVolume) ? Volume.InterpolateVolumePosition(pathF, crossF) : Path.InterpolatePosition(pathF);
            }

            // Orientation Setup
            if (Path.SourceIsManaged)
            {
                spot.Rotation = Quaternion.LookRotation(tan, up) *
                                Quaternion.Euler(group.RotationOffset.x + group.RotationScatter.x * Random.Range(-1, 1),
                                                 group.RotationOffset.y + group.RotationScatter.y * Random.Range(-1, 1),
                                                 group.RotationOffset.z + group.RotationScatter.z * Random.Range(-1, 1));
                spot.Position = pos + spot.Rotation * new Vector3(0, group.Height.Next, 0);
            }
            else
            {
                spot.Rotation = Quaternion.LookRotation(tan, up) *
                                Quaternion.Euler(group.RotationOffset.x + group.RotationScatter.x * Random.Range(-1, 1),
                                                 group.RotationOffset.y + group.RotationScatter.y * Random.Range(-1, 1),
                                                 group.RotationOffset.z + group.RotationScatter.z * Random.Range(-1, 1));
                spot.Position = pos + spot.Rotation * new Vector3(0, group.Height.Next, 0);
            }
            return(spot);
        }
示例#2
0
        CGSpot getSpot(int itemID, ref CGBoundsGroup group, ref CGBounds bounds, float startDist, float remainingDistance)
        {
            var spot = new CGSpot(itemID);
            float pathF = Path.DistanceToF(startDist + bounds.Depth / 2);
            Vector3 pos = Vector3.zero;
            Vector3 tan = Vector3.forward;
            Vector3 up = Vector3.up;

            float crossF = getCrossValue((startDist - StartDistance) / Length, group);
            if (group.RotationMode != CGBoundsGroup.RotationModeEnum.Independent)
            {
                if (UseVolume)
                    Volume.InterpolateVolume(pathF, crossF, out pos, out tan, out up);
                else
                    Path.Interpolate(pathF, crossF, out pos, out tan, out up);
                switch (group.RotationMode)
                {
                    case CGBoundsGroup.RotationModeEnum.Direction:
                        up = Vector3.up;
                        break;
                    case CGBoundsGroup.RotationModeEnum.Horizontal:
                        up = Vector3.up;
                        tan.y = 0;
                        break;
                }
            }
            else
                pos = (UseVolume) ? Volume.InterpolateVolumePosition(pathF, crossF) : Path.InterpolatePosition(pathF);

            // Orientation Setup
            if (Path.SourceIsManaged)
            {
                spot.Rotation = Quaternion.LookRotation(tan, up) *
                                Quaternion.Euler(group.RotationOffset.x + group.RotationScatter.x * Random.Range(-1,1),
                                                 group.RotationOffset.y + group.RotationScatter.y * Random.Range(-1, 1),
                                                 group.RotationOffset.z + group.RotationScatter.z * Random.Range(-1, 1));
                spot.Position = pos + spot.Rotation * new Vector3(0, group.Height.Next, 0);
            }
            else
            {

                spot.Rotation = Quaternion.LookRotation(tan, up) *
                                Quaternion.Euler(group.RotationOffset.x + group.RotationScatter.x * Random.Range(-1, 1),
                                                 group.RotationOffset.y + group.RotationScatter.y * Random.Range(-1, 1),
                                                 group.RotationOffset.z + group.RotationScatter.z * Random.Range(-1, 1));
                spot.Position = pos + spot.Rotation * new Vector3(0, group.Height.Next, 0);
                
            }
            return spot;
        }