Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# -x0); int dy=数学绝对值(y1-y0); int sx=x0_C#_Unity3d_Triangulation_Delaunay_Triangle.net - Fatal编程技术网

C# -x0); int dy=数学绝对值(y1-y0); int sx=x0

C# -x0); int dy=数学绝对值(y1-y0); int sx=x0,c#,unity3d,triangulation,delaunay,triangle.net,C#,Unity3d,Triangulation,Delaunay,Triangle.net,好消息!我已经设法解决了这个问题InsertVertex()实际上不会将新顶点添加到顶点列表中!这意味着当它尝试三角化时,它试图指向新的顶点,但它不能(因为该顶点不在列表中)。因此,为了解决这个问题,我只需在调用InsertVertex()之前手动将新顶点添加到网格中的顶点列表中。注意:执行此操作时,还需要手动设置顶点的id。我将id设置为顶点列表的大小,因为我正在将所有新顶点添加到列表的末尾 // When left click is pressed, a raycast is sent ou

好消息!我已经设法解决了这个问题
InsertVertex()
实际上不会将新顶点添加到顶点列表中!这意味着当它尝试三角化时,它试图指向新的顶点,但它不能(因为该顶点不在列表中)。因此,为了解决这个问题,我只需在调用
InsertVertex()
之前手动将新顶点添加到网格中的顶点列表中。注意:执行此操作时,还需要手动设置顶点的id。我将id设置为顶点列表的大小,因为我正在将所有新顶点添加到列表的末尾

// When left click is pressed, a raycast is sent out. If that raycast hits the wall, updatePoints() is called and is passed in the location of the hit (hit.point).
public void updatePoints(Vector3 pos)
{
    // Convert pos to local coords of wall. You don't need to do this, i do it because of my draw() method where i map everything out onto a texture and display it.
    pos = transform.InverseTransformPoint(pos);
    pos.x = map(pos.x, -0.5f, 0.5f, 0, 512);
    pos.y = map(pos.y, -0.5f, 0.5f, 0, 512);
    Vertex newVert = new Vertex(pos.x, pos.y);

    // Manually add new vertex to list of vertices.
    newVert.id = mesh.vertices.Count;
    mesh.vertices.Add(newVert.id, newVert);

    //Doing just the first line gave me a null pointer exception. Adding the two extra lines below it fixed it for me.
    otri.tri = mesh.dummytri;
    otri.orient = 0;
    otri.Sym();

    // Insert new vertex into existing triangulation.
    mesh.InsertVertex(newVert, ref otri, ref osub, false, false);

    // Draw result as a texture onto the wall so to visualise what is happening.
    draw();
}

希望这将有助于某人完成道路

好消息!我已经设法解决了这个问题
InsertVertex()
实际上不会将新顶点添加到顶点列表中!这意味着当它尝试三角化时,它试图指向新的顶点,但它不能(因为该顶点不在列表中)。因此,为了解决这个问题,我只需在调用
InsertVertex()
之前手动将新顶点添加到网格中的顶点列表中。注意:执行此操作时,还需要手动设置顶点的id。我将id设置为顶点列表的大小,因为我正在将所有新顶点添加到列表的末尾

// When left click is pressed, a raycast is sent out. If that raycast hits the wall, updatePoints() is called and is passed in the location of the hit (hit.point).
public void updatePoints(Vector3 pos)
{
    // Convert pos to local coords of wall. You don't need to do this, i do it because of my draw() method where i map everything out onto a texture and display it.
    pos = transform.InverseTransformPoint(pos);
    pos.x = map(pos.x, -0.5f, 0.5f, 0, 512);
    pos.y = map(pos.y, -0.5f, 0.5f, 0, 512);
    Vertex newVert = new Vertex(pos.x, pos.y);

    // Manually add new vertex to list of vertices.
    newVert.id = mesh.vertices.Count;
    mesh.vertices.Add(newVert.id, newVert);

    //Doing just the first line gave me a null pointer exception. Adding the two extra lines below it fixed it for me.
    otri.tri = mesh.dummytri;
    otri.orient = 0;
    otri.Sym();

    // Insert new vertex into existing triangulation.
    mesh.InsertVertex(newVert, ref otri, ref osub, false, false);

    // Draw result as a texture onto the wall so to visualise what is happening.
    draw();
}
希望这将有助于某人完成道路

我们不把“已解决”放在问题中。你已经接受了一个帖子作为答案,仅此而已。我们不会在问题中添加“已解决”。你已经接受了一个帖子作为答案,就这样。