예제 #1
0
    public string ExportTerritory()
    {
        string contents = "<\n";

        contents += "land:" + land.ToString() + "\n";

        contents += "position:" + MeshMaker.ExportVector(gameObject.transform.position) + "\n";

        string points = "points:";

        Vector3[] vertices = gameObject.GetComponent <MeshFilter> ().mesh.vertices;
        for (int i = 0; i < vertices.Length; i++)
        {
            Vector3 vertex = vertices[i];
            points += MeshMaker.ExportVector(vertex);
            if (i != vertices.Length - 1)
            {
                points += " ";
            }
        }

        contents += points + "\n";
        contents += ">\n";

        return(contents);
    }
예제 #2
0
    protected void InitMesh()
    {
        // Init Meshes and the Renderer
        SkinnedMeshRenderer renderer = this.gameObject.GetComponent <SkinnedMeshRenderer>();
        Mesh mesh = MeshMaker.Cylinder(width, length, segmentCount, meshSides);

        Vector3[]    vertices    = mesh.vertices;
        BoneWeight[] boneWeights = new BoneWeight[vertices.Length];
        Matrix4x4[]  bindPoses   = new Matrix4x4[segments.Length];

        for (int i = 0; i < boneWeights.Length; i++)
        {
            int id = Mathf.RoundToInt(-vertices[i].y / SegmentLength);
            boneWeights[i].boneIndex0 = id;
            boneWeights[i].weight0    = 1;
        }
        mesh.boneWeights = boneWeights;

        for (int i = 0; i < segments.Length; i++)
        {
            bindPoses[i] = segments[i].worldToLocalMatrix * transform.localToWorldMatrix;
        }


        mesh.bindposes      = bindPoses;
        renderer.bones      = segments;
        renderer.sharedMesh = mesh;

        renderer.localBounds = new Bounds(new Vector3(0, -length / 2, 0),
                                          new Vector3(width, length, width));

        renderer.allowOcclusionWhenDynamic = false;
        renderer.updateWhenOffscreen       = true;
        renderer.sharedMaterial            = material;
    }
        public void UpdateMesh()
        {
            //Debug.Log("updateMesh");
            //if (gameObject == null || _meshFilter == null) return;
            Vector3[] vects = Vects;
            Vector3   size  = Size;

            Vector3[] gapVects = new Vector3[4];
            for (int i = 0; i < 3; i++)
            {
                gapVects[i] = vects[i] * gap;
            }
            gapVects[3] = gapVects[0] + gapVects[1] + gapVects[2];


            Vector3[] magVects = new Vector3[3];
            for (int i = 0; i < 3; i++)
            {
                magVects[i] = (vects[i] * size[i]) - (gapVects[i] * 2);
            }

            Vector3[] pts = new Vector3[4];
            pts[0] = gapVects[3];
            pts[1] = pts[0] + magVects[0];
            pts[2] = pts[1] + magVects[2];
            pts[3] = pts[0] + magVects[2];

            Mesh mesh = MeshMaker.makeExtrusion(pts, magVects[1].magnitude);

            _meshFilter.mesh = mesh;
        }
예제 #4
0
        public void Test()
        {
            CadFigure baseFig = GetTargetFigure();

            if (baseFig == null)
            {
                return;
            }

            if (baseFig.Type != CadFigure.Types.POLY_LINES)
            {
                return;
            }

            (Vector3d p1, Vector3d p2) = InputLine();

            Vector3d org  = p1;
            Vector3d axis = (p2 - p1).Normalized();

            CadMesh cm = MeshMaker.CreateRotatingBody(32, org, axis, baseFig.PointList, false, false, MeshMaker.FaceType.QUADRANGLE);

            CadFigure fig = MesthToFig(cm);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig);

            Session.PostRemakeObjectTree();
        }
예제 #5
0
        public void MakeRotatingBody(uint baseFigID, Vector3d org, Vector3d axis, bool topCap, bool btmCap)
        {
            CadFigure baseFig = GetFigure(baseFigID);

            if (baseFig == null)
            {
                return;
            }

            if (baseFig.Type != CadFigure.Types.POLY_LINES)
            {
                return;
            }

            CadMesh cm = MeshMaker.CreateRotatingBody(32, org, axis, baseFig.PointList, topCap, btmCap, MeshMaker.FaceType.TRIANGLE);

            CadFigure fig = MesthToFig(cm);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig);

            ope = new CadOpeRemoveFigure(Controller.CurrentLayer, baseFig.ID);
            Session.AddOpe(ope);
            Controller.CurrentLayer.RemoveFigureByID(baseFig.ID);

            Session.PostRemakeObjectTree();
        }
예제 #6
0
    public string ExportNode()
    {
        string contents = "{\n";

        contents += "name:" + gameObject.name + "\n";
        contents += "position:" + MeshMaker.ExportVector(gameObject.transform.position) + "\n";
        contents += "unit:" + System.Enum.GetName(System.Type.GetType("UnitType"), unitNode.unitType) + "\n";
        contents += "unit-displace:" + MeshMaker.ExportVector(unitNode.gameObject.transform.position - gameObject.transform.position) + "\n";

        string slinks = "link-to:";

        foreach (CLink link in links)
        {
            CNode otherNode = link.nodes.Find(x => x != this);
            if (otherNode.GetType() == System.Type.GetType("CountryNode"))
            {
                CountryNode country = otherNode as CountryNode;
                slinks += country.country.countryName + "[" + country.country.nodes.IndexOf(country).ToString() + "]";

                if (links.IndexOf(link) != links.Count - 1)
                {
                    slinks += ",";
                }
                //e.g. Moscow[0] would be Moscow's base node - the number really only matters for coasts, which have multiple nodes
            }
        }

        slinks += "\n";

        contents += slinks;
        contents += "}\n";
        return(contents);
    }
예제 #7
0
    // Use this for initialization
    void Start()
    {
        Faction unowned = new Faction();

        unowned.factionName  = "Unowned";
        unowned.factionColor = new Color(208f / 255f, 164f / 255f, 80f / 255f);
        unowned.colorString  = MeshMaker.ColorToHex(unowned.factionColor);
        factions.Add(unowned);
    }
예제 #8
0
    /// <summary>
    /// 将场景中的屏幕坐标转换为世界坐标
    /// </summary>
    public static Vector3 ScreenToWorldPointInScene(this MeshMaker meshMaker, Camera sceneCamera, Vector3 screenPositon, Vector3 referencePosition)
    {
        Vector3 vec = screenPositon;

        vec.y = sceneCamera.pixelHeight - vec.y;
        vec.z = sceneCamera.worldToCameraMatrix.MultiplyPoint(referencePosition).z * -1;
        vec   = sceneCamera.ScreenToWorldPoint(vec);
        return(vec);
    }
예제 #9
0
    public string ExportFaction()
    {
        string contents = "{\n";

        contents += "name:" + factionName + "\n";
        contents += "factionColor:" + MeshMaker.ColorToHex(factionColor) + "\n";
        contents += "}\n";
        return(contents);
    }
예제 #10
0
    public void UpdateMesh(float[,] heightMap)
    {
        Init();
        meshDisplay.transform.position = new Vector3(
            heightMap.GetLength(0) * meshParams.vertSpacing / Defines.UnityUnitsToPixelRatio,
            heightMap.GetLength(1) * meshParams.vertSpacing / Defines.UnityUnitsToPixelRatio,
            0);

        filter.mesh = MeshMaker.ConstructMeshFrom(colorSteps, heightMap, meshParams);
    }
예제 #11
0
    private void Awake()
    {
        //setup singleton
        instance = this;

        //setup mesh
        mf      = GetComponent <MeshFilter>();
        m       = new Mesh();
        mf.mesh = m;
        mr      = GetComponent <MeshRenderer>();
    }
예제 #12
0
 public void Init(MeshMaker meshMaker)
 {
     _meshMaker = meshMaker;
     _texture   = _meshMaker._meshRenderer.sharedMaterial.GetTexture("_MainTex");
     if (!_texture)
     {
         _texture = AssetDatabase.LoadAssetAtPath("Assets/MeshEditor/MeshMaker/Editor/Texture/UVBg.png", typeof(Texture)) as Texture;
         _meshMaker._meshRenderer.sharedMaterial.SetTexture("_MainTex", _texture);
     }
     _amplification    = 400;
     _moveAmount       = 0.02f;
     _scaleAmount      = 10;
     _vertexButtonSize = 10;
     position          = new Rect(0, 0, _amplification, _amplification + 20);
 }
예제 #13
0
        public CadFigure AddCylinder(Vector3d pos, int circleDiv, int slices, double r, double len)
        {
            CadMesh cm = MeshMaker.CreateCylinder(pos, circleDiv, slices, r, len);

            CadFigure fig = MesthToFig(cm);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig);

            Session.PostRemakeObjectTree();

            return(fig);
        }
예제 #14
0
    public List <CNode> CClockwiseConnected()
    {
        List <CNode> connected = ConnectedTo();

        connected.Sort(delegate(CNode a, CNode b) {
            return((MeshMaker.GetCWAngle(gameObject.transform.position,
                                         gameObject.transform.position + Vector3.up,
                                         a.gameObject.transform.position)).CompareTo(
                       MeshMaker.GetCWAngle(gameObject.transform.position,
                                            gameObject.transform.position + Vector3.up,
                                            b.gameObject.transform.position)));
        });

        return(connected);
    }
예제 #15
0
        public CadFigure AddSphere(Vector3d pos, int slices, double r)
        {
            CadMesh cm = MeshMaker.CreateSphere(pos, r, slices, slices);

            CadFigure fig = MesthToFig(cm);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig);

            Session.PostRemakeObjectTree();

            return(fig);
        }
예제 #16
0
        /// <summary>
        /// <para>CreateMesh</para>
        /// Creates a Godot mesh instance using a Urdf
        /// defined Mesh geometry object.
        /// </summary>
        /// <param name="mesh">Urdf mesh object generated from a link.</param>
        /// <param name="mat">Optional material to apply to the mesh.</param>
        /// <returns>A Godot.Mesh representing the Urdf mesh data.</returns>
        private MeshInstance CreateMesh(
            Link.Geometry.Mesh mesh,
            SpatialMaterial mat = null)
        {
            string fileName = mesh.filename;

            fileName = GetFullPath(fileName);

            GD.Print(fileName);
            MeshMaker mmaker = new MeshMaker();

            var meshMat = (MeshInstance)mmaker.CreateMesh(fileName);

            return(meshMat);
        }
예제 #17
0
        public CadFigure AddOctahedron(Vector3d pos, double x, double y, double z)
        {
            CadMesh cm =
                MeshMaker.CreateOctahedron(pos, new Vector3d(x, y, z));

            CadFigure fig = MesthToFig(cm);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig);

            Session.PostRemakeObjectTree();

            return(fig);
        }
예제 #18
0
    private void DrawOuter(List <List <ShapePoint> > outerVerticies, bool closedLoop)
    {
        Mesh mesh = MeshMaker.ExtrudeShapeMeshAlongPath(outerVerticies, "outer", closedLoop, true);

        DestroyImmediate(GameObject.Find("Outer Edge"));
        GameObject piece = new GameObject("Outer Edge");

        piece.transform.SetParent(transform);
        piece.transform.position = transform.position;
        piece.AddComponent <MeshFilter>().sharedMesh = mesh;

        MeshRenderer rend = piece.AddComponent <MeshRenderer>();

        rend.sharedMaterial       = new Material(Shader.Find("Standard"));
        rend.sharedMaterial.color = Color.white;
    }
예제 #19
0
        private void test002()
        {
            CadMesh cm = MeshMaker.CreateSphere(new Vector3d(0, 0, 0), 20, 16, 16);

            HeModel hem = HeModelConverter.ToHeModel(cm);

            CadFigureMesh fig = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig.SetMesh(hem);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Controller.HistoryMan.foward(ope);
            Controller.CurrentLayer.AddFigure(fig);
            Controller.UpdateObjectTree(true);
        }
예제 #20
0
        public static (CadMesh m1, CadMesh m2) CutMeshWithVector(
            CadMesh src, Vector3d p0, Vector3d p1, Vector3d normal)
        {
            Vector3d wv = (p1 - p0).UnitVector();
            Vector3d hv = normal;

            CadMesh cubeA = MeshMaker.CreateUnitCube(wv, hv, MeshMaker.FaceType.QUADRANGLE);

            MoveMesh(cubeA, -hv / 2);
            ScaleMesh(cubeA, 10000);
            MoveMesh(cubeA, (p1 - p0) / 2 + p0);

            CadMesh cubeB = MeshMaker.CreateUnitCube(wv, hv, MeshMaker.FaceType.QUADRANGLE);

            MoveMesh(cubeB, hv / 2);
            ScaleMesh(cubeB, 10000);
            MoveMesh(cubeB, (p1 - p0) / 2 + p0);


            CadMesh m1;

            try
            {
                m1 = CarveW.AMinusB(src, cubeA);
            }
            catch (Exception e)
            {
                return(null, null);
            }

            MeshUtil.SplitAllFace(m1);

            CadMesh m2;

            try
            {
                m2 = CarveW.AMinusB(src, cubeB);
            }
            catch (Exception e)
            {
                return(null, null);
            }

            MeshUtil.SplitAllFace(m2);

            return(m1, m2);
        }
예제 #21
0
    public void GenerateRoadMesh(List <Vector3> evenPoints, string name, bool closedLoop)
    {
        //var roadInfo = GenerateTangentPointsFromPath(evenPoints, extrude, edgeWidth, thickness);

        if (name == "bottom")
        {
            firstRoad = evenPoints;
        }
        else if (name == "right")
        {
            secondRoad = evenPoints;
        }

        //Mesh mesh = MeshMaker.RoadMeshAlongPath(roadInfo.roadVerticies, name, closedLoop);

        //Make the road template... just 2 points on either side of the center point
        List <TemplatePoint> template = new List <TemplatePoint>();

        template.Add(new TemplatePoint(new Vector2(extrude / 2, 0), 0));
        template.Add(new TemplatePoint(new Vector2(-extrude / 2, 0), 1));

        Mesh mesh = MeshMaker.ExtrudeShapeAlongPath(evenPoints, template, "road", closedLoop, false);

        //GetComponent<MeshFilter>().sharedMesh = mesh;
        //GetComponent<MeshCollider>().sharedMesh = mesh;

        DestroyImmediate(GameObject.Find(name));
        GameObject road = new GameObject(name);

        road.transform.SetParent(transform);
        road.transform.position = transform.position;
        road.AddComponent <MeshFilter>().sharedMesh   = mesh;
        road.AddComponent <MeshCollider>().sharedMesh = mesh;

        MeshRenderer rend = road.AddComponent <MeshRenderer>();

        Material material = (Material)Resources.Load("URP Shaders/Shader Graphs_road", typeof(Material));

        rend.sharedMaterial       = material;
        rend.sharedMaterial.color = Color.white;

        if (drawEdges)
        {
            // DrawInner(roadInfo.innerVerticies, closedLoop);
            // DrawOuter(roadInfo.outerVerticies, closedLoop);
        }
    }
예제 #22
0
    public void GenerateMesh(List <Vector3> evenPoints)
    {
        var  info = MakeExitTest(evenPoints, extrude);
        Mesh mesh = MeshMaker.RoadMeshAlongPath(info, "exit", false);

        DestroyImmediate(GameObject.Find("exit"));
        GameObject exit = new GameObject("exit");

        exit.transform.SetParent(transform);
        exit.transform.position = transform.position;
        exit.AddComponent <MeshFilter>().sharedMesh = mesh;

        MeshRenderer rend = exit.AddComponent <MeshRenderer>();

        rend.sharedMaterial       = new Material(Shader.Find("Shader Graphs_road"));
        rend.sharedMaterial.color = Color.white;
    }
예제 #23
0
    IEnumerator NodeMove()
    {
        while (Input.GetMouseButton(1))
        {
            gameObject.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0f, 0f, 9f);
            yield return(null);
        }

        foreach (CountryNode node in parentCC.nodes)
        {
            if (node == this)
            {
                continue;
            }
            if (MeshMaker.GetDistance(node.gameObject.transform.position, gameObject.transform.position) <= nodeSize)
            {
                country.MergeInto(node.country);
                break;
            }
        }
    }
예제 #24
0
    void FixedUpdate()
    {
        if (lastModelForColliders != null)
        {
            int  inc = 5;
            bool b   = true;
            // print("LastIso: " + lastModelForColliders.isoCenter);
            // if (antiBakeCounter > 0) {
            // antiBakeCounter--;
            // return;
            // }

            if (lastModelForColliders.isoCenter != null)
            {
                b = AddColliders(lastModelForColliders, lastModelForCollidersCounter, inc);
                antiBakeCounter = antiBakeMax;
                lastModelForCollidersCounter += inc;
            }

            if (!b)
            {
                return;
            }
            lastModelForColliders.top.SetActive(true);
            // antiBakeCounter = 0;
            // UnityEngine.Debug.LogError("ISO TEST");
            // return;
            MeshMaker.FixPositions(lastModelForColliders.dimensions, lastModelForColliders.top);
            rotate = lastModelForColliders.top.transform;
            uic.UpdateUI();
            // sw.Stop();
            // printStopwatch(sw, "Update Model: ");
            loadingModelName             = "";
            loadingModel                 = false;
            loadingModelChange           = true;
            lastModelForColliders        = null;
            lastModelForCollidersCounter = 0;
            // UnityEngine.Debug.LogError("ISO TEST");
        }
    }
예제 #25
0
        // 押し出し
        public void Extrude(uint id, Vector3d v, double d, int divide)
        {
            CadFigure tfig = Controller.DB.GetFigure(id);

            if (tfig == null || tfig.Type != CadFigure.Types.POLY_LINES)
            {
                return;
            }

            v = v.UnitVector();

            v *= -d;

            CadMesh cm = MeshMaker.CreateExtruded(tfig.GetPoints(16), v, divide);

            HeModel hem = HeModelConverter.ToHeModel(cm);

            CadFigureMesh fig = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig.RecalcNormal();

            fig.SetMesh(hem);

            CadOpeList root = new CadOpeList();
            CadOpe     ope;

            ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);
            root.Add(ope);

            ope = new CadOpeRemoveFigure(Controller.CurrentLayer, tfig.ID);
            root.Add(ope);

            Session.AddOpe(root);

            Controller.CurrentLayer.AddFigure(fig);
            Controller.CurrentLayer.RemoveFigureByID(tfig.ID);

            Session.PostRemakeObjectTree();
        }
    //once triggered a new set of mesh locations will be genorated along with all
    //nessesry containers.
    public void launch()
    {
        if (!launched)
        {
            launched      = true;
            spline        = GetComponent <BezierSpline>();
            controlPoints = new List <GameObject>();
            setControlObjet();
            shapeHold = GameObject.Find("ScriptHolder").GetComponent <MeshMaker>();

            shapeHold.Begin();
            items[0] = shapeHold.pointPrefab;

            vertexPoints = new List <GameObject>();
            splinePoints = new Vector3[spline.points.Length];
            meshMap      = GetComponent <MeshManipulator>();


            identPos();
            runCreation();
        }
    }
예제 #27
0
        private void test003()
        {
            CadFigure tfig = GetTargetFigure();

            if (tfig == null || tfig.Type != CadFigure.Types.POLY_LINES)
            {
                return;
            }


            CadMesh cm = MeshMaker.CreateExtruded(tfig.GetPoints(16), Vector3d.UnitZ * -20);

            HeModel hem = HeModelConverter.ToHeModel(cm);

            CadFigureMesh fig = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig.SetMesh(hem);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Controller.HistoryMan.foward(ope);
            Controller.CurrentLayer.AddFigure(fig);
            Controller.UpdateObjectTree(true);
        }
예제 #28
0
 public Faction()
 {
     colorString = MeshMaker.ColorToHex(factionColor);
 }
예제 #29
0
    public void CreateIntersection(List <Vector3> roadA, List <Vector3> roadB, float width, int size)
    {
        debugPoints = new List <Vector3>();

        var firstList  = roadA;
        var secondList = roadB;

        int firstListIndex  = 0;
        int secondListIndex = 0;

        float distance = float.MaxValue;

        //For a curve, need to fine intersection with brute force
        for (int i = 0; i < firstList.Count; i++)
        {
            for (int j = 0; j < secondList.Count; j++)
            {
                var d = Vector3.Distance(firstList[i], secondList[j]);
                if (d < distance)
                {
                    firstListIndex  = i;
                    secondListIndex = j;
                    distance        = d;
                }
            }
        }

        connections = new List <List <Vector3> >();

        var firstListA = firstList.GetRange(0, firstListIndex);

        firstListA.Reverse();
        connections.Add(firstListA.Skip(size).ToList());
        var firstListB = firstList.GetRange(firstListIndex - 1, firstList.Count() - firstListIndex);

        connections.Add(firstListB.Skip(size).ToList());

        //var lineA1 = new Pair<Vector3>(firstListA.GetRoadPoint(size, -width / 2), firstListB.GetRoadPoint(size, width / 2));
        //var lineA2 = new Pair<Vector3>(firstListA.GetRoadPoint(size, width / 2), firstListB.GetRoadPoint(size, -width / 2));

        var secondListA = secondList.GetRange(0, secondListIndex);

        secondListA.Reverse();
        connections.Add(secondListA.Skip(size).ToList());
        var secondListB = secondList.GetRange(secondListIndex - 1, secondList.Count() - secondListIndex);

        connections.Add(secondListB.Skip(size).ToList());

        //var lineB1 = new Pair<Vector3>(secondListA.GetRoadPoint(size, -width / 2), secondListB.GetRoadPoint(size, width / 2));
        //var lineB2 = new Pair<Vector3>(secondListA.GetRoadPoint(size, width / 2), secondListB.GetRoadPoint(size, -width / 2));

        var side1 = new Pair <Vector3>(firstListA.GetRoadPoint(size, width / 2), firstListA.GetRoadPoint(size, -width / 2));
        var side3 = new Pair <Vector3>(firstListB.GetRoadPoint(size, width / 2), firstListB.GetRoadPoint(size, -width / 2));

        var side4 = new Pair <Vector3>(secondListA.GetRoadPoint(size, width / 2), secondListA.GetRoadPoint(size, -width / 2));
        var side2 = new Pair <Vector3>(secondListB.GetRoadPoint(size, width / 2), secondListB.GetRoadPoint(size, -width / 2));

        var outerPoints = new List <Pair <Vector3> >();

        outerPoints.Add(side1);

        //debugPoints.Add(side2.First);
        //debugPoints.Add(side4.Second);

        outerPoints.Add(side2);
        outerPoints.Add(side3);
        outerPoints.Add(side4);

        LineEquation line1 = new LineEquation(side1.First.To2D(), side3.Second.To2D());
        LineEquation line2 = new LineEquation(side1.Second.To2D(), side3.First.To2D());
        LineEquation line3 = new LineEquation(side2.First.To2D(), side4.Second.To2D());
        LineEquation line4 = new LineEquation(side2.Second.To2D(), side4.First.To2D());

        var innerPoints = new List <Vector3>();

        innerPoints.Add(line1.GetIntersectionWithLine(line3).Value.To3D());
        innerPoints.Add(line2.GetIntersectionWithLine(line3).Value.To3D());
        innerPoints.Add(line2.GetIntersectionWithLine(line4).Value.To3D());
        innerPoints.Add(line1.GetIntersectionWithLine(line4).Value.To3D());

        //debugPoints.Add(line1.GetIntersectionWithLine(line3).Value.To3D());
        //debugPoints.Add(line1.GetIntersectionWithLine(line4).Value.To3D());
        //debugPoints.Add(line2.GetIntersectionWithLine(line3).Value.To3D());
        //debugPoints.Add(line2.GetIntersectionWithLine(line4).Value.To3D());

        var name = "fourwayintersection";

        Mesh mesh = MeshMaker.FourWayIntersection(outerPoints, innerPoints, name);

        DestroyImmediate(GameObject.Find(name));
        GameObject intersection = new GameObject(name);

        intersection.transform.SetParent(transform);
        intersection.transform.position = transform.position;
        intersection.AddComponent <MeshFilter>().sharedMesh = mesh;

        MeshRenderer rend     = intersection.AddComponent <MeshRenderer>();
        Material     material = (Material)Resources.Load("Materials/test_mat", typeof(Material));

        rend.sharedMaterial       = material;
        rend.sharedMaterial.color = Color.white;
    }
예제 #30
0
 float LinkDist()
 {
     return(MeshMaker.GetDistance(nodes [0].transform.position, nodes [1].transform.position));
 }