Ejemplo n.º 1
0
        public string ConvertToString()
        {
            EdgeObjectLibraryMaker ELM = new EdgeObjectLibraryMaker();

            ELM.Setup(this);
            return(GSDRootUtil.GetString <EdgeObjectLibraryMaker>(ELM));
        }
Ejemplo n.º 2
0
    private static bool IsApproxTwoThirds(ref Vector3 V1, Vector3 V2)
    {
        int cCount = 0;

        if (GSDRootUtil.IsApproximately(V1.x, V2.x, 0.02f))
        {
            cCount += 1;
        }
        if (GSDRootUtil.IsApproximately(V1.y, V2.y, 0.02f))
        {
            cCount += 1;
        }
        if (GSDRootUtil.IsApproximately(V1.z, V2.z, 0.02f))
        {
            cCount += 1;
        }

        if (cCount == 2)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// This will create an intersection if two nodes overlap on the road. Only good if the roads only overlap once.
        /// </summary>
        /// <param name="bRoad"></param>
        /// <param name="tRoad"></param>
        private static void UnitTest_IntersectionHelper(GSDRoad bRoad, GSDRoad tRoad, GSDRoadIntersection.iStopTypeEnum iStopType, GSDRoadIntersection.RoadTypeEnum rType)
        {
            GSDSplineN tInter1 = null;
            GSDSplineN tInter2 = null;

            foreach (GSDSplineN tNode in bRoad.GSDSpline.mNodes)
            {
                foreach (GSDSplineN xNode in tRoad.GSDSpline.mNodes)
                {
                    if (GSDRootUtil.IsApproximately(Vector3.Distance(tNode.transform.position, xNode.transform.position), 0f, 0.05f))
                    {
                        tInter1 = tNode;
                        tInter2 = xNode;
                        break;
                    }
                }
            }

            if (tInter1 != null && tInter2 != null)
            {
                GameObject          tInter = GSD.Roads.GSDIntersections.CreateIntersection(tInter1, tInter2);
                GSDRoadIntersection GSDRI  = tInter.GetComponent <GSDRoadIntersection>();
                GSDRI.iStopType = iStopType;
                GSDRI.rType     = rType;
            }
        }
Ejemplo n.º 4
0
 public static EdgeObjectLibraryMaker ELMFromData(string tData)
 {
     try{
         EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadData <EdgeObjectLibraryMaker>(ref tData);
         return(ELM);
     }catch {
         return(null);
     }
 }
Ejemplo n.º 5
0
        public void LoadFromLibraryWizard(string xName)
        {
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "W/" + xName + ".gsd";
            EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML <EdgeObjectLibraryMaker>(ref tPath);

            ELM.LoadTo(this);
            bNeedsUpdate = true;
        }
Ejemplo n.º 6
0
    public Vector3 GetSplineValue_SkipOpt(float f, bool b = false)
    {
        int i;
        int idx = -1;

        if (mNodes.Count == 0)
        {
            return(default(Vector3));
        }
        if (mNodes.Count == 1)
        {
            return(mNodes[0].pos);
        }

//		if(GSDRootUtil.IsApproximately(f,0f,0.00001f)){
//			if(b){
//				return mNodes[0].tangent;
//			}else{
//				return mNodes[0].pos;
//			}
//		}else
//		if(GSDRootUtil.IsApproximately(f,1f,0.00001f) || f > 1f){
//			if(b){
//				return mNodes[mNodes.Count-1].tangent;
//			}else{
//				return mNodes[mNodes.Count-1].pos;
//			}
//		}else{
        for (i = 1; i < mNodes.Count; i++)
        {
            if (i == mNodes.Count - 1)
            {
                idx = i - 1;
                break;
            }
            if (mNodes[i].tTime >= f)
            {
                idx = i - 1;
                break;
            }
        }
        if (idx < 0)
        {
            idx = 0;
        }
//		}

        float param = (f - mNodes[idx].tTime) / (mNodes[idx + 1].tTime - mNodes[idx].tTime);

        param = GSDRootUtil.Ease(param, mNodes[idx].EaseIO.x, mNodes[idx].EaseIO.y);
        return(GetHermiteInternal(idx, param, b));
    }
Ejemplo n.º 7
0
        public void LoadFromLibrary(string xName, bool bIsQuickAdd = false)
        {
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "EOM" + xName + ".gsd";

            if (bIsQuickAdd)
            {
                tPath = xPath + "Q/EOM" + xName + ".gsd";
            }
            EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML <EdgeObjectLibraryMaker>(ref tPath);

            ELM.LoadTo(this);
            bNeedsUpdate = true;
        }
Ejemplo n.º 8
0
        public static void GetLibraryFiles(out string[] tNames, out string[] tPaths, bool bIsDefault = false)
        {
                        #if UNITY_WEBPLAYER
            tNames = null;
            tPaths = null;
            return;
                        #else
            tNames = null;
            tPaths = null;
            DirectoryInfo info;
            string        xPath = GSDRootUtil.Dir_GetLibrary();
            if (bIsDefault)
            {
                info = new DirectoryInfo(xPath + "Q/");
            }
            else
            {
                info = new DirectoryInfo(xPath);
            }

            FileInfo[] fileInfo = info.GetFiles();
            int        tCount   = 0;


            foreach (FileInfo tInfo in fileInfo)
            {
                if (tInfo.Name.Contains("EOM") && tInfo.Extension.ToLower().Contains("gsd"))
                {
                    tCount += 1;
                }
            }

            tNames = new string[tCount];
            tPaths = new string[tCount];
            tCount = 0;
            foreach (FileInfo tInfo in fileInfo)
            {
                if (tInfo.Name.Contains("EOM") && tInfo.Extension.ToLower().Contains("gsd"))
                {
                    tNames[tCount] = tInfo.Name.Replace(".gsd", "").Replace("EOM", "");
                    tPaths[tCount] = tInfo.FullName;
                    tCount        += 1;
                }
            }
                        #endif
        }
Ejemplo n.º 9
0
        //ref hVerts,ref hTris, ref hNormals, ref hUV, ref hTangents
        private Mesh GSDCombineMeshes(ref List <Vector3[]> hVerts, ref List <int[]> hTris, ref List <Vector2[]> hUV, int OrigMVL, int OrigTriCount)
        {
            int mCount = hVerts.Count;
            int NewMVL = OrigMVL * mCount;

            Vector3[] tVerts   = new Vector3[NewMVL];
            int[]     tTris    = new int[OrigTriCount * mCount];
            Vector3[] tNormals = new Vector3[NewMVL];
            Vector2[] tUV      = new Vector2[NewMVL];

            int CurrentMVLIndex = 0;
            int CurrentTriIndex = 0;

            for (int j = 0; j < mCount; j++)
            {
                CurrentMVLIndex = OrigMVL * j;
                CurrentTriIndex = OrigTriCount * j;

                if (j > 0)
                {
                    for (int i = 0; i < OrigTriCount; i++)
                    {
                        hTris[j][i] += CurrentMVLIndex;
                    }
                }

                System.Array.Copy(hVerts[j], 0, tVerts, CurrentMVLIndex, OrigMVL);
                System.Array.Copy(hTris[j], 0, tTris, CurrentTriIndex, OrigTriCount);
                System.Array.Copy(hUV[j], 0, tUV, CurrentMVLIndex, OrigMVL);
            }

            Mesh tMesh = new Mesh();

            tMesh.vertices  = tVerts;
            tMesh.triangles = tTris;
            tMesh.uv        = tUV;
            tMesh.normals   = tNormals;
            tMesh.RecalculateBounds();
            tMesh.RecalculateNormals();
            tMesh.tangents = GSDRootUtil.ProcessTangents(tTris, tNormals, tUV, tVerts);
            return(tMesh);
        }
Ejemplo n.º 10
0
        public void SaveToLibrary(string fName = "", bool bIsDefault = false)
        {
            EdgeObjectLibraryMaker ELM = new EdgeObjectLibraryMaker();

            ELM.Setup(this);
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "EOM" + tName + ".gsd";

            if (fName.Length > 0)
            {
                if (bIsDefault)
                {
                    tPath = xPath + "Q/EOM" + fName + ".gsd";
                }
                else
                {
                    tPath = xPath + "EOM" + fName + ".gsd";
                }
            }
            GSDRootUtil.CreateXML <EdgeObjectLibraryMaker>(ref tPath, ELM);
        }
Ejemplo n.º 11
0
    private void OnGUI()
    {
        GUILayout.Space(4f);
        EditorGUILayout.LabelField(titleText, EditorStyles.boldLabel);

        temp2D_2 = (Texture2D)EditorGUILayout.ObjectField("Square thumb (optional):", temp2D, typeof(Texture2D), false);
        if (temp2D_2 != temp2D)
        {
            temp2D      = temp2D_2;
            ThumbString = AssetDatabase.GetAssetPath(temp2D);
        }

        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        EditorGUILayout.LabelField("Short description (optional):");
        Desc         = EditorGUILayout.TextArea(Desc, GUILayout.Height(40f));
        displayName2 = EditorGUILayout.TextField("Display name:", displayName);
        if (string.Compare(displayName2, displayName) != 0)
        {
            displayName = displayName2;
            SanitizeFilename();

            if (tWindowType == WindowTypeEnum.Edge)
            {
                if (System.IO.File.Exists(xPath + "EOM" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                if (System.IO.File.Exists(xPath + "ESO" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
            else
            {
                if (System.IO.File.Exists(xPath + "B/" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
        }


        if (fileExists)
        {
            EditorGUILayout.LabelField("File exists already!", EditorStyles.miniLabel);
            if (tWindowType == WindowTypeEnum.Edge)
            {
                EditorGUILayout.LabelField(xPath + "EOM" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                EditorGUILayout.LabelField(xPath + "ESO" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else
            {
                EditorGUILayout.LabelField(xPath + "B/" + fileName + ".gsd", EditorStyles.miniLabel);
            }
        }
        else
        {
            if (tWindowType == WindowTypeEnum.Edge)
            {
                EditorGUILayout.LabelField(xPath + "EOM" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                EditorGUILayout.LabelField(xPath + "ESO" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else
            {
                EditorGUILayout.LabelField(xPath + "B/" + fileName + ".gsd", EditorStyles.miniLabel);
            }
        }

        GUILayout.Space(4f);

        isBridge = EditorGUILayout.Toggle("Is bridge related:", isBridge);
        //		GUILayout.Space(4f);
        //		bIsDefault = EditorGUILayout.Toggle("Is GSD:",bIsDefault);
        GUILayout.Space(8f);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Cancel"))
        {
            Close();
        }
        if (tWindowType == WindowTypeEnum.Extrusion)
        {
            DoExtrusion();
        }
        else if (tWindowType == WindowTypeEnum.Edge)
        {
            DoEdgeObject();
        }
        else if (tWindowType == WindowTypeEnum.BridgeWizard)
        {
            DoBridge();
        }

        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 12
0
    public void Initialize(ref Rect _rect, WindowTypeEnum _windowType, GSDSplineN _node, GSD.Roads.Splination.SplinatedMeshMaker _SMM = null, GSD.Roads.EdgeObjects.EdgeObjectMaker _EOM = null)
    {
        int   Rheight = 300;
        int   Rwidth  = 360;
        float Rx      = ((float)_rect.width / 2f) - ((float)Rwidth / 2f) + _rect.x;
        float Ry      = ((float)_rect.height / 2f) - ((float)Rheight / 2f) + _rect.y;

        if (Rx < 0)
        {
            Rx = _rect.x;
        }
        if (Ry < 0)
        {
            Ry = _rect.y;
        }
        if (Rx > (_rect.width + _rect.x))
        {
            Rx = _rect.x;
        }
        if (Ry > (_rect.height + _rect.y))
        {
            Ry = _rect.y;
        }

        Rect fRect = new Rect(Rx, Ry, Rwidth, Rheight);

        if (fRect.width < 300)
        {
            fRect.width = 300;
            fRect.x     = _rect.x;
        }
        if (fRect.height < 300)
        {
            fRect.height = 300;
            fRect.y      = _rect.y;
        }

        position    = fRect;
        tWindowType = _windowType;
        Show();
        titleContent.text = "Save";
        if (tWindowType == WindowTypeEnum.Extrusion)
        {
            titleText = "Save extrusion";
            tSMMs     = new GSD.Roads.Splination.SplinatedMeshMaker[1];
            tSMMs[0]  = _SMM;
            if (_SMM != null)
            {
                fileName    = _SMM.tName;
                displayName = fileName;
            }
        }
        else if (tWindowType == WindowTypeEnum.Edge)
        {
            titleText = "Save edge object";
            tEOMs     = new GSD.Roads.EdgeObjects.EdgeObjectMaker[1];
            tEOMs[0]  = _EOM;
            if (_EOM != null)
            {
                fileName    = _EOM.tName;
                displayName = fileName;
            }
        }
        else if (tWindowType == WindowTypeEnum.BridgeWizard)
        {
            isBridge    = true;
            tSMMs       = _node.SplinatedObjects.ToArray();
            tEOMs       = _node.EdgeObjects.ToArray();
            titleText   = "Save group";
            fileName    = "Group" + Random.Range(0, 10000).ToString();
            displayName = fileName;
        }

        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        if (tWindowType == WindowTypeEnum.Edge)
        {
            if (System.IO.File.Exists(xPath + "EOM" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
        else if (tWindowType == WindowTypeEnum.Extrusion)
        {
            if (System.IO.File.Exists(xPath + "ESO" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
        else
        {
            if (System.IO.File.Exists(xPath + "B/" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
    }
Ejemplo n.º 13
0
    private void LoadObjs(ref string[] tNames, ref string[] tPaths, bool bIsDefault = false)
    {
        int    tCount       = tNames.Length;
        string tPath        = "";
        string tStringPath  = "";
        string tDesc        = "";
        string tDisplayName = "";
        string ThumbString  = "";
        bool   bIsBridge    = false;

        for (int i = 0; i < tCount; i++)
        {
            bIsBridge = false;
            tPath     = tPaths[i];

            if (tWindowType == WindowTypeEnum.Extrusion)
            {
                SplinatedMeshMaker.SplinatedMeshLibraryMaker SLM = (SplinatedMeshMaker.SplinatedMeshLibraryMaker)GSDRootUtil.LoadXML <SplinatedMeshMaker.SplinatedMeshLibraryMaker>(ref tPath);
                if (SLM == null)
                {
                    continue;
                }
                tStringPath  = SLM.CurrentSplinationString;
                tDesc        = SLM.Desc;
                tDisplayName = SLM.DisplayName;
                ThumbString  = SLM.ThumbString;
                bIsBridge    = SLM.bIsBridge;
            }
            else if (tWindowType == WindowTypeEnum.Edge)
            {
                EdgeObjectMaker.EdgeObjectLibraryMaker ELM = (EdgeObjectMaker.EdgeObjectLibraryMaker)GSDRootUtil.LoadXML <EdgeObjectMaker.EdgeObjectLibraryMaker>(ref tPath);
                if (ELM == null)
                {
                    continue;
                }
                tStringPath  = ELM.EdgeObjectString;
                tDesc        = ELM.Desc;
                tDisplayName = ELM.DisplayName;
                ThumbString  = ELM.ThumbString;
                bIsBridge    = ELM.bIsBridge;
            }

            //Don't continue if bridge pieces and this is not a bridge piece:
            if (tWindowType == WindowTypeEnum.Extrusion && bIsBridge)
            {
                continue;
            }

            GSDRoadUtil.WizardObject tO = new GSDRoadUtil.WizardObject();
            try{
                tO.Thumb = (Texture2D)AssetDatabase.LoadAssetAtPath(ThumbString, typeof(Texture2D)) as Texture2D;
            }catch {
                tO.Thumb = null;
            }
            if (tO.Thumb == null)
            {
                try{
                    GameObject xObj = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tStringPath, typeof(GameObject)) as GameObject;
                    tO.Thumb = AssetPreview.GetAssetPreview(xObj);
                }catch {
                    tO.Thumb = null;
                }
            }
            tO.DisplayName = tDisplayName;
            tO.FileName    = tNames[i];
            tO.FullPath    = tPath;
            tO.Desc        = tDesc;
            tO.bIsDefault  = bIsDefault;

            if (bIsDefault && tWindowType == WindowTypeEnum.Edge)
            {
                if (tO.DisplayName.Contains("GSDAtten"))
                {
                    tO.DisplayName = "Attenuator";
                    tO.Desc        = "Standard double WBeam with impact absorption.";
                }
                else if (tO.DisplayName.Contains("GSDGreenBlinder"))
                {
                    tO.DisplayName = "KRail Blinder";
                    tO.Desc        = "Best results when placed on KRail for KRail blinders.";
                    tO.sortID      = 5;
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrelStatic"))
                {
                    tO.DisplayName = "Sand Barrel Static";
                    tO.Desc        = "One static sand barrel. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrelRigid"))
                {
                    tO.DisplayName = "Sand Barrel Rigid";
                    tO.Desc        = "One rigid sand barrel. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrel3Static"))
                {
                    tO.DisplayName = "Sand Barrels Static 3";
                    tO.Desc        = "Three static sand barrels in a line. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrel3Rigid"))
                {
                    tO.DisplayName = "Sand Barrels Rigid 3";
                    tO.Desc        = "Three rigid sand barrels in a line. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrel7Static"))
                {
                    tO.DisplayName = "Sand Barrels Static 7";
                    tO.Desc        = "Seven static sand barrels in standard formation. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadBarrel7Rigid"))
                {
                    tO.DisplayName = "Sand Barrel Rigid 7";
                    tO.Desc        = "Seven rigid sand barrels in standard formation. Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDRoadConBarrelStatic"))
                {
                    tO.DisplayName = "Con Barrels Static";
                    tO.Desc        = "Static road construction barrels.";
                    tO.sortID      = 3;
                }
                else if (tO.DisplayName.Contains("GSDRoadConBarrelRigid"))
                {
                    tO.DisplayName = "Con Barrels Rigid";
                    tO.Desc        = "Rigid road construction barrels.";
                    tO.sortID      = 3;
                }
                else if (tO.DisplayName.Contains("GSDTrafficConeStatic"))
                {
                    tO.DisplayName = "Traffic cones Static";
                    tO.Desc        = "Static traffic cones.";
                    tO.sortID      = 4;
                }
                else if (tO.DisplayName.Contains("GSDTrafficConeRigid"))
                {
                    tO.DisplayName = "Traffic cones Rigid";
                    tO.Desc        = "Rigid traffic cones.";
                    tO.sortID      = 4;
                }
                else if (tO.DisplayName.Contains("GSDRoadReflector"))
                {
                    tO.DisplayName = "Road reflectors";
                    tO.Desc        = "Placed one center line of road for center line reflection.";
                    tO.sortID      = 4;
                }
                else if (tO.DisplayName.Contains("GSDStopSign"))
                {
                    tO.DisplayName = "Stop sign";
                    tO.Desc        = "Standard specification non-interstate stop sign.";
                }
                else if (tO.DisplayName.Contains("GSDStreetLightSingle"))
                {
                    tO.DisplayName = "Streetlight Singlesided";
                    tO.Desc        = "Best used on side of roads.";
                }
                else if (tO.DisplayName.Contains("GSDStreetLightDouble"))
                {
                    tO.DisplayName = "Streetlight Doublesided";
                    tO.Desc        = "Best results when embedded in KRail in centerline of road.";
                }
                else if (tO.DisplayName.Contains("GSDWarningSign1"))
                {
                    tO.DisplayName = "Warning Sign #1";
                    tO.Desc        = "Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDWarningSign2"))
                {
                    tO.DisplayName = "Warning Sign #2";
                    tO.Desc        = "Best results when placed in front of railings or bridges.";
                }
                else if (tO.DisplayName.Contains("GSDSignRightTurnOnly"))
                {
                    tO.DisplayName = "Right turn only";
                    tO.Desc        = "Best results when placed near intersection right turn lane.";
                    tO.sortID      = 4;
                }

                else if (tO.DisplayName.Contains("GSDSign330"))
                {
                    tO.DisplayName = "Signs 330";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-330\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign396"))
                {
                    tO.DisplayName = "Signs 396";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-396\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign617-Small"))
                {
                    tO.DisplayName = "Signs 617 small";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign617"))
                {
                    tO.DisplayName = "Signs 617";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign861-Small"))
                {
                    tO.DisplayName = "Signs 861 small";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign861"))
                {
                    tO.DisplayName = "Sign type 861";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign988-Small"))
                {
                    tO.DisplayName = "Signs 988 small";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSign988"))
                {
                    tO.DisplayName = "Signs 988";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSignDiamond"))
                {
                    tO.DisplayName = "Signs diamond";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-diamond\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSignSquare-Small"))
                {
                    tO.DisplayName = "Signs square small";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
                    tO.sortID      = 21;
                }
                else if (tO.DisplayName.Contains("GSDSignSquare"))
                {
                    tO.DisplayName = "Signs square";
                    tO.Desc        = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
                    tO.sortID      = 21;
                }
            }

            if (bIsDefault && tWindowType == WindowTypeEnum.Extrusion)
            {
                if (tO.DisplayName.Contains("GSDKRail"))
                {
                    tO.DisplayName = "KRail";
                    tO.Desc        = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with down ends.";
                }
                else if (tO.DisplayName.Contains("GSDKRailCurvedR"))
                {
                    tO.DisplayName = "KRail Curved Right";
                    tO.Desc        = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for right shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDKRailCurvedL"))
                {
                    tO.DisplayName = "KRail Curved Left";
                    tO.Desc        = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for left shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDWBeam1R"))
                {
                    tO.DisplayName = "WBeam Wood Right";
                    tO.Desc        = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDWBeam1L"))
                {
                    tO.DisplayName = "WBeam Wood Left";
                    tO.Desc        = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDWBeam2R"))
                {
                    tO.DisplayName = "WBeam Metal Right";
                    tO.Desc        = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDWBeam2L"))
                {
                    tO.DisplayName = "WBeam Metal Left";
                    tO.Desc        = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDRailing1"))
                {
                    tO.DisplayName = "Railing #1";
                    tO.Desc        = "Standard double square pole railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing2"))
                {
                    tO.DisplayName = "Railing #2";
                    tO.Desc        = "Standard concrete big block railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing3"))
                {
                    tO.DisplayName = "Railing #3";
                    tO.Desc        = "Standard four-strand metal railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing5"))
                {
                    tO.DisplayName = "Railing #5";
                    tO.Desc        = "Basic concrete railing with pylons.";
                }
                else if (tO.DisplayName.Contains("GSDRailing6"))
                {
                    tO.DisplayName = "Railing #6";
                    tO.Desc        = "Standard two-strand metal pole railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing7"))
                {
                    tO.DisplayName = "Railing #7";
                    tO.Desc        = "Rock-decorated concrete railing with pylons and double strand rusted look metal railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing8"))
                {
                    tO.DisplayName = "Railing #8";
                    tO.Desc        = "Rock-decorated concrete railing with standard single pole metal railing.";
                }
                else if (tO.DisplayName.Contains("GSDRailing9"))
                {
                    tO.DisplayName = "Railing #9";
                    tO.Desc        = "Very low poly railing used for mobile.";
                }
                else if (tO.DisplayName.Contains("GSDSidewalk"))
                {
                    tO.DisplayName = "Sidewalk";
                    tO.Desc        = "Sidewalk.";
                }
                else if (tO.DisplayName.Contains("GSDRumbleStrip"))
                {
                    tO.DisplayName = "Rumblestrip";
                    tO.Desc        = "State spec rumblestrip. For best results place several cm from road edge into shoulder.";
                }
                else if (tO.DisplayName.Contains("GSDRailing4R"))
                {
                    tO.DisplayName = "Railing #4 Right";
                    tO.Desc        = "Three bar angled pole railing. Right side of road.";
                }
                else if (tO.DisplayName.Contains("GSDRailing4L"))
                {
                    tO.DisplayName = "Railing #4 Left";
                    tO.Desc        = "Three bar angled pole railing. Left side of road.";
                }
                else if (tO.DisplayName.Contains("GSDRailing4-LightR"))
                {
                    tO.DisplayName = "Railing #4 Light Right";
                    tO.Desc        = "Three bar angled pole railing. Right side of road. Light version with fewer triangle count.";
                }
                else if (tO.DisplayName.Contains("GSDRailing4-LightL"))
                {
                    tO.DisplayName = "Railing #4 Light Left";
                    tO.Desc        = "Three bar angled pole railing. Left side of road. Light version with fewer triangle count.";
                }
                else if (tO.DisplayName.Contains("GSDRailingBase1"))
                {
                    tO.DisplayName = "Railing base #1";
                    tO.Desc        = "Use as a base on other railings to create more detail.";
                }
                else if (tO.DisplayName.Contains("GSDRailingBase2"))
                {
                    tO.DisplayName = "Railing base #2";
                    tO.Desc        = "Use as a base on other railings to create more detail.";
                }
                else if (tO.DisplayName.Contains("GSDCableBarrier-Light"))
                {
                    tO.DisplayName = "Cable barrier 10m";
                    tO.Desc        = "Cable barrier 10m light triangle version. Best used as center divider or as railing barriers.";
                    tO.sortID      = 20;
                }
                else if (tO.DisplayName.Contains("GSDCableBarrier"))
                {
                    tO.DisplayName = "Cable barrier 5m";
                    tO.Desc        = "Cable barrier 5m. Best used as center divider or as railing barriers.";
                    tO.sortID      = 20;
                }
            }

            oList.Add(tO);
        }
        oListSort();
    }
Ejemplo n.º 14
0
    public static void GetGroupListing(out string[] tNames, out string[] tPaths, int Lanes, bool bIsDefault = false)
    {
        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        string LaneText = "-2L";

        if (Lanes == 4)
        {
            LaneText = "-4L";
        }
        else if (Lanes == 6)
        {
            LaneText = "-6L";
        }

        tNames = null;
        tPaths = null;
        DirectoryInfo info;

        if (bIsDefault)
        {
            info = new DirectoryInfo(xPath + "B/W/");
        }
        else
        {
            info = new DirectoryInfo(xPath + "B/");
        }

        FileInfo[] fileInfo = info.GetFiles();
        int        tCount   = 0;

        foreach (FileInfo tInfo in fileInfo)
        {
            if (tInfo.Extension.ToLower().Contains("gsd"))
            {
                if (!bIsDefault)
                {
                    tCount += 1;
                }
                else
                {
                    if (tInfo.Name.Contains(LaneText))
                    {
                        tCount += 1;
                    }
                }
            }
        }

        tNames = new string[tCount];
        tPaths = new string[tCount];
        tCount = 0;
        foreach (FileInfo tInfo in fileInfo)
        {
            if (tInfo.Extension.ToLower().Contains("gsd"))
            {
                if (!bIsDefault)
                {
                    tNames[tCount] = tInfo.Name.Replace(".gsd", "");
                    tPaths[tCount] = tInfo.FullName;
                    tCount        += 1;
                }
                else
                {
                    if (tInfo.Name.Contains(LaneText))
                    {
                        tNames[tCount] = tInfo.Name.Replace(".gsd", "");
                        tPaths[tCount] = tInfo.FullName;
                        tCount        += 1;
                    }
                }
            }
        }
    }
Ejemplo n.º 15
0
        private void SetupLocations()
        {
            float OrigHeight = 0f;

            StartTime = tNode.GSDSpline.GetClosestParam(StartPos);
            EndTime   = tNode.GSDSpline.GetClosestParam(EndPos);

            float FakeStartTime = StartTime;

            if (bStartMatchRoadDefinition)
            {
                int   tIndex = tNode.GSDSpline.GetClosestRoadDefIndex(StartTime, false, true);
                float jTime1 = tNode.GSDSpline.TranslateInverseParamToFloat(tNode.GSDSpline.RoadDefKeysArray[tIndex]);
                float jTime2 = jTime1;
                if (tIndex + 1 < tNode.GSDSpline.RoadDefKeysArray.Length)
                {
                    jTime2 = tNode.GSDSpline.TranslateInverseParamToFloat(tNode.GSDSpline.RoadDefKeysArray[tIndex + 1]);
                }
                FakeStartTime = jTime1 + ((jTime2 - jTime1) * StartMatchRoadDef);
            }


//			int eCount = EdgeObjects.Count;
//			Vector3 rVect = default(Vector3);
//			Vector3 lVect = default(Vector3);
//			float fTimeMax = -1f;
            int mCount = tNode.GSDSpline.GetNodeCount();

            if (tNode.idOnSpline >= mCount - 1)
            {
                return;
            }
//			fTimeMax = tNode.GSDSpline.mNodes[tNode.idOnSpline+1].tTime;
//			float tStep = -1f;
            Vector3 tVect = default(Vector3);
            Vector3 POS   = default(Vector3);

//			tStep = MeterSep/tNode.GSDSpline.distance;
            //Destroy old objects:
            ClearEOM();
            //Make sure old locs and rots are fresh:
            if (EdgeObjectLocations != null)
            {
                EdgeObjectLocations.Clear(); EdgeObjectLocations = null;
            }
            EdgeObjectLocations = new List <Vector3>();
            if (EdgeObjectRotations != null)
            {
                EdgeObjectRotations.Clear(); EdgeObjectRotations = null;
            }
            EdgeObjectRotations = new List <Vector3>();
            bool bIsCenter = GSDRootUtil.IsApproximately(HorizontalSep, 0f, 0.02f);


            //Set rotation and locations:
//			Vector2 temp2DVect = default(Vector2);
            Ray tRay = default(Ray);

            RaycastHit[] tRayHit = null;
            float[]      tRayYs  = null;
            if (bSingle)
            {
                tNode.GSDSpline.GetSplineValue_Both(SinglePosition, out tVect, out POS);
                OrigHeight = tVect.y;

                //Horizontal offset:
                if (!bIsCenter)
                {
//					if(HorizontalSep > 0f){
                    tVect = (tVect + new Vector3(HorizontalSep * POS.normalized.z, 0, HorizontalSep * -POS.normalized.x));
//					}else{
//						tVect = (tVect + new Vector3(HorizontalSep*-POS.normalized.z,0,HorizontalSep*POS.normalized.x));
//					}
                }



                //Vertical:
                if (bMatchTerrain)
                {
                    tRay    = new Ray(tVect + new Vector3(0f, 1f, 0f), Vector3.down);
                    tRayHit = Physics.RaycastAll(tRay);
                    if (tRayHit.Length > 0)
                    {
                        tRayYs = new float[tRayHit.Length];
                        for (int g = 0; g < tRayHit.Length; g++)
                        {
                            tRayYs[g] = tRayHit[g].point.y;
                        }
                        tVect.y = Mathf.Max(tRayYs);
                    }
                }
                tVect.y += VerticalRaise;

                StartPos = tVect;
                EndPos   = tVect;

                if (float.IsNaN(tVect.y))
                {
                    tVect.y = OrigHeight;
                }

                EdgeObjectLocations.Add(tVect);
                EdgeObjectRotations.Add(POS);
            }
            else
            {
                //Get the vector series that this mesh is interpolated on:
                List <float> tTimes = new List <float>();
                float        cTime  = FakeStartTime;
                tTimes.Add(cTime);
                int     SpamGuard        = 5000;
                int     SpamGuardCounter = 0;
                float   pDiffTime        = EndTime - FakeStartTime;
                float   CurrentH         = 0f;
                float   fHeight          = 0f;
                Vector3 xVect            = default(Vector3);
                while (cTime < EndTime && SpamGuardCounter < SpamGuard)
                {
                    tNode.GSDSpline.GetSplineValue_Both(cTime, out tVect, out POS);

                    fHeight  = HorizontalCurve.Evaluate((cTime - FakeStartTime) / pDiffTime);
                    CurrentH = fHeight * HorizontalSep;

                    if (CurrentH < 0f)
                    {
                        CurrentH *= -1f;
                        tVect     = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
                    }
                    else if (CurrentH > 0f)
                    {
                        tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
                    }

                    xVect = (POS.normalized * MeterSep) + tVect;

                    cTime = tNode.GSDSpline.GetClosestParam(xVect, false, false);

                    if (cTime > EndTime)
                    {
                        break;
                    }
                    tTimes.Add(cTime);
                    SpamGuardCounter += 1;
                }
                int vSeriesCount = tTimes.Count;

                float mMin     = FakeStartTime;
                float mMax     = EndTime;
                float tPercent = 0;
                for (int i = 0; i < vSeriesCount; i++)
                {
                    tNode.GSDSpline.GetSplineValue_Both(tTimes[i], out tVect, out POS);

                    tPercent = ((tTimes[i] - mMin) / (mMax - mMin));

                    //Horiz:
                    CurrentH = (HorizontalCurve.Evaluate(tPercent) * HorizontalSep);
                    if (CurrentH < 0f)
                    {
                        CurrentH *= -1f;
                        tVect     = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
                    }
                    else if (CurrentH > 0f)
                    {
                        tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
                    }

                    //Vertical:
                    if (bMatchTerrain)
                    {
                        tRay    = new Ray(tVect + new Vector3(0f, 1f, 0f), Vector3.down);
                        tRayHit = Physics.RaycastAll(tRay);
                        if (tRayHit.Length > 0)
                        {
                            tRayYs = new float[tRayHit.Length];
                            for (int g = 0; g < tRayHit.Length; g++)
                            {
                                tRayYs[g] = tRayHit[g].point.y;
                            }
                            tVect.y = Mathf.Max(tRayYs);
                        }
                    }

                    tVect.y += (VerticalCurve.Evaluate(tPercent) * VerticalRaise);

                    EdgeObjectLocations.Add(tVect);
                    EdgeObjectRotations.Add(POS);
                }
                StartPos = tNode.GSDSpline.GetSplineValue(StartTime);
                EndPos   = tNode.GSDSpline.GetSplineValue(EndTime);
            }
        }
Ejemplo n.º 16
0
        private void Setup_Do(bool bCollect, ref List <GameObject> tErrorObjs)
        {
                        #if UNITY_EDITOR
            if (EdgeObjects == null)
            {
                EdgeObjects = new List <GameObject>();
            }
            if (HorizontalCurve == null)
            {
                HorizontalCurve = new AnimationCurve();
                HorizontalCurve.AddKey(0f, 1f);
                HorizontalCurve.AddKey(1f, 1f);
            }
            if (VerticalCurve == null)
            {
                VerticalCurve = new AnimationCurve();
                VerticalCurve.AddKey(0f, 1f);
                VerticalCurve.AddKey(1f, 1f);
            }

            SetupUniqueIdentifier();

            SetupLocations();
            EdgeObjectString = GSDRootUtil.GetPrefabString(EdgeObject);
            if (EdgeMaterial1 != null)
            {
                EdgeMaterial1String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial1);
            }
            if (EdgeMaterial2 != null)
            {
                EdgeMaterial2String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial2);
            }
            EdgeObjects = new List <GameObject>();

            Quaternion xRot = default(Quaternion);
            xRot             = Quaternion.identity;
            xRot.eulerAngles = CustomRotation;
            int lCount = EdgeObjectLocations.Count;
//			Quaternion OrigRot = Quaternion.identity;
            Material[] tMats = null;
            GameObject tObj  = null;
            if (EdgeObject != null)
            {
                GameObject mObj = new GameObject(EdgeObject.name);
                MasterObj = mObj;
                tErrorObjs.Add(MasterObj);
                mObj.transform.position = tNode.transform.position;
                mObj.transform.parent   = tNode.transform;
                mObj.name = tName;
                MeshRenderer OrigMR = EdgeObject.GetComponent <MeshRenderer>();
                for (int j = 0; j < lCount; j++)
                {
                    if (EdgeObjectRotations[j] == default(Vector3))
                    {
                        tObj = (GameObject)GameObject.Instantiate(EdgeObject);
                        tErrorObjs.Add(tObj);
                        tObj.transform.position = EdgeObjectLocations[j];
                    }
                    else
                    {
                        tObj = (GameObject)GameObject.Instantiate(EdgeObject, EdgeObjectLocations[j], Quaternion.LookRotation(EdgeObjectRotations[j]));
                        tErrorObjs.Add(tObj);
                    }
//					OrigRot = tObj.transform.rotation;
                    tObj.transform.rotation *= xRot;
                    if (bOncomingRotation && SubType == GSD.Roads.SignPlacementSubTypeEnum.Left)
                    {
                        Quaternion tRot = new Quaternion(0f, 0f, 0f, 0f);
                        tRot                     = Quaternion.identity;
                        tRot.eulerAngles         = new Vector3(0f, 180f, 0f);
                        tObj.transform.rotation *= tRot;
                    }
                    tObj.isStatic         = bStatic;
                    tObj.transform.parent = mObj.transform;
                    EdgeObjects.Add(tObj);

                    MeshRenderer NewMR = tObj.GetComponent <MeshRenderer>();
                    if (NewMR == null)
                    {
                        NewMR = tObj.AddComponent <MeshRenderer>();
                    }

                    if (!bMaterialOverride && OrigMR != null && OrigMR.sharedMaterials.Length > 0 && NewMR != null)
                    {
                        NewMR.sharedMaterials = OrigMR.sharedMaterials;
                    }
                    else
                    {
                        if (EdgeMaterial1 != null)
                        {
                            if (EdgeMaterial2 != null)
                            {
                                tMats    = new Material[2];
                                tMats[0] = EdgeMaterial1;
                                tMats[1] = EdgeMaterial2;
                            }
                            else
                            {
                                tMats    = new Material[1];
                                tMats[0] = EdgeMaterial1;
                            }
                            NewMR.sharedMaterials = tMats;
                        }
                    }
                }
            }

            lCount = EdgeObjects.Count;
            if (lCount > 1 && bCombineMesh)
            {
                Material[] tMat        = null;
                Mesh       xMeshBuffer = null;
                xMeshBuffer = EdgeObject.GetComponent <MeshFilter>().sharedMesh;
                if (bMaterialOverride)
                {
                    if (EdgeMaterial1 != null)
                    {
                        if (EdgeMaterial2 != null)
                        {
                            tMat    = new Material[2];
                            tMat[0] = EdgeMaterial1;
                            tMat[1] = EdgeMaterial2;
                        }
                        else
                        {
                            tMat    = new Material[1];
                            tMat[0] = EdgeMaterial1;
                        }
                    }
                }
                else
                {
                    tMat = EdgeObject.GetComponent <MeshRenderer>().sharedMaterials;
                }

                Vector3[] kVerts       = xMeshBuffer.vertices;
                int[]     kTris        = xMeshBuffer.triangles;
                Vector2[] kUV          = xMeshBuffer.uv;
                int       OrigMVL      = kVerts.Length;
                int       OrigTriCount = xMeshBuffer.triangles.Length;

                List <Vector3[]> hVerts = new List <Vector3[]>();
                List <int[]>     hTris  = new List <int[]>();
                List <Vector2[]> hUV    = new List <Vector2[]>();


                Transform tTrans;
                for (int j = 0; j < lCount; j++)
                {
                    tTrans = EdgeObjects[j].transform;
                    hVerts.Add(new Vector3[OrigMVL]);
                    hTris.Add(new int[OrigTriCount]);
                    hUV.Add(new Vector2[OrigMVL]);

                    //Vertex copy:
                    System.Array.Copy(kVerts, hVerts[j], OrigMVL);
                    //Tri copy:
                    System.Array.Copy(kTris, hTris[j], OrigTriCount);
                    //UV copy:
                    System.Array.Copy(kUV, hUV[j], OrigMVL);

                    Vector3 tVect = default(Vector3);
                    for (int i = 0; i < OrigMVL; i++)
                    {
                        tVect         = hVerts[j][i];
                        hVerts[j][i]  = tTrans.rotation * tVect;
                        hVerts[j][i] += tTrans.localPosition;
                    }
                }

                GameObject   xObj = new GameObject(tName);
                MeshRenderer MR   = xObj.GetComponent <MeshRenderer>();
                if (MR == null)
                {
                    MR = xObj.AddComponent <MeshRenderer>();
                }
                xObj.isStatic         = bStatic;
                xObj.transform.parent = MasterObj.transform;
                tErrorObjs.Add(xObj);
                xObj.transform.name = xObj.transform.name + "Combined";
                xObj.transform.name = xObj.transform.name.Replace("(Clone)", "");
                MeshFilter MF = xObj.GetComponent <MeshFilter>();
                if (MF == null)
                {
                    MF = xObj.AddComponent <MeshFilter>();
                }
                MF.sharedMesh = GSDCombineMeshes(ref hVerts, ref hTris, ref hUV, OrigMVL, OrigTriCount);
                MeshCollider MC = xObj.GetComponent <MeshCollider>();
                if (MC == null)
                {
                    MC = xObj.AddComponent <MeshCollider>();
                }
                xObj.transform.position = tNode.transform.position;
                xObj.transform.rotation = Quaternion.identity;

                for (int j = (lCount - 1); j >= 0; j--)
                {
                    Object.DestroyImmediate(EdgeObjects[j]);
                }
                for (int j = 0; j < EdgeObjects.Count; j++)
                {
                    EdgeObjects[j] = null;
                }
                EdgeObjects.RemoveRange(0, lCount);
                EdgeObjects.Add(xObj);

                if (tMat != null && MR != null)
                {
                    MR.sharedMaterials = tMat;
                }

                BoxCollider BC = xObj.GetComponent <BoxCollider>();
                if (BC != null)
                {
                    Object.DestroyImmediate(BC);
                }
                int cCount = xObj.transform.childCount;
                int spamc  = 0;
                while (cCount > 0 && spamc < 10)
                {
                    Object.DestroyImmediate(xObj.transform.GetChild(0).gameObject);
                    cCount = xObj.transform.childCount;
                    spamc += 1;
                }

                if (bCombineMeshCollider)
                {
                    if (MC == null)
                    {
                        MC = xObj.AddComponent <MeshCollider>();
                    }
                    MC.sharedMesh = MF.sharedMesh;
                }
                else
                {
                    if (MC != null)
                    {
                        Object.DestroyImmediate(MC);
                        MC = null;
                    }
                }

                if (tNode.GSDSpline.tRoad.GSDRS.opt_bSaveMeshes && MF != null && bCombineMesh)
                {
                    SaveMesh(MF.sharedMesh, false);
                    if (MC != null)
                    {
                        if (MF.sharedMesh != MC.sharedMesh)
                        {
                            SaveMesh(MC.sharedMesh, true);
                        }
                    }
                }

//				tMesh = null;
            }

            //Zero these out, as they are not needed anymore:
            if (EdgeObjectLocations != null)
            {
                EdgeObjectLocations.Clear(); EdgeObjectLocations = null;
            }
            if (EdgeObjectRotations != null)
            {
                EdgeObjectRotations.Clear(); EdgeObjectRotations = null;
            }

            if (bCollect)
            {
                tNode.GSDSpline.tRoad.bTriggerGC = true;
            }
                        #endif
        }
Ejemplo n.º 17
0
            public bool IsEqual(EdgeObjectMaker EOM)
            {
                if (EOM.EdgeObject != EdgeObject)
                {
                    return(false);
                }
                if (EOM.bMaterialOverride != bMaterialOverride)
                {
                    return(false);
                }
                if (EOM.EdgeMaterial1 != EdgeMaterial1)
                {
                    return(false);
                }
                if (EOM.EdgeMaterial2 != EdgeMaterial2)
                {
                    return(false);
                }

                if (EOM.bCombineMesh != bCombineMesh)
                {
                    return(false);
                }
                if (EOM.bCombineMeshCollider != bCombineMeshCollider)
                {
                    return(false);
                }
                if (EOM.SubType != SubType)
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.MeterSep, MeterSep, 0.001f))
                {
                    return(false);
                }
//				if(EOM.bToggle != bToggle){ return false; }

                if (!GSDRootUtil.IsApproximately(EOM.HorizontalSep, HorizontalSep, 0.001f))
                {
                    return(false);
                }
                if (EOM.HorizontalCurve != HorizontalCurve)
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.VerticalRaise, VerticalRaise, 0.001f))
                {
                    return(false);
                }
                if (EOM.VerticalCurve != VerticalCurve)
                {
                    return(false);
                }
                if (EOM.bMatchTerrain != bMatchTerrain)
                {
                    return(false);
                }

                if (EOM.CustomRotation != CustomRotation)
                {
                    return(false);
                }
                if (EOM.bOncomingRotation != bOncomingRotation)
                {
                    return(false);
                }
                if (EOM.bStatic != bStatic)
                {
                    return(false);
                }
                if (EOM.bSingle != bSingle)
                {
                    return(false);
                }

                if (!GSDRootUtil.IsApproximately(EOM.SinglePosition, SinglePosition, 0.001f))
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.StartTime, StartTime, 0.001f))
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.EndTime, EndTime, 0.001f))
                {
                    return(false);
                }
                if (EOM.tName != tName)
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.SingleOnlyBridgePercent, SingleOnlyBridgePercent, 0.001f))
                {
                    return(false);
                }
                if (EOM.bStartMatchRoadDefinition != bStartMatchRoadDefinition)
                {
                    return(false);
                }
                if (!GSDRootUtil.IsApproximately(EOM.StartMatchRoadDef, StartMatchRoadDef, 0.001f))
                {
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 18
0
        /// <summary>
        /// Use this to insert nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
        /// </summary>
        /// <param name="RS">The road system to insert nodes in.</param>
        /// <param name="NodeLocation">The location of the newly inserted node.</param>
        /// <returns></returns>
        public static GSDSplineN InsertNode_Programmatically(GSDRoad RS, Vector3 NodeLocation)
        {
            GameObject tNodeObj;

            Object[] tWorldNodeCount = GameObject.FindObjectsOfType(typeof(GSDSplineN));
            tNodeObj = new GameObject("Node" + tWorldNodeCount.Length.ToString());

            //Set node location:
            if (NodeLocation.y < 0.03f)
            {
                NodeLocation.y = 0.03f;
            }                                                           //Make sure it doesn't try to create a node below 0 height.
            tNodeObj.transform.position = NodeLocation;

            //Set the node's parent:
            tNodeObj.transform.parent = RS.GSDSplineObj.transform;

            int cCount = RS.GSDSpline.mNodes.Count;

            //Get the closet param on spline:
            float tParam = RS.GSDSpline.GetClosestParam(NodeLocation, false, true);

            bool bEndInsert  = false;
            bool bZeroInsert = false;
            int  iStart      = 0;

            if (GSDRootUtil.IsApproximately(tParam, 0f, 0.0001f))
            {
                bZeroInsert = true;
                iStart      = 0;
            }
            else if (GSDRootUtil.IsApproximately(tParam, 1f, 0.0001f))
            {
                //Inserted at end, switch to create node instead:
                Object.DestroyImmediate(tNodeObj);
                return(CreateNode_Programmatically(RS, NodeLocation));
            }

            //Figure out where to insert the node:
            for (int i = 0; i < cCount; i++)
            {
                GSDSplineN xNode = RS.GSDSpline.mNodes[i];
                if (!bZeroInsert && !bEndInsert)
                {
                    if (tParam > xNode.tTime)
                    {
                        iStart = xNode.idOnSpline + 1;
                    }
                }
            }
            for (int i = iStart; i < cCount; i++)
            {
                RS.GSDSpline.mNodes[i].idOnSpline += 1;
            }

            GSDSplineN tNode = tNodeObj.AddComponent <GSDSplineN>();

            tNode.GSDSpline  = RS.GSDSpline;
            tNode.idOnSpline = iStart;
            tNode.pos        = NodeLocation;
            RS.GSDSpline.mNodes.Insert(iStart, tNode);

            //Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates
            RS.UpdateRoad();

            return(tNode);
        }