Example #1
0
        public void Init(OBJData data, int i)
        {
            this.data   = data;
            lines       = new List <RenderLine>();
            boundingBox = new RenderBoundingBox();
            boundingBox.Init(new BoundingBox(new Vector3(-0.5f), new Vector3(0.5f)));
            boundingBox.SetTransform(Matrix.Translation(data.vertices[i].position));

            if (data.vertices[i].unk3 < data.vertices.Length)
            {
                RenderLine line = new RenderLine();
                Vector3    pos1 = data.vertices[i].position;
                Vector3    pos2 = data.vertices[data.vertices[i].unk3].position;
                line.Init(new Vector3[] { pos1, pos2 });
                lines.Add(line);
            }

            if (data.vertices[i].unk4 < data.vertices.Length)
            {
                RenderLine line = new RenderLine();
                line.Init(new Vector3[] { data.vertices[i].position, data.vertices[data.vertices[i].unk4].position });
                lines.Add(line);
            }

            if (data.vertices[i].unk5 < data.vertices.Length)
            {
                RenderLine line = new RenderLine();
                line.Init(new Vector3[] { data.vertices[i].position, data.vertices[data.vertices[i].unk5].position });
                lines.Add(line);
            }
        }
Example #2
0
        public void Init(JunctionDefinition data)
        {
            if (data.Boundaries != null)
            {
                //boundary init
                if (data.Boundaries.Length > 0)
                {
                    Vector3[] extraPoints = new Vector3[data.Boundaries.Length + 1];
                    Array.Copy(data.Boundaries, extraPoints, data.Boundaries.Length);
                    extraPoints[extraPoints.Length - 1] = extraPoints[0];
                    Boundary = new RenderLine();
                    Boundary.SetSelectedColour(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
                    Boundary.SetUnselectedColour(new Vector4(1.0f));
                    Boundary.Init(extraPoints);
                }
            }

            if (data.Splines != null)
            {
                //do spline
                Splines = new RenderLine[data.Splines.Length];
                for (int i = 0; i < data.Splines.Length; i++)
                {
                    RenderLine line = new RenderLine();
                    line.SetUnselectedColour(new Vector4(1.0f, 0.87f, 0f, 1.0f));
                    line.Init(data.Splines[i].Path);
                    Splines[i] = line;
                }
            }
            DoRender  = true;
            this.data = data;
        }
Example #3
0
        private RenderLine CreateConnectionLine(OBJData.VertexStruct FromPoint, OBJData.VertexStruct ToPoint, System.Drawing.Color Colour)
        {
            RenderLine navigationLine = new RenderLine();

            navigationLine.SetUnselectedColour(Colour);
            navigationLine.SetSelectedColour(System.Drawing.Color.Red);
            navigationLine.Init(new Vector3[2] {
                FromPoint.Position, ToPoint.Position
            });

            return(navigationLine);
        }
Example #4
0
 private void InitSplines()
 {
     if (data.Splines != null)
     {
         //do spline
         Splines = new RenderLine[data.Splines.Length];
         for (int i = 0; i < data.Splines.Length; i++)
         {
             RenderLine line = new RenderLine();
             line.SetUnselectedColour(Color.FromArgb(255, 222, 255));
             line.Init(data.Splines[i].Path);
             Splines[i] = line;
         }
     }
 }
 private void InitSplines()
 {
     if (data.Splines != null)
     {
         //do spline
         Splines = new RenderLine[data.Splines.Length];
         for (int i = 0; i < data.Splines.Length; i++)
         {
             RenderLine line = new RenderLine();
             line.SetUnselectedColour(new Vector4(1.0f, 0.87f, 0f, 1.0f));
             line.Init(data.Splines[i].Path);
             Splines[i] = line;
         }
     }
 }
Example #6
0
 private void InitBoundary()
 {
     if (data.Boundaries != null)
     {
         //boundary init
         if (data.Boundaries.Length > 0)
         {
             Vector3[] extraPoints = new Vector3[data.Boundaries.Length + 1];
             Array.Copy(data.Boundaries, extraPoints, data.Boundaries.Length);
             extraPoints[extraPoints.Length - 1] = extraPoints[0];
             Boundary = new RenderLine();
             Boundary.SetSelectedColour(Color.Red);
             Boundary.SetUnselectedColour(Color.White);
             Boundary.Init(extraPoints);
         }
     }
 }
Example #7
0
        public void Init(ref Vector3[] points, ResourceTypes.Navigation.LaneProperties lane, ResourceTypes.Navigation.RoadFlags roadFlags)
        {
            vertices = new VertexLayouts.BasicLayout.Vertex[points.Length * 2];
            indices  = new ushort[(vertices.Length - 2) * 3];
            int idx = 0;

            for (int i = 0; i < points.Length; i++)
            {
                if (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.MainRoad) || (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.IsHighway)))
                {
                    colour = Color.Blue;
                }
                else if (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.Parking))
                {
                    colour = Color.Green;
                }
                else if (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.ExcludeImpassible))
                {
                    colour = Color.FromArgb(255, 128, 26, 0);
                }
                else if (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.ExcludeImpassible) && lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.BackRoad))
                {
                    colour = Color.FromArgb(255, 128, 51, 230);
                }
                else if (lane.Flags.HasFlag(ResourceTypes.Navigation.LaneTypes.BackRoad))
                {
                    colour = Color.FromArgb(255, 128, 51, 230);
                }

                vertices[idx]          = new VertexLayouts.BasicLayout.Vertex();
                vertices[idx].Position = points[i];
                vertices[idx].Colour   = colour.ToArgb();
                Vector2 forward = Vector2.Zero;

                if (i < points.Length - 1)
                {
                    forward += (new Vector2(points[(i + 1) % points.Length].X, points[(i + 1) % points.Length].Y) - new Vector2(points[i].X, points[i].Y));
                }
                if (i > 0)
                {
                    forward += new Vector2(points[i].X, points[i].Y) - new Vector2(points[(i - 1) % points.Length].X, points[(i - 1) % points.Length].Y);
                }

                forward.Normalize();
                Vector3 left = new Vector3(-forward.Y, forward.X, points[i].Z);
                idx++;
                vertices[idx] = new VertexLayouts.BasicLayout.Vertex();

                float x = 0.0f;
                float y = 0.0f;

                if (roadFlags.HasFlag(ResourceTypes.Navigation.RoadFlags.BackwardDirection))
                {
                    x = (points[i].X - left.X * lane.Width);
                    y = (points[i].Y - left.Y * lane.Width);
                }
                else
                {
                    x = (points[i].X + left.X * lane.Width);
                    y = (points[i].Y + left.Y * lane.Width);
                }

                vertices[idx].Position = new Vector3(x, y, points[i].Z);
                vertices[idx].Colour   = colour.ToArgb();
                points[i] = vertices[idx].Position;

                RenderLine line = new RenderLine();
                line.SetUnselectedColour(Color.Blue);
                line.Init(new Vector3[2] {
                    vertices[idx - 1].Position, vertices[idx].Position
                });
                idx++;

                ushort sIdx       = 0;
                int    indIdx     = 0;
                bool   switcheroo = false;
                while (indIdx < indices.Length)
                {
                    if (switcheroo == false)
                    {
                        indices[indIdx]     = sIdx++;
                        indices[indIdx + 1] = sIdx++;
                        indices[indIdx + 2] = sIdx++;
                        switcheroo          = true;
                    }
                    else
                    {
                        indices[indIdx]     = sIdx--;
                        indices[indIdx + 1] = sIdx--;
                        indices[indIdx + 2] = sIdx--;

                        switcheroo = false;
                    }
                    sIdx    = (ushort)(indices[indIdx + 2] + 1);
                    indIdx += 3;
                }
            }
        }