PolygonFace.TurnInternalEdgeOffset operator

導入

v8.0 (2010)

詳細

このポリゴンフェイスのテッセレータによって使用されている現在の開始ノードを戻します。

デフォルトでは、三角形のファンを使用して、頂点#0を開始点としてポリゴンが三角形分割されます。これにより、三角形分割は、[0,1,2], [0,2,3], [0,3,4], ..., [0,N-2,N-1]のようになります(ここで、Nはポリゴン内のノードの数を示します)。このため、四角形の場合、ファンは[0,1,2]と[0,2,3]の 2 つの三角形しか持ちません。

TurnEdgeOpオペレータを適用して、三角形のファンの開始点ノードを変更し、三角形分割が[1,2,3], [1,3,4], ..., [1,N-1,0](または 2 度目が[2,3,4], [2,4,5], ..., [2,0,1])になるようにします。これは、「非表示」エッジがシェーディングで可視不連続性を起こしている非プラナポリゴンで特に便利です。

凹面のポリゴンの場合、ポリゴンエリアの外側に三角形を作成しない三角形分割を作成するために、テッセレータが、このオフセットを無視することがあります。

JScript の例

/*
        This example demonstrates how to set and use the turn edge offset.
*/
NewScene( null, false );
CreatePrim("Grid", "MeshSurface", null, null);
SetValue("grid.polymsh.geom.subdivu", 2, null);
SetValue("grid.polymsh.geom.subdivv", 2, null);
var GridGeom = GetValue( "Grid" ).ActivePrimitive.Geometry;
var Polygons = GridGeom.Polygons;
var Polygon = Polygons.Item(3);
var PolygonVertices = Polygon.Vertices;
var TriangleSubIndices = Polygon.TriangleSubIndexArray.toArray();
Application.LogMessage( "Polygon #3 is defined with the following vertices: " + 
                                                PolygonVertices.Item(0).Index + ", " + 
                                                PolygonVertices.Item(1).Index + ", " + 
                                                PolygonVertices.Item(2).Index + ", " + 
                                                PolygonVertices.Item(3).Index );
Application.LogMessage( "Polygon #3 has the following two triangles before applying the TurnEdge operator: [" + 
                                                PolygonVertices.Item(TriangleSubIndices[0]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[1]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[2]).Index + "] and [" +
                                                PolygonVertices.Item(TriangleSubIndices[3]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[4]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[5]).Index + "]." );
ApplyOp("TurnEdgeOp", "grid.poly[LAST]", 3, siPersistentOperation, null, 0);
var GridGeom = GetValue( "Grid" ).ActivePrimitive.Geometry;
var Polygons = GridGeom.Polygons;
var Polygon = Polygons.Item(3);
var PolygonVertices = Polygon.Vertices;
var TriangleSubIndices = Polygon.TriangleSubIndexArray.toArray();
Application.LogMessage( "Polygon #3 has the following two triangles after applying the TurnEdge operator: [" + 
                                                PolygonVertices.Item(TriangleSubIndices[0]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[1]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[2]).Index + "] and [" +
                                                PolygonVertices.Item(TriangleSubIndices[3]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[4]).Index + ", " +
                                                PolygonVertices.Item(TriangleSubIndices[5]).Index + "]" );
var offset = Polygon.TurnInternalEdgeOffset; // this should be 1 since with only turned the polygon edges once.
Application.LogMessage( "This triangulation is equivalent to that of a polygon defined using the following vertices: " + 
                                                PolygonVertices.Item( ( 0 + offset ) % 4 ).Index + ", " + 
                                                PolygonVertices.Item( ( 1 + offset ) % 4 ).Index + ", " + 
                                                PolygonVertices.Item( ( 2 + offset ) % 4 ).Index + ", " + 
                                                PolygonVertices.Item( ( 3 + offset ) % 4 ).Index );
// Expected results:
// INFO : Polygon #3 is defined with the following vertices: 4, 5, 8, 7
// INFO : Polygon #3 has the following two triangles before applying the TurnEdge operator: [4, 5, 8] and [4, 8, 7].
// INFO : Polygon #3 has the following two triangles after applying the TurnEdge operator: [5, 8, 7] and [5, 7, 4]
// INFO : This triangulation is equivalent to that of a polygon defined using the following vertices: 5, 8, 7, 4

関連項目

PolygonFace.Vertices PolygonFace.Nodes