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); }
protected override void SetupArrayEx(DevToolsEditor.DTFieldNode node, DevTools.ArrayExAttribute attribute) { base.SetupArrayEx(node, attribute); node.ArrayEx.elementHeight *= 4; node.ArrayEx.drawElementCallback = OnSpotGUI; node.ArrayEx.onSelectCallback = (ReorderableList l) => { selectedIndex = l.index; }; node.ArrayEx.onAddCallback = (ReorderableList l) => { CGSpot newSpot = (selectedIndex > -1 && selectedIndex < Target.Spots.Count) ? Target.Spots[selectedIndex] : new CGSpot(0, Vector3.zero, Quaternion.identity, Vector3.one); Target.Spots.Insert(Mathf.Max(0, l.index + 1), newSpot); EditorUtility.SetDirty(Target); }; }
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; }