Beispiel #1
0
        public void CurveType(
            NodePosition startPosition1, RoadType startType1,
            NodePosition endPosition1, RoadType endType1,
            NodePosition startPosition2, RoadType startType2,
            NodePosition endPosition2, RoadType endType2,
            RoadTextureType expectedCurveType)
        {
            var start1 = new MapObject(NodePositions[startPosition1], 0, startType1, default);
            var end1   = new MapObject(NodePositions[endPosition1], 0, endType1, default);
            var start2 = new MapObject(NodePositions[startPosition2], 0, startType2, default);
            var end2   = new MapObject(NodePositions[endPosition2], 0, endType2, default);

            var template = new RoadTemplate("SideWalk3");

            var topology = new RoadTopology();

            topology.AddSegment(template, start1, end1);
            topology.AddSegment(template, start2, end2);

            topology.AlignOrientation();

            var curveNode       = topology.Nodes.Single(n => n.Edges.Count == 2);
            var actualCurveType = CurvedRoadSegment.ChooseCurveType(topology.Edges[0], topology.Edges[1], curveNode.Position);

            Assert.Equal(expectedCurveType, actualCurveType);
        }
        private static SizeF GetSize(RoadTextureType type, RoadTemplate template)
        {
            var stubLength = 0.5f * (1f - template.RoadWidthInTexture);

            float width, height;

            switch (type)
            {
            case RoadTextureType.TCrossing:
                width  = template.RoadWidthInTexture + stubLength + OverlapLength;
                height = template.RoadWidthInTexture + 2 * stubLength + 2 * OverlapLength;
                break;

            case RoadTextureType.XCrossing:
                width  = template.RoadWidthInTexture + 2 * stubLength + 2 * OverlapLength;
                height = width;
                break;

            case RoadTextureType.AsymmetricYCrossing:
                width  = 1.2f + template.RoadWidthInTexture / 2f;
                height = 1.33f + OverlapLength;
                break;

            case RoadTextureType.SymmetricYCrossing:
                width  = 1.59f;
                height = 1.065f + OverlapLength;
                break;

            default:
                throw new ArgumentOutOfRangeException("Unknown RoadTextureType: " + type);
            }

            return(new SizeF(width * template.RoadWidth, height * template.RoadWidth));
        }
 private CrossingRoadSegment(Vector3 position, IEnumerable <RoadSegmentEndPoint> endPoints, Vector3 start, Vector3 end, RoadTextureType type)
 {
     Position      = position;
     EndPoints     = endPoints;
     StartPosition = start;
     EndPosition   = end;
     Type          = type;
 }
Beispiel #4
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        protected override void Unserialize(System.IO.BinaryReader reader)
        {
            values.Clear();

            byte[] fname = reader.ReadBytes(0x40);
            flname = Helper.ToString(fname);

            uk1 = reader.ReadUInt32();
            uk2 = reader.ReadUInt32();
            uk3 = reader.ReadUInt32();

            uint ct = reader.ReadUInt32();

            long pos = reader.BaseStream.Position;

            try
            {
                for (int i = 0; i < ct; i++)
                {
                    string k = reader.ReadString();
                    string v = reader.ReadString();
                    values[k] = v;
                }

                type = RoadTextureType.Materials;
            }
            catch {
                type = RoadTextureType.Unknown;
                reader.BaseStream.Seek(pos, System.IO.SeekOrigin.Begin);

                for (int i = 0; i < ct; i++)
                {
                    uint k = reader.ReadUInt32();
                    uint v = reader.ReadUInt32();
                    values[k] = v;
                }
            }
        }
 public TextureCoordinates this[RoadTextureType roadType] => _coordinates[roadType];
 //API
 public void SetTexture(RoadTextureType type, string texture)
 {
     Textures[(int)type] = texture;
 }
 public string GetTexture(RoadTextureType type)
 {
     return(Textures[(int)type]);
 }
Beispiel #8
0
        private void AssertCurveType(RoadTopologyNode node, RoadTextureType expectedCurveType)
        {
            var actualCurveType = CurvedRoadSegment.ChooseCurveType(node.Edges[0], node.Edges[1], node.Position);

            Assert.Equal(expectedCurveType, actualCurveType);
        }
Beispiel #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 public RoadTexture() : base()
 {
     values = new Hashtable();
     flname = "";
     type   = RoadTextureType.Materials;
 }