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();
}
希望这将有助于某人完成道路 我们不把“已解决”放在问题中。你已经接受了一个帖子作为答案,仅此而已。我们不会在问题中添加“已解决”。你已经接受了一个帖子作为答案,就这样。