private void Generate(int width, int height) { int numPoints = width * height; if (Algorithms.IsNumberOdd(numPoints)) numPoints += 1; line = new VectorLine("Tile Map Grid", new Vector3[numPoints], null, GridWidth); int index = 0; for (int x = 0; x < width + 1; x++) { line.points3[index++] = new Vector3(x, 0.0f, 0.0f); line.points3[index++] = new Vector3(x, height, 0.0f); } for (int y = 0; y < height + 1; y++) { line.points3[index++] = new Vector3(0.0f, y, 0.0f); line.points3[index++] = new Vector3(width, y, 0.0f); } VectorLine.canvas3D.pixelPerfect = true; VectorLine.canvas3D.sortingLayerName = "Pathfinding"; VectorLine.canvas3D.sortingOrder = 1; line.SetColor(new Color(0.0f, 0.0f, 0.0f, GridOpacity)); line.Draw3DAuto(); }
void Start() { pathfindingLine = new VectorLine("Pathfinding Line", new Vector3[0], null, 3.0f, LineType.Continuous); VectorLine.canvas3D.pixelPerfect = true; VectorLine.canvas3D.sortingLayerName = "Pathfinding"; VectorLine.canvas3D.sortingOrder = 2; }
private void Init (CelestialBody body, float mass, float diameter, Vector3 barycenter) { Body = body; Mass = mass; EquatorialDiameter = diameter; Barycenter = barycenter; CalculateBaseProperties (); CalculateOrbitProperties (); debugLine = new VectorLine ("Debug_Orbit_" + Body.Name, new Vector3[90], null, 1.0f); }
protected override void Initialize() { base.Initialize(); _line.MakeCube(Vector3.zero, Size.x, Size.y, Size.z); List<Vector3> centerPoint = new List<Vector3>() { Vector3.zero }; _centerPoint = new VectorLine("CenterPoint", centerPoint, texture, 2F, LineType.Points); _centerPoint.color = Color.ToUnityColor(); // color removed from constructor in Vectrosity 4.0 _centerPoint.drawTransform = _target; // _line.Draw3D(_target); removed by Vectrosity 3.0 _centerPoint.active = false; }
public Fleet (List<ActorShip> Ships = null, ActorShip FlagShip =null, Colony HomeColony =null) { name = "Fleet " + (Finder.fleetDatabase.Count + 1); ships = new List<ActorShip> (); AddMultipleShips (Ships); SetDefaultFlagShip (); homeColony = HomeColony; Interval = 5; // selectedLine = new VectorLine ("Selected_" + name, new Vector3[8], null, 3.0f); selectedLine.color = Color.magenta; Finder.fleetDatabase.Add (this); }
public void CreateLine() { // set line string name = "line"; Color color = Color.red; Material material = null; // Texture texture = // material.shader = Shader.Find("Diffuse"); // material.SetTexture("_MainTex", texture); float width = 5.0f; if (line == null) line = new VectorLine(name, pointsOfLine, color, material, width); }
public override Entity Init (string defID) { base.Init (defID); AddBrain (); Interval = brain.Interval; AddAnatomy (); SetLateAttributes (); constructionPointsRequired += anatomy.GetConstructionCost (); worker = new Worker (this); Finder.actorDatabase.Add (this); displayDepth = 10; targetPosLine = new VectorLine ("TargetPos_" + this.Name, new Vector3[2], null, 1.0f); targetPosLine.color = Color.red; return this; }
public void Show(bool toShow) { if (!toShow && _line == null) { return; } if (_line == null) { _line = new VectorLine(LineName, new Vector3[24], Color.ToUnityColor(), null, LineWidth, LineType.Discrete); if (Parent != null) { OnParentChanged(); } VectorManager.useDraw3D = true; _line.MakeCube(Vector3.zero, Size.x, Size.y, Size.z); VectorManager.ObjectSetup(_target.gameObject, _line, _visibility, Brightness.None, makeBounds: false); // NOTE: Using makeBounds: false means this CubeWireframe object does not automatically gain a renderer and invisible mesh. This renderer // and mesh enables OnBecameVisible/Invisible which overrides the line.active on/off commands I use to show/not show the line. There is another // alternative to retain control: destroy this SectorWireframe gameobject each time I turn the line off (and then rebuild it of course). Destroying // the VectorLine itself when using VectorManager.ObjectSetup will result in an error. } _line.active = toShow; D.Log("{0} line.active = {1}.", this.GetType().Name, toShow); }
// public PlanetarySystem (Coord position=null) { if (GameManager.currentGame.currentSystem == null) { GameManager.currentGame.currentSystem = this; } GameManager.currentGame.planetarySystems.Add (this); entities = new List<Entity> (); name = "system" + UnityEngine.Random.Range (0, 100); debugLine = new VectorLine ("Debug_" + name, new List<Vector3> (), null, 2.0f, LineType.Discrete, Joins.None); if (position == null) { RandomizeSystemCoord (); } else { coord = position; } GenerateSystem (); Interval = 30; isVisible = false; SetVisiblity (false); }
public void Show(bool toShow) { if (!toShow && _line == null) { return; } if (_line == null) { _line = new VectorLine(LineName, new List<Vector3>(_points), null, LineWidth); _line.color = Color.ToUnityColor(); // color removed from constructor by Vectrosity 4.0 VectorManager.useDraw3D = true; VectorManager.ObjectSetup(_target.gameObject, _line, _visibility, Brightness.Fog); VectorManager.SetBrightnessParameters(5000F, 250F, 32, .2F, GameColor.Clear.ToUnityColor()); // NOTE: Using makeBounds: false means this CubeWireframe object does not automatically gain a renderer and invisible mesh. This renderer // and mesh enables OnBecameVisible/Invisible which overrides the line.active on/off commands I use to show/not show the line. There is another // alternative to retain control: destroy this SectorWireframe gameobject each time I turn the line off (and then rebuild it of course). Destroying // the VectorLine itself when using VectorManager.ObjectSetup will result in an error. } _line.active = toShow; D.Log("{0} line.active = {1}.", this.GetType().Name, toShow); }
public static void CheckDistanceSetup(Transform thisTransform, VectorLine line, Color color, RefInt objectNum) { VectorLine.LineManagerEnable(); if (vectorLines3 == null) { vectorLines3 = new List <VectorLine>(); transforms3 = new List <Transform>(); oldDistances = new List <int>(); colors = new List <Color>(); objectNumbers3 = new List <RefInt>(); VectorLine.LineManagerCheckDistance(); } transforms3.Add(thisTransform); vectorLines3.Add(line); oldDistances.Add(-1); colors.Add(color); objectNum.i = _arrayCount3++; objectNumbers3.Add(objectNum); }
public void AddLine(VectorLine vectorLine, Transform thisTransform, float time) { if (time > 0.0f) // Needs to be before the line check, to accommodate re-added lines { StartCoroutine(DisableLine(vectorLine, time, false)); } for (int i = 0; i < lineCount; i++) { if (vectorLine == lines[i]) { return; } } lines.Add(vectorLine); transforms.Add(thisTransform); if (++lineCount == 1) { enabled = true; } }
public void Setup(VectorLine line, bool makeBounds) { if (makeBounds) { VectorManager.SetupBoundsMesh(gameObject, line); } // Adjust points to this position, so the line doesn't have to be updated with the transform of this object // Also make sure the points are unique by creating a new list and copying the points over m_originalMatrix = transform.localToWorldMatrix; var thisPoints = new List <Vector3>(line.points3); for (int i = 0; i < thisPoints.Count; i++) { thisPoints[i] = m_originalMatrix.MultiplyPoint3x4(thisPoints[i]); } line.points3 = thisPoints; m_vectorLine = line; VectorManager.VisibilityStaticSetup(line, out m_objectNumber); StartCoroutine(WaitCheck()); }
public void DisableLine(VectorLine vectorLine, float time) { StartCoroutine(DisableLine(vectorLine, time, false)); }
void PolyDataToMesh() { // mesh.MarkDynamic(); mesh.Clear(); triangleFilter.Update(); Kitware.VTK.vtkPolyData pd = triangleFilter.GetOutput(); // Points / Vertices int numVertices = pd.GetNumberOfPoints(); Vector3[] vertices = new Vector3[numVertices]; for (int i = 0; i < numVertices; ++i) { double[] pnt = pd.GetPoint(i); // Flip z-up to y-up vertices[i] = new Vector3(-(float)pnt[0], (float)pnt[2], (float)pnt[1]); } mesh.vertices = vertices; // Triangles / Cells int numTriangles = pd.GetNumberOfPolys(); int[] triangles = new int[numTriangles * 3]; Kitware.VTK.vtkCellArray polys = pd.GetPolys(); if (polys.GetNumberOfCells() > 0) { int prim = 0; Kitware.VTK.vtkIdList pts = Kitware.VTK.vtkIdList.New(); polys.InitTraversal(); while (polys.GetNextCell(pts) != 0) { for (int i = 0; i < pts.GetNumberOfIds(); ++i) { triangles[prim * 3 + i] = pts.GetId(i); } ++prim; } } mesh.triangles = triangles; // Lines Kitware.VTK.vtkCellArray lines = pd.GetLines(); if (lines.GetNumberOfCells() > 0) { Kitware.VTK.vtkIdList pts = Kitware.VTK.vtkIdList.New(); lines.InitTraversal(); int prim = 0; while (lines.GetNextCell(pts) != 0) { Color lineColor = solidColor; if (colorArray != null) { if (colorDataType == VtkColorType.CELL_DATA) { lineColor = GetColorAtIndex(prim); } else if (colorDataType == VtkColorType.POINT_DATA) { lineColor = GetColorAtIndex(pts.GetId(0)); } } Vector3[] linePoints = new Vector3[2]; linePoints[0] = vertices[pts.GetId(0)]; linePoints[1] = vertices[pts.GetId(1)]; Vectrosity.VectorLine line = new Vectrosity.VectorLine(name + "-Line", linePoints, lineColor, null, 1.0f); line.Draw3DAuto(go.transform); ++prim; } } // Points Kitware.VTK.vtkCellArray points = pd.GetVerts(); int numPointCells = points.GetNumberOfCells(); if (numPointCells > 0) { ArrayList list = new ArrayList(); ArrayList colorList = new ArrayList(); Kitware.VTK.vtkIdList pts = Kitware.VTK.vtkIdList.New(); points.InitTraversal(); while (points.GetNextCell(pts) != 0) { ArrayList pointsList = new ArrayList(); ArrayList colorsList = new ArrayList(); for (int i = 0; i < pts.GetNumberOfIds(); ++i) { pointsList.Add(vertices[pts.GetId(i)]); Color pointColor = solidColor; if (colorArray != null && colorDataType == VtkColorType.POINT_DATA) { pointColor = GetColorAtIndex(pts.GetId(i)); } colorsList.Add(pointColor); } list.AddRange(pointsList); colorList.AddRange(colorsList); } Vectrosity.VectorPoints pnt = new Vectrosity.VectorPoints(name + "-Point " + list.Count, list.ToArray(typeof(Vector3)) as Vector3[], colorList.ToArray(typeof(Color)) as Color[], null, 1f); pnt.Draw3DAuto(go.transform); } // Texture coordinates Vector2[] uvs; int numCoords = 0; Kitware.VTK.vtkDataArray vtkTexCoords = pd.GetPointData().GetTCoords(); if (vtkTexCoords != null) { numCoords = vtkTexCoords.GetNumberOfTuples(); uvs = new Vector2[numCoords]; for (int i = 0; i < numCoords; ++i) { double[] texCoords = vtkTexCoords.GetTuple2(i); uvs[i] = new Vector2((float)texCoords[0], (float)texCoords[1]); } mesh.uv = uvs; } // Vertex colors if (numTriangles > 0 && colorArray != null) { Color32[] colors = new Color32[numVertices]; for (int i = 0; i < numVertices; ++i) { colors[i] = GetColor32AtIndex(i); } mesh.colors32 = colors; } //Debug.Log("Number of point data arrays: " + pd.GetPointData().GetNumberOfArrays()); //Debug.Log(" - " + pd.GetPointData().GetArrayName(0)); //Debug.Log("Number of cell data arrays: " + pd.GetCellData().GetNumberOfArrays()); //Debug.Log(" - " + pd.GetCellData().GetArrayName(0)); //Debug.Log(name + " - Vertices: " + numPoints + ", triangle: " + numTriangles + ", UVs: " + numCoords); mesh.RecalculateNormals(); mesh.RecalculateBounds(); //mesh.Optimize(); }
void Awake() { int dirCount = System.Enum.GetValues(typeof(Direction)).Length; for(int i=0; i<dirCount; ++i) { choice.Add(new DirectionalData()); } scanTimer.Randomize(); worstLine = new VectorLine ("BrainAvoid", new Vector3[6], lineMaterial, 2f); worstLine.color = Color.red; bestLine = new VectorLine ("BrainTarget", new Vector3[6], lineMaterial, 2f); bestLine.color = Color.green; badSpiderLine = new VectorLine ("BadSpider", new Vector3[32], lineMaterial, 2f); badSpiderLine.color = Color.red; goodSpiderLine = new VectorLine ("GoodSpider", new Vector3[32], lineMaterial, 2f); goodSpiderLine.color = Color.blue; }
public static VectorLine SetLine (Color color, float time, params Vector3[] points) { if (points.Length < 2) { Debug.LogError ("VectorLine.SetLine needs at least two points"); return null; } var line = new VectorLine("SetLine", points, null, 1.0f, LineType.Continuous, Joins.None); line.color = color; if (time > 0.0f) { lineManager.DisableLine(line, time); } line.Draw(); return line; }
public void ToggleShowPath(int index, bool show, bool update = true) { GameObject pathObjectRoot = PathObjectRoots[index]; if (pathObjectRoot && (!show || update)) { Object.Destroy(pathObjectRoot); PathObjectRoots[index] = null; pathObjectRoot = null; } if (show && pathObjectRoot == null) { Color color = PathColors[index]; MapPath path = Paths[index]; pathObjectRoot = new GameObject("PathObjectRoot"); pathObjectRoot.transform.SetParent(PathRoot.transform, false); PathObjectRoots[index] = pathObjectRoot; GameObject obj = Loader.LoadPrefab("Map/StartMark").Instantiate(); obj.transform.SetParent(pathObjectRoot.transform, false); obj.transform.position = path.StartPosition; obj.GetComponent<SpriteRenderer>().color = color; obj = Loader.LoadPrefab("Map/EndMark").Instantiate(); obj.transform.SetParent(pathObjectRoot.transform, false); obj.transform.position = path.EndPosition; obj.GetComponent<SpriteRenderer>().color = color; int count = path.WaypointCount; for (int i = 1; i < count; ++i) { List<Vector3> positions = path.FindPathPosition(i); if (positions.Count >= 2) { VectorLine line = new VectorLine("PathLine", positions, null, 2, LineType.Continuous); line.color = color; obj = new GameObject("PathLine"); obj.transform.SetParent(pathObjectRoot.transform, false); VectorManager.useDraw3D = true; VectorManager.ObjectSetup(obj, line, Visibility.Dynamic, Brightness.None); } if (i < count - 1) { obj = Loader.LoadPrefab("Map/StartMark").Instantiate(); obj.transform.SetParent(pathObjectRoot.transform, false); obj.transform.position = path.GetPosition(i); obj.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); obj.GetComponent<SpriteRenderer>().color = color; } } } }
public static void ObjectSetup(GameObject go, VectorLine line, Visibility visibility, Brightness brightness) { ObjectSetup(go, line, visibility, brightness, true); }
private void InitializeLine() { int pointsCount = MaxCircles * _segmentsPerCircle * 2; // 2 points per segment for a discrete line _line = new VectorLine(LineName, new List<Vector2>(pointsCount), texture, 1F, LineType.Discrete); _line.active = false; _circlesToShow = new bool[MaxCircles]; }
void Start() { line = new VectorLine("PathLine", new Vector3[numPoints], null, 2, LineType.Continuous); line.SetColor(new Color(1, 0, 0)); VectorManager.useDraw3D = true; VectorManager.ObjectSetup(gameObject, line, Visibility.Dynamic, Brightness.None); }
public static void Init () { mainCam = Camera.main; selectLine = new VectorLine ("SelectBox", new Vector3[8], null, 1.0f); }
public static void ObjectSetup(GameObject go, VectorLine line, Visibility visibility, Brightness brightness, bool makeBounds) { var vc = go.GetComponent(typeof(VisibilityControl)) as VisibilityControl; var vcs = go.GetComponent(typeof(VisibilityControlStatic)) as VisibilityControlStatic; var vca = go.GetComponent(typeof(VisibilityControlAlways)) as VisibilityControlAlways; var bc = go.GetComponent(typeof(BrightnessControl)) as BrightnessControl; if (visibility == Visibility.None) { if (vc) { MonoBehaviour.Destroy(vc); } if (vcs) { MonoBehaviour.Destroy(vcs); } if (vca) { MonoBehaviour.Destroy(vca); } } if (visibility == Visibility.Dynamic) { if (vc == null) { vc = go.AddComponent(typeof(VisibilityControl)) as VisibilityControl; vc.Setup(line, makeBounds); if (bc != null) { bc.SetUseLine(false); } } } else if (visibility == Visibility.Static) { if (vcs == null) { vcs = go.AddComponent(typeof(VisibilityControlStatic)) as VisibilityControlStatic; vcs.Setup(line, makeBounds); if (bc != null) { bc.SetUseLine(false); } } } else if (visibility == Visibility.Always) { if (vca == null) { vca = go.AddComponent(typeof(VisibilityControlAlways)) as VisibilityControlAlways; vca.Setup(line); if (bc != null) { bc.SetUseLine(false); } } } if (brightness == Brightness.Fog) { if (bc == null) { bc = go.AddComponent(typeof(BrightnessControl)) as BrightnessControl; if (vc == null && vcs == null && vca == null) { bc.Setup(line, true); } else { bc.Setup(line, false); } } } else { if (bc) { MonoBehaviour.Destroy(bc); } } }
public void Setup(VectorLine line) { VectorManager.VisibilitySetup(transform, line, out m_objectNumber); VectorManager.DrawArrayLine2(m_objectNumber.i); m_vectorLine = line; }
public static VectorLine MakeLine (string name, Vector2[] points) { if (!defaultsSet) { PrintMakeLineError(); return null; } var line = new VectorLine(name, points, defaultLineColor, defaultLineMaterial, defaultLineWidth, defaultLineType, defaultJoins); line.capLength = defaultCapLength; line.depth = defaultLineDepth; return line; }
public static VectorLine SetRay (Color color, float time, Vector3 origin, Vector3 direction) { var line = new VectorLine("SetRay", new Vector3[] {origin, new Ray(origin, direction).GetPoint (direction.magnitude)}, null, 1.0f, LineType.Continuous, Joins.None); line.color = color; if (time > 0.0f) { lineManager.DisableLine(line, time); } line.Draw(); return line; }
public static void GetAsterismLines(ref StarData[] starData) { for(int i=0; i<AsterismParser.AsterismData.Length; i++) { Asterism asterism = AsterismParser.AsterismData[i]; Vector3[] positionArray = new Vector3[asterism.HD_ids.Length]; for(int j=0; j<asterism.HD_ids.Length;j++) { uint hdid = asterism.HD_ids[j]; if(StarParser.HD_idToIndex != null && StarParser.HD_idToIndex.ContainsKey(hdid)) { StarData star = starData[StarParser.HD_idToIndex[hdid]]; GameObject starObj = star.GameObjectRepresentation; if ( starObj != null ) { positionArray[j] = starObj.transform.position; } else { Debug.LogError("Ummm...this star is missing a game object. Skipping the asterism: " + asterism.name); } } else { Debug.LogError("Ummm...this star is missing. Skipping the asterism: " + asterism.name); continue; } } if ( asterism.lineArt == null ) { if ( m_lineMat == null ) { m_lineMat = Resources.Load("Lines/LineMat") as Material; } VectorLine asterismLines = new VectorLine(asterism.name + "_line", positionArray, m_lineMat, 1.0f, LineType.Discrete); asterism.lineArt = asterismLines; } else { asterism.lineArt.points3 = positionArray; } AsterismParser.AsterismData[i] = asterism; } setAsterismColor(m_asterismColor); }
public static void Destroy (ref VectorLine line) { DestroyLine (ref line); }
public static VectorLine SetLine3D (Color color, float time, params Vector3[] points) { if (points.Length < 2) { Debug.LogError ("VectorLine.SetLine3D needs at least two points"); return null; } var line = new VectorLine("SetLine3D", points, null, 1.0f, LineType.Continuous, Joins.None); line.color = color; line.Draw3DAuto (time); return line; }
private static void DestroyLine (ref VectorLine line) { if (line != null) { Object.Destroy (line.m_vectorObject); if (line.isAutoDrawing) { line.StopDrawing3DAuto(); } line = null; } }
public static VectorLine SetRay3D (Color color, float time, Vector3 origin, Vector3 direction) { var line = new VectorLine("SetRay3D", new Vector3[] {origin, new Ray(origin, direction).GetPoint (direction.magnitude)}, null, 1.0f, LineType.Continuous, Joins.None); line.color = color; line.Draw3DAuto (time); return line; }
protected override void Initialize() { _line = new VectorLine(LineName, _points, Color.ToUnityColor(), material, LineWidth); if (Parent != null) { OnParentChanged(); } }
public static void Destroy (VectorLine[] lines) { for (int i = 0; i < lines.Length; i++) { DestroyLine (ref lines[i]); } }
public void SetVectorLine(VectorLine vectorLine, Texture tex, Material mat) { this.vectorLine = vectorLine; SetTexture(tex); SetMaterial(mat); }
public static void Destroy (ref VectorLine line, GameObject go) { Destroy (ref line); if (go != null) { Object.Destroy (go); } }
protected virtual void Initialize() { /********************************************************************************************************************************************* * GOTCHA! The new VectorLine 5.0 constructor relies on the capacity of the list when Points.Count is 0. * If Points.Count is 0, new List(Points) creates an empty list with ZERO capacity, it DOES NOT copy the capacity of the Points list! *********************************************************************************************************************************************/ var points = new List<Vector3>(Points.Capacity); points.AddRange(Points); //D.Log("List being used for Line creation: Capacity = {0}, Count = {1}.", points.Capacity, points.Count); _line = new VectorLine(LineName, points, texture, LineWidth, _lineType); _line.color = Color.ToUnityColor(); // color removed from constructor in Vectrosity 4.0 _line.layer = (int)Layers.TransparentFX; // make the line visible to the mainCamera. line.layer added in Vectrosity 5.0 if (_target != null) { _line.drawTransform = _target; } // added as Vectrosity 3.0 removed Draw3D(Transform) _line.active = false; //RelocateLineManager(); // see Relocate LineManager Archive }