本文整理汇总了C#中VectorLine.MakeSpline方法的典型用法代码示例。如果您正苦于以下问题:C# VectorLine.MakeSpline方法的具体用法?C# VectorLine.MakeSpline怎么用?C# VectorLine.MakeSpline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorLine
的用法示例。
在下文中一共展示了VectorLine.MakeSpline方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlotTrajectory
List<GameObject> planets; //destination objects, the earth and moon
#endregion Fields
#region Methods
public void PlotTrajectory(Vector3 start, Vector3 startVelocity, float timestep, float maxTime)
{
//Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime/timestep+1)];
List<Vector2> curvePoints = new List<Vector2> ();
Vector3 prev = start;
for (int i = 1; ; i++)
{
float t = timestep * i;
if (t > maxTime) break;
Vector2 pos = PlotTrajectoryAtTime(start, startVelocity, t);
if (Physics.Linecast(prev, pos)) break;
Debug.DrawLine(prev, pos, Color.red);
Debug.Log(pos);
curvePoints.Add(Camera.main.WorldToViewportPoint(pos));
//curvePoints.Add(pos);
prev = pos;
}
line = new VectorLine("Spline", new List<Vector2>(curvePoints.Count+1), 2.0f, LineType.Continuous, Joins.Weld);
//line.useViewportCoords = true;
//Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime / timestep + 1)]
if (curvePoints.Count > 0) {
Debug.Log(curvePoints.Count);
line.MakeSpline(curvePoints.ToArray());
line.continuousTexture = true;
line.Draw();
}
/*
VectorLine line2 = new VectorLine("Arrow2", new List<Vector2>(50), 40.0f, LineType.Continuous, Joins.Weld);
line2.useViewportCoords = true;
Vector2[] splinePoints = new Vector2[] { new Vector2(0.1f, 0.85f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.4f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.85f) };
line2.MakeSpline(curvePoints.ToArray());
//line2.endCap = "arrow2";
line2.continuousTexture = true;
line2.Draw();
*/
}
示例2: getPathLine
public static PathDisplay getPathLine(Path path)
{
Debug.Log("drawPath numba J");
// Debug.Log("awkward length " + path.getPathLength());
float usable_ap = mech.current_ap;
float max_ap = mech.max_ap;
if(path != null)
{
Vector3[] path_spots = new Vector3[path.getPathLength()];
Color[] path_colors = new Color[path_spots.Length-1];
float[] path_widths = new float[path_spots.Length-1];
int i = 0;
int this_turns_travelable = -1;
List<VectorLine> spots = new List<VectorLine>();
foreach(HexData path_pos in path.getTraverseOrderList())
{
// path_spots[i] = Camera.mainCamera.WorldToScreenPoint((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z)));
path_spots[i] = ((hexManagerS.CoordsGameTo3D(path_pos.x, path_pos.z) + y_adj_line));
if(i != 0)
{
path_colors[i-1] = getColorFromCost(path_pos.traversal_cost);
usable_ap-=path_pos.traversal_cost;
if(usable_ap >= 0)
{
path_widths[i-1] = usable_ap/max_ap * max_path_width/2 + max_path_width/2;
}
else
{
usable_ap = 1;
if(this_turns_travelable == -1)
this_turns_travelable = i-1;
path_widths[i-1] = 2;
path_colors[i-1] = enginePlayerS.disable_color;
// break;
}
// var circle = new VectorLine("Circle", new Vector3[30], path_colors[i-1], null, 10F, LineType.Continuous, Joins.Weld);
// circle.MakeCircle(path_spots[i], Vector3.up, .3F);
// spots.Add(circle);
VectorLine outline = outlineHex(path_pos);
outline.SetColor(path_colors[i-1]);
outline.lineWidth = usable_ap/max_ap * max_path_width/2 + max_path_width/4;
spots.Add (outline);
}
Debug.Log(path_spots[i] + " | " + path_pos.traversal_cost);
i++;
}
Array.Resize(ref path_spots, i+1);
Array.Resize(ref path_colors, i);
Array.Resize(ref path_widths, i);
// for(int vc = 0; vc < lineColors.Length; ++vc)
// lineColors[vc] = Color.red;
//// lineColors[vc] = new Color(UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255), UnityEngine.Random.Range(0,255));
// VectorLine.SetLine (Color.green, path_spots);
// VectorLine.Destroy(ref player_route);
player_route = new VectorLine("Line", path_spots, path_colors, null, 5F, LineType.Continuous, Joins.Weld);
// player_route.MakeCircle(path_spots[3], Vector3.up, 2F, 10);
player_route.SetColorsSmooth(path_colors);
player_route.SetWidths(path_widths);
player_route.MakeSpline(path_spots);
player_route.smoothWidth = true;
// if(this_turns_travelable != -1)
// {
// var circle = new VectorLine("Circle", new Vector3[30], null, 10F, LineType.Continuous, Joins.Weld);
// circle.MakeCircle(path_spots[this_turns_travelable], Vector3.up, .3F);
//
// }
//
// VectorLine rings = new VectorLine("Ring1", new Vector2[8], Color.white, null, 10F, LineType.Continuous);
//
// rings.MakeCircle(path_spots[3], Vector3.up, 8F);
// rings.Draw3DAuto();
return new PathDisplay(spots, player_route, new List<Color>(path_colors), new List<float>(path_widths));
// player_route.Draw3DAuto();
}
return null;
}