Exemple #1
0
        /// <summary>
        /// Make Slab GameObjects
        /// </summary>
        void MakeSlabObjs(StbSlabs stbSlabs)
        {
            int slabNum = 0;

            GameObject slabs   = new GameObject("StbSlabs");
            GameObject slabBar = new GameObject("StbSlabBar");

            slabs.transform.parent   = GameObject.Find("StbData").transform;
            slabBar.transform.parent = GameObject.Find("StbData").transform;

            foreach (var NodeIds in stbSlabs.NodeIdList)
            {
                int[] nodeIndex = new int[NodeIds.Count];
                Mesh  meshObj   = new Mesh();

                for (int i = 0; i < NodeIds.Count; i++)
                {
                    nodeIndex[i] = _nodes.Id.IndexOf(NodeIds[i]);
                }
                meshObj = CreateMesh.Slab(_nodes.Vertex, nodeIndex);

                var        slabName = string.Format("Slab{0}", slabNum);
                GameObject slab     = new GameObject(slabName);
                slab.AddComponent <MeshFilter>().mesh       = meshObj;
                slab.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Custom/CulloffSurfaceShader"))
                {
                    color = GetMemberColor("RC", "Slab")
                };
                slab.transform.localPosition = new Vector3(0, (float)stbSlabs.Level[slabNum], 0);
                slab.transform.parent        = slabs.transform;
                slabNum++;
            }
        }
Exemple #2
0
        static void Hoop(Vector3[,] cornerPos, float bandD, int index, GameObject parent)
        {
            // メッシュ結合用に親のオブジェクト作成
            var hoops = new GameObject("Hoops");

            hoops.transform.parent = parent.transform;

            float          pitch    = STBReader._secColumnRC.BarList[index][5] / 1000f;
            int            dirXNum  = STBReader._secColumnRC.BarList[index][6];
            int            dirYNum  = STBReader._secColumnRC.BarList[index][7];
            int            sumBar   = dirXNum + dirYNum;
            float          distance = Vector3.Distance(cornerPos[0, 0], cornerPos[1, 0]);
            List <Vector3> vertex   = new List <Vector3>();
            int            i        = 0;


            Vector3[,] hoopPos = GetBandPos(cornerPos, dirXNum, dirYNum);

            while ((pitch * i) / distance < 1)
            {
                for (int j = 0; j < 2 * sumBar; j++)
                {
                    vertex.Add(Vector3.Lerp(hoopPos[0, j], hoopPos[1, j], (float)(pitch * i) / distance));
                }
                for (int j = 0; j < sumBar; j++)
                {
                    Mesh       meshObj = CreateMesh.Pipe(vertex[2 * j + (i * 2 * sumBar)], vertex[2 * j + 1 + (i * 2 * sumBar)], bandD / 2f, 12, true);
                    GameObject element = new GameObject("hoop");
                    element.AddComponent <MeshFilter>().mesh       = meshObj;
                    element.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Standard"))
                    {
                        color = new Color(1, 0, 1, 1)
                    };
                    element.transform.parent = hoops.transform;
                }
                i++;
            }

            // ドローコール削減のため、作成したフープを一つのメッシュに結合
            var color = new Color(1, 0, 1, 1);

            CreateMesh.Conbine(hoops, color, "Standard");
        }
Exemple #3
0
        static void BeamMainBar(Vector3[,] main1Pos, Vector3[,] main2Pos, Vector3[,] main3Pos, float barSpace, float mainD, int index, GameObject parent)
        {
            // メッシュ結合用に親のオブジェクト作成
            var mainBars = new GameObject("MainBars");

            mainBars.transform.parent = parent.transform;

            int[]          mainBarNum = GetBeamMainNum(index);
            bool[]         hasMain    = new bool[6]; // {Main1_Top, Main1_bottom, Main2_Top, Main2_bottom, Main3_Top, Main3_bottom}
            float          distance   = Vector3.Distance(main1Pos[0, 1], main1Pos[0, 2]);
            int            barCount   = 0;
            List <Vector3> vertex     = new List <Vector3>();

            for (int i = 0; i < 5; i++)
            {
                if (mainBarNum[i] > 1)
                {
                    hasMain[i] = true;
                }
                else
                {
                    hasMain[i] = false;
                }
            }

            if (hasMain[0])
            {
                float posRatio = 1f / (mainBarNum[0] - 1);

                for (int j = 0; j < mainBarNum[0]; j++)
                {
                    vertex.Add(Vector3.Lerp(main1Pos[0, 1], main1Pos[0, 2], posRatio * j));
                    vertex.Add(Vector3.Lerp(main1Pos[1, 1], main1Pos[1, 2], posRatio * j));
                    barCount++;
                }
            }
            if (hasMain[1])
            {
                float posRatio = 1f / (mainBarNum[1] - 1);

                for (int j = 0; j < mainBarNum[1]; j++)
                {
                    vertex.Add(Vector3.Lerp(main1Pos[0, 3], main1Pos[0, 4], posRatio * j));
                    vertex.Add(Vector3.Lerp(main1Pos[1, 3], main1Pos[1, 4], posRatio * j));
                    barCount++;
                }
            }
            if (hasMain[2])
            {
                float posRatio = 1f / (mainBarNum[2] - 1);

                for (int j = 0; j < mainBarNum[2]; j++)
                {
                    vertex.Add(Vector3.Lerp(main2Pos[0, 1], main2Pos[0, 2], posRatio * j));
                    vertex.Add(Vector3.Lerp(main2Pos[1, 1], main2Pos[1, 2], posRatio * j));
                    barCount++;
                }
            }
            if (hasMain[3])
            {
                float posRatio = 1f / (mainBarNum[3] - 1);

                for (int j = 0; j < mainBarNum[3]; j++)
                {
                    vertex.Add(Vector3.Lerp(main2Pos[0, 3], main2Pos[0, 4], posRatio * j));
                    vertex.Add(Vector3.Lerp(main2Pos[1, 3], main2Pos[1, 4], posRatio * j));
                    barCount++;
                }
            }
            if (hasMain[4])
            {
                float posRatio = 1f / (mainBarNum[4] - 1);

                for (int j = 0; j < mainBarNum[4]; j++)
                {
                    vertex.Add(Vector3.Lerp(main3Pos[0, 1], main3Pos[0, 2], posRatio * j));
                    vertex.Add(Vector3.Lerp(main3Pos[1, 1], main3Pos[1, 2], posRatio * j));
                    barCount++;
                }
            }
            if (hasMain[5])
            {
                float posRatio = 1f / (mainBarNum[5] - 1);

                for (int j = 0; j < mainBarNum[5]; j++)
                {
                    vertex.Add(Vector3.Lerp(main3Pos[0, 3], main3Pos[0, 4], posRatio * j));
                    vertex.Add(Vector3.Lerp(main3Pos[1, 3], main3Pos[1, 4], posRatio * j));
                    barCount++;
                }
            }

            for (int i = 0; i < barCount; i++)
            {
                Mesh       meshObj = CreateMesh.Pipe(vertex[2 * i], vertex[2 * i + 1], mainD / 2f, 12, true);
                GameObject element = new GameObject("MainBar");
                element.AddComponent <MeshFilter>().mesh       = meshObj;
                element.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Standard"))
                {
                    color = new Color(0, 1, 0, 1)
                };
                element.transform.parent = mainBars.transform;
            }

            // ドローコール削減のため、作成したフープを一つのメッシュに結合
            var color = new Color(0, 1, 0, 1);

            CreateMesh.Conbine(mainBars, color, "Standard");
        }
Exemple #4
0
        static void ColumnMainBar(Vector3[,] mainPos, Vector3[,] mainX2Pos, Vector3[,] mainY2Pos, float barSpace, float mainD, int index, GameObject parent)
        {
            // メッシュ結合用に親のオブジェクト作成
            var mainBars = new GameObject("MainBars");

            mainBars.transform.parent = parent.transform;

            int[]  mainBarNum = GetColMainNum(index);
            bool[] hasMain2   = { false, false }; // {Main2_X, Main2_Y}
            if (mainBarNum[2] > 1)
            {
                hasMain2[0] = true;
            }
            if (mainBarNum[3] > 1)
            {
                hasMain2[1] = true;
            }

            for (int i = 1; i < 5; i++)
            {
                // コーナーの主筋
                Mesh       meshObj = CreateMesh.Pipe(mainPos[0, i], mainPos[1, i], mainD / 2f, 12, true);
                GameObject element = new GameObject("MainBar");
                element.AddComponent <MeshFilter>().mesh       = meshObj;
                element.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Standard"))
                {
                    color = new Color(1, 1, 0, 1)
                };
                element.transform.parent = mainBars.transform;
            }

            float          posX1Ratio = 1f / (mainBarNum[0] - 1);
            float          posY1Ratio = 1f / (mainBarNum[1] - 1);
            float          posX2Ratio = 1f / (mainBarNum[2] - 1);
            float          posY2Ratio = 1f / (mainBarNum[3] - 1);
            float          distanceX  = Vector3.Distance(mainPos[0, 1], mainPos[0, 2]);
            float          distanceY  = Vector3.Distance(mainPos[0, 2], mainPos[0, 3]);
            int            barCount   = 0;
            List <Vector3> vertex     = new List <Vector3>();

            if (hasMain2[1])
            {
                // 寄せ筋の作成
                vertex.Add(Vector3.Lerp(mainPos[0, 1], mainPos[0, 2], (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[1, 1], mainPos[1, 2], (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[0, 3], mainPos[0, 4], (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[1, 3], mainPos[1, 4], (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[0, 1], mainPos[0, 2], 1f - (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[1, 1], mainPos[1, 2], 1f - (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[0, 3], mainPos[0, 4], 1f - (barSpace + mainD) / distanceX));
                vertex.Add(Vector3.Lerp(mainPos[1, 3], mainPos[1, 4], 1f - (barSpace + mainD) / distanceX));
                barCount += 4;
                // 1st_X
                for (int j = 2; j <= mainBarNum[0] - 3; j++)
                {
                    vertex.Add(Vector3.Lerp(mainPos[0, 1], mainPos[0, 2], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 1], mainPos[1, 2], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[0, 3], mainPos[0, 4], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 3], mainPos[1, 4], posX1Ratio * j));
                    barCount += 2;
                }
                // 2nd_X
                for (int j = 1; j <= mainBarNum[2] - 2; j++)
                {
                    vertex.Add(Vector3.Lerp(mainX2Pos[0, 1], mainX2Pos[0, 2], posX2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainX2Pos[1, 1], mainX2Pos[1, 2], posX2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainX2Pos[0, 3], mainX2Pos[0, 4], posX2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainX2Pos[1, 3], mainX2Pos[1, 4], posX2Ratio * j));
                    barCount += 2;
                }
            }
            else
            {
                for (int j = 1; j <= mainBarNum[0] - 2; j++)
                {
                    vertex.Add(Vector3.Lerp(mainPos[0, 1], mainPos[0, 2], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 1], mainPos[1, 2], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[0, 3], mainPos[0, 4], posX1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 3], mainPos[1, 4], posX1Ratio * j));
                    barCount += 2;
                }
            }
            if (hasMain2[0])
            {
                // 寄せ筋の作成
                vertex.Add(Vector3.Lerp(mainPos[0, 2], mainPos[0, 3], (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[1, 2], mainPos[1, 3], (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[0, 4], mainPos[0, 1], (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[1, 4], mainPos[1, 1], (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[0, 2], mainPos[0, 3], 1f - (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[1, 2], mainPos[1, 3], 1f - (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[0, 4], mainPos[0, 1], 1f - (barSpace + mainD) / distanceY));
                vertex.Add(Vector3.Lerp(mainPos[1, 4], mainPos[1, 1], 1f - (barSpace + mainD) / distanceY));
                barCount += 4;
                // 1st_Y
                for (int j = 2; j <= mainBarNum[0] - 3; j++)
                {
                    vertex.Add(Vector3.Lerp(mainPos[0, 2], mainPos[0, 3], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 2], mainPos[1, 3], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[0, 4], mainPos[0, 1], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 4], mainPos[1, 1], posY1Ratio * j));
                    barCount += 2;
                }
                // 2nd_Y
                for (int j = 1; j <= mainBarNum[3] - 2; j++)
                {
                    vertex.Add(Vector3.Lerp(mainY2Pos[0, 2], mainY2Pos[0, 3], posY2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainY2Pos[1, 2], mainY2Pos[1, 3], posY2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainY2Pos[0, 4], mainY2Pos[0, 1], posY2Ratio * j));
                    vertex.Add(Vector3.Lerp(mainY2Pos[1, 4], mainY2Pos[1, 1], posY2Ratio * j));
                    barCount += 2;
                }
            }
            else
            {
                for (int j = 1; j <= mainBarNum[1] - 2; j++)
                {
                    vertex.Add(Vector3.Lerp(mainPos[0, 2], mainPos[0, 3], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 2], mainPos[1, 3], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[0, 4], mainPos[0, 1], posY1Ratio * j));
                    vertex.Add(Vector3.Lerp(mainPos[1, 4], mainPos[1, 1], posY1Ratio * j));
                    barCount += 2;
                }
            }
            for (int i = 0; i < barCount; i++)
            {
                Mesh       meshObj = CreateMesh.Pipe(vertex[2 * i], vertex[2 * i + 1], mainD / 2f, 12, true);
                GameObject element = new GameObject("mainBars");
                element.AddComponent <MeshFilter>().mesh       = meshObj;
                element.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Standard"))
                {
                    color = new Color(1, 1, 0, 1)
                };
                element.transform.parent = mainBars.transform;
            }

            // ドローコール削減のため、作成したフープを一つのメッシュに結合
            var color = new Color(1, 1, 0, 1);

            CreateMesh.Conbine(mainBars, color, "Standard");
        }
Exemple #5
0
        public List <Mesh> MakeElementsMeshFromVertex(Vector3 nodeStart, Vector3 nodeEnd, float hight, float width, string shapeType, string structType, int elementNum, GameObject elements, string kind)
        {
            Vector3[] vertexS = new Vector3[6];
            Vector3[] vertexE = new Vector3[6];
            Mesh      meshObj = new Mesh();

            float dx     = nodeEnd.x - nodeStart.x;
            float dy     = nodeEnd.y - nodeStart.y;
            float dz     = nodeEnd.z - nodeStart.z;
            float angleY = -1f * Mathf.Atan2(dy, dx);
            float angleZ = -1f * Mathf.Atan2(dz, dx);

            // 梁は部材天端の中心が起点に対して、柱・ブレースは部材芯が起点なので場合分け
            switch (structType)
            {
            case "Girder":
            case "Beam":
                vertexS = GetGirderVertex(nodeStart, width, hight, angleZ);
                vertexE = GetGirderVertex(nodeEnd, width, hight, angleZ);
                break;

            case "Column":
            case "Post":
                vertexS = GetColumnVertex(nodeStart, width, hight, angleY);
                vertexE = GetColumnVertex(nodeEnd, width, hight, angleY);
                break;

            case "Brace":
                vertexS = GetBraceVertex(nodeStart, width, hight, angleZ);
                vertexE = GetBraceVertex(nodeEnd, width, hight, angleZ);
                break;

            default: break;
            }
            switch (shapeType)
            {
            case "H":
                meshObj = CreateMesh.H(vertexS, vertexE); break;

            case "BOX":
                meshObj = CreateMesh.BOX(vertexS, vertexE); break;

            case "Pipe":
                meshObj = CreateMesh.Pipe(nodeStart, nodeEnd, width / 2); break;

            case "L":
                meshObj = CreateMesh.L(vertexS, vertexE); break;

            default: break;
            }

            string     name    = string.Format(structType + "{0}", elementNum);
            GameObject element = new GameObject(name);

            element.AddComponent <MeshFilter>().mesh       = meshObj;
            element.AddComponent <MeshRenderer>().material = new Material(Shader.Find("Custom/CulloffSurfaceShader"))
            {
                color = GetMemberColor(kind, structType)
            };
            element.transform.parent = elements.transform;

            return(_shapeMesh);
        }