本文整理汇总了C#中Polygon.GetPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.GetPoints方法的具体用法?C# Polygon.GetPoints怎么用?C# Polygon.GetPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.GetPoints方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOutlinedPolygon
// retourne un nouveau polygone correspondant a un contour du polygone polygon
// calcule a partir de quantity
public static Polygon GetOutlinedPolygon(Polygon polygon, float quantity)
{
Point2Data [] pointsData = new Point2Data[polygon.GetPoints ().Count];
polygon.CopyPoint2DataTo (pointsData);
for (int pIndex = 0; pIndex < pointsData.Length; ++pIndex)
{
Point2 pt2 = polygon.GetPoints ()[pIndex];
Vector2 position = pointsData[pIndex].position;
position = position + pt2.GetCalculatedNormal () * quantity;
pointsData[pIndex].position = position;
}
return new Polygon (pointsData);
}
示例2: FindMutuallyVisibleVertices
// Cherche les vertices qui transformera le polgone troué en polygone concave
// voir http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
protected static MutuallyVisibleVertices FindMutuallyVisibleVertices(Polygon inner, Polygon outer)
{
LoopedList<Point2> points = inner.GetPoints ();
Vector2 innerMaxXVertex = new Vector2 (float.MinValue, 0);
int innerIndex = 0;
int outerIndex = 0;
for (int vertexIndice = 0; vertexIndice < points.Count; ++vertexIndice)
{
Vector2 vertex = points[vertexIndice];
if (vertex.x > innerMaxXVertex.x)
{
innerMaxXVertex = vertex;
innerIndex = vertexIndice;
}
}
// fake algorithm because we know that outer polygon is an axis aligned rectangle
Vector2 upRight = outer.GetPoints ()[0];
Vector2 downRight = outer.GetPoints ()[1];
float upDistance = Vector2.Distance (innerMaxXVertex, upRight);
float downDistance = Vector2.Distance (innerMaxXVertex, downRight);
Vector2 duplicatedMVVOffset;
if (upDistance < downDistance)
{
outerIndex = 0;
duplicatedMVVOffset = new Vector2 (1.0f, 0);
}
else
{
outerIndex = 1;
duplicatedMVVOffset = new Vector2 (-1.0f, 0);
}
MutuallyVisibleVertices mvv = new MutuallyVisibleVertices ();
mvv.innerIndex = innerIndex;
mvv.outerIndex = outerIndex;
mvv.duplicatedMVVOffset = duplicatedMVVOffset;
return mvv;
}
示例3: MergeInnerAndOuter
// fusionne deux polygones. Inner doit etre totalement inclus dans outer
// permet la triangulation d'un polygonr avec un trou --> plage
// voir http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
public static MergedPolygon MergeInnerAndOuter(Polygon inner, Polygon outer)
{
MergedPolygon mergedPolygon = new MergedPolygon ();
PolygonRawData mergedPolyRaw = new PolygonRawData ();
MutuallyVisibleVertices mvv = FindMutuallyVisibleVertices (inner, outer);
LoopedList<Point2> innerPoints = inner.GetPoints ();
LoopedList<Point2> outerPoints = outer.GetPoints ();
int innerIndex = 0;
for (; innerIndex <= mvv.innerIndex; ++innerIndex)
{
mergedPolyRaw.Add (innerPoints[innerIndex]);
}
mergedPolygon.originalIndex0 = mergedPolyRaw.Count - 1;
mergedPolygon.originalIndex1 = mergedPolyRaw.Count;
for (int counter = 0, outerIndex = mvv.outerIndex;
counter < outerPoints.Count;
++counter, --outerIndex)
{
mergedPolyRaw.Add (outerPoints[outerIndex]);
}
mergedPolyRaw.Add (outerPoints[mvv.outerIndex] + mvv.duplicatedMVVOffset);
mergedPolygon.duplicatedIndex1 = mergedPolyRaw.Count - 1;
mergedPolyRaw.Add (innerPoints[mvv.innerIndex] + mvv.duplicatedMVVOffset);
mergedPolygon.duplicatedIndex0 = mergedPolyRaw.Count - 1;
for (; innerIndex < innerPoints.Count; ++innerIndex)
{
mergedPolyRaw.Add (innerPoints[innerIndex]);
}
mergedPolygon.polygonRawData = mergedPolyRaw;
// Debug.Log (mergedPolygon.originalIndex0 + " " + mergedPolygon.originalIndex1 + " " + mergedPolygon.duplicatedIndex0 + " " + mergedPolygon.duplicatedIndex1);
return mergedPolygon;
}
示例4: Subdivide
public void Subdivide(Polygon _polygon)
{
//_polygon = _polygon.GetMirrorX();
_subdividedPolygon.Clear ();
_curveIndices.Clear ();
_indexedAngleType.Clear ();
// boundingBox de l'element de margelle correspondant a l'angle 90°
//Bounds rightAngleRimBounds = new Bounds (new Vector3 (-0.085f, 0.025f, -0.085f) * 100, new Vector3 (0.45f, 0.05f, 0.45f) * 100);
//Bounds rightAngleRimBounds = new Bounds (new Vector3 (-0.15f, 0.00005f, -0.15f)*100, new Vector3 (0.3f, 0.0001f, 0.3f)*100);
Bounds rightAngleRimBounds = new Bounds (new Vector3 (-0.13f, 1.0f, -0.13f) * 100, new Vector3 (0.30f, 1.0f, 0.30f)*100);
//Bounds rightAngleRimBounds = new Bounds (new Vector3 (-0.075f, 0.00005f, -0.075f) * 100, new Vector3 (0.15f, 0.05f, 0.15f)*100);
// longueur des coupures a realiser avant et apres les points d'angle 90°
float xCutOffset = rightAngleRimBounds.center.x + rightAngleRimBounds.extents.x;
float zCutOffset = rightAngleRimBounds.center.z + rightAngleRimBounds.extents.z;
int ptIndices = 0;
// pour chaque point
//_polygon.UpdateBounds();
//Bounds polyBounds = _polygon.bounds;
foreach (Point2 currentPoint in _polygon.GetPoints ())
{
//Point2 currentPoint = (Point2) currentPoint2.Clone();
//Point2 currentPoint = currentPoint2.;
//currentPoint.SetX(currentPoint2.GetX()*1);
//currentPoint.SetX(2*polyBounds.center.x + currentPoint.GetX());
if (currentPoint.GetJunction () == JunctionType.Broken)
{
// si c'est un angle de 90°
if (Utils.Approximately (currentPoint.GetAngle (), 90) && currentPoint.GetAngleType () == AngleType.Outside)
{
float xCut = xCutOffset;
float zCut = zCutOffset;
//Debug.Log("xCutOffset : "+xCutOffset);
//Debug.Log("zCutOffset : "+zCutOffset);
AngleType angleType = currentPoint.GetAngleType ();
// if (angleType == AngleType.Inside)
// {
// xCut = rightAngleRimBounds.size.x;
// zCut = rightAngleRimBounds.size.z;
// }
// si angle exterieur
if (angleType == AngleType.Inside)
{
ptIndices++;
_subdividedPolygon.Add (currentPoint);
}
// si angle interieur
if (angleType == AngleType.Outside)
{
// On coupe avant et apres le point sur les segments precedent et suivant
// de longueur xCut et zCut respectivement
Vector2 prevDirection = currentPoint.GetPrevEdge ().ToVector2 ().normalized * -1;
Vector2 prevPoint = currentPoint + prevDirection * xCut;
Vector2 nextDirection = currentPoint.GetNextEdge ().ToVector2 ().normalized;
Vector2 nextPoint = currentPoint + nextDirection * zCut;
ptIndices++;
_subdividedPolygon.Add (prevPoint);
ptIndices++;
_subdividedPolygon.Add (currentPoint);
ptIndices++;
_subdividedPolygon.Add (nextPoint);
}
}
else
{
// pour les angle non predefini
AngleType angleType = currentPoint.GetAngleType ();
float rimWidth = 0.31f * 100; // largeur de la margelle
float sectionLength = rimWidth * currentPoint.GetNormalScaleFactor ();
float outsideLength = Mathf.Sqrt (sectionLength * sectionLength - rimWidth * rimWidth);
float subdividedLimit = RIM_SIZE;// + RIM_SIZE / 2;
// si angle exterieur
if (angleType == AngleType.Inside)
{
Edge2 prevEdge = currentPoint.GetPrevEdge ();
if (prevEdge != null && _subdividedPolygon.Count > 0)
{
// verification si le point tangent et le point correspondant a la futur coupure sont a fusionner
// si oui pas de coupure
bool merged = false;
ArchedPoint2 prevAPoint = prevEdge.GetPrevPoint2 () as ArchedPoint2;
if (prevAPoint != null && prevAPoint.IsNextTangentPointMerged ())
{
merged = true;
}
//.........这里部分代码省略.........
示例5: scalePool
public IEnumerator scalePool(int _isens)
{
List<float> listRadiusPercentage = new List<float>();
Vector2 v2center = computeCenter();
Vector3 v3center = new Vector3 (v2center.x, 0, -v2center.y) * 0.1f;
int i = 0;
if(savedPointsData != null && savedPointsData.Length > 0)
{
_polygon = new Polygon(savedPointsData);
StartCoroutine (Generate (_polygon));
yield return new WaitForEndOfFrame();
savedPointsData = null;
}
foreach(Point2 p2 in _polygon.GetPoints())
{
ArchedPoint2 ar = p2 as ArchedPoint2;
if(ar != null)
{
listRadiusPercentage.Add((100.0f * ar.GetMeasuredRadius ()) / ar.GetMaxRadius ());
}
}
goParent3DPosition.transform.position = v3center;
i = 0;
fscale += 0.25f * _isens;
foreach(Point2Data p2d in pointsData)
{
Vector2 v2direction = p2d.position - v2center;
float fpowerScale = 0.1f * 0.52f;
if(_isens < 0)
{
fpowerScale= 0.09075f * 0.52f;
}
p2d.position += v2direction * fpowerScale * _isens;
Vector3 v3position = new Vector3(p2d.position.x, 0.0f, -p2d.position.y) * 0.1f;
go3DPosition[i++].transform.localPosition = v3position - v3center;
}
goParent3DPosition.transform.position = transform.position;
_polygon = new Polygon(pointsData);
i = 0;
foreach(Point2 p2 in _polygon.GetPoints())
{
ArchedPoint2 ar = p2 as ArchedPoint2;
if(ar != null)
{
float fnewMeasuredRadius = (listRadiusPercentage[i++] * ar.GetMaxRadius ()) * 0.01f;
ar.SetMeasuredRadius(fnewMeasuredRadius);
}
}
frailStairway = 0.0f;
StartCoroutine (Generate (_polygon));
yield return new WaitForEndOfFrame();
if(bstairway && canAddStairway(pointsData, fsizeStairway))
{
if(canAddStairway(pointsData, fsizeStairway))
{
StartCoroutine (addStairway(null, true, 0, fsizeStairway, fradiusStairway));
}
else
{
StartCoroutine(removeStairway());
}
}
init3DPoints();
if(listDoubleV3.Count > 0)
{
idDoubleV3 = 0;
v3positionBloc = listDoubleV3[0].v3start;
goBloc.transform.localPosition = v3positionBloc;
fgoBlocPosition = 5.0f;
fcurrentMagnitudeRail = 0.0f;
}
}
示例6: Generate
public IEnumerator Generate(Polygon polygon)
{
GameObject pool = _poolGen.GetParentGameObject ();
if (_isLoading)
{
// lors de la copie, on attend le frame suivante
// pour que la copie soit complete
_isLoading = false;
yield return new WaitForEndOfFrame();
}
// on conserve les donnees des Function_hideObject de la plage et du Function_PoolInitializer
// avant de les detruire et de les reaffecter
Function_hideObject [] hiders = pool.GetComponents<Function_hideObject> ();
Function_hideObject hider = hiders[0].id == 0 ? hiders[0] : hiders[1];
ArrayList hiderConfig = hider.getConfig ();
if (hider != null)
{
Destroy (hider);
}
Function_hideObject rimHider = hiders[0].id == 1 ? hiders[0] : hiders[1];
ArrayList rimHiderConfig = rimHider.getConfig ();
if (rimHider != null)
{
Destroy (rimHider);
}
Function_PoolInitializer initializer = pool.GetComponent <Function_PoolInitializer> ();
ArrayList initializerConfig = initializer.getConfig ();
if (initializer != null)
{
if(pool.transform.FindChild ("muret"))
{
GameObject lowWall = pool.transform.FindChild ("muret").gameObject;
if(lowWall)
{
Destroy (lowWall);
}
}
Transform sidewalk = pool.transform.FindChild ("plage");
if(sidewalk)
{
Destroy (sidewalk.GetComponent<AABBOutlineResizer> ());
}
Destroy (initializer);
}
// _polygon = polygon.GetMirrorX();
_polygon = polygon;
List<Point2Data> tpsList = new List<Point2Data>();
foreach(Point2Data p2d in _polygon._pointsData)
{
tpsList.Add(p2d);
}
pointsData = new Point2Data[_polygon.GetPoints ().Count];
_polygon.CopyPoint2DataTo (pointsData);
_poolGen.Generate (_polygon);
_rimCount = _poolGen.GetRimCount ();
for(int i = 0; i < tpsList.Count; i++)
{
if(tpsList[i].bstairway)
{
pointsData[i].bstairway = true;
}
}
// on attend la frame suivante que les Function soit prete pour les configurer
// avec les valeurs sauvegardées
// et que les script soit supprimés
yield return new WaitForEndOfFrame();
Function_hideObject addedHider = pool.AddComponent<Function_hideObject> ();
addedHider._nameObjectToHide = "plage";
addedHider._strObjectToHide = "plage";
addedHider.setConfig (hiderConfig);
Function_hideObject addedRimHider = gameObject.AddComponent<Function_hideObject> ();
addedRimHider.id = 1;
addedRimHider._nameObjectToHide = "margelle";
addedRimHider._strObjectToHide = "margelle";
addedRimHider.setConfig (rimHiderConfig);
addedRimHider.SetObjectToHide (_poolGen.GetRimObjects ());
//.........这里部分代码省略.........
示例7: Generate
public void Generate(Polygon _polygon)
{
_rimParts.Clear ();
_rimLofters.Clear ();
_corners.Clear ();
foreach (Transform child in _rim.transform)
{
GameObject.Destroy (child.gameObject);
}
_rars.Subdivide (_polygon);
Polygon subdividedPolygon = new Polygon (_rars.GetSubdividedPolygon ());
subdividedPolygon.SetClosed (_polygon.IsClosed ());
//******************* OBTENTION DU PROFILE A EXTERNALISER ********************//
PolygonRawData shapeRaw = new PolygonRawData ();
/*shapeRaw.Add (new Vector2 (0, 0));
shapeRaw.Add (new Vector2 (0, 0.01f));
shapeRaw.Add (new Vector2 (-0.015f, 0.026f));
shapeRaw.Add (new Vector2 (-0.015f, 0.042f));
shapeRaw.Add (new Vector2 (-0.006f, 0.06f));
shapeRaw.Add (new Vector2 (0.01f, 0.069f));
shapeRaw.Add (new Vector2 (0.03f, 0.071f));
shapeRaw.Add (new Vector2 (0.049f, 0.066f));
shapeRaw.Add (new Vector2 (0.071f, 0.06f));
shapeRaw.Add (new Vector2 (0.1f, 0.052f));
shapeRaw.Add (new Vector2 (0.169f, 0.044f));
shapeRaw.Add (new Vector2 (0.249f, 0.041f));
shapeRaw.Add (new Vector2 (0.29f, 0.04f));
shapeRaw.Add (new Vector2 (0.298f, 0.038f));
shapeRaw.Add (new Vector2 (0.305f, 0.033f));
shapeRaw.Add (new Vector2 (0.309f, 0.024f));
shapeRaw.Add (new Vector2 (0.31f, 0.014f));
shapeRaw.Add (new Vector2 (0.31f, 0));*/
shapeRaw.Add (new Vector2 (-0.02f, 0.0f));
shapeRaw.Add (new Vector2 (0.28f, 0.0f));
shapeRaw.Add (new Vector2 (0.28f, 0.001f));
shapeRaw.Add (new Vector2 (-0.02f, 0.001f));
Polygon profile = new Polygon (shapeRaw);
profile.SetClosed (false);
//************************************************************************//
Polygon currentPortion = null;
bool inPortion = false;
bool inCurve = false;
int pointCounter = 0;
int indexOffset = 0;
// pour chaque point du polygon subdivisé
// si c'est un angle prédéfini on charge le mesh margelle associé
// sinon on crée un section avec l'outil loft jusqu'au prochain angle prédéfini
foreach (Point2 currentPoint in subdividedPolygon.GetPoints ())
{
float angle = currentPoint.GetAngle ();
AngleType angleType = currentPoint.GetAngleType ();
if (inPortion || inCurve)
{
Point2 pointToAdd = new Point2 (currentPoint);
currentPortion.AddPoint (pointToAdd);
}
Edge2 nextEdge = currentPoint.GetNextEdge ();
Edge2 prevEdge = currentPoint.GetPrevEdge ();
Point2 nextPoint = null;
Point2 prevPoint = null;
if (nextEdge != null)
{
nextPoint = nextEdge.GetNextPoint2 ();
prevPoint = prevEdge.GetPrevPoint2 ();
float nextAngle = nextPoint.GetAngle ();
AngleType nextAngleType = nextPoint.GetAngleType ();
// stop case for onr portion
if (Utils.Approximately (nextAngle, 90) && inPortion && nextAngleType == AngleType.Outside)
{
inPortion = false;
currentPortion.SetClosed (false);
GameObject portionGO = new GameObject ("portion");
portionGO.transform.parent = _rim.transform;
portionGO.transform.localPosition = Vector3.zero;
portionGO.transform.localRotation = Quaternion.identity;
portionGO.transform.localScale = Vector3.one;
portionGO.AddComponent<MeshRenderer> ();
MeshFilter meshFilter = portionGO.AddComponent<MeshFilter> ();
PolygonLofter polyLofter = new PolygonLofter (currentPortion, profile, meshFilter.mesh);
polyLofter.SetCurveIndices (_rars.GetCurveIndices ());
polyLofter.SetIndexedAngleType (_rars.GetIndexedAngleType ());
polyLofter.SetIndexOffset (indexOffset + 1, subdividedPolygon.GetPoints ().Count);
//.........这里部分代码省略.........
示例8: Generate
public void Generate(Polygon _polygon)
{
//_polygon = new Polygon(_polygon.GenerateWithCurveInverse());
// On genere les meshs des composants de la piscine
if (_polygon.GetPoints ().Count < 3)
return;
if (!_polygon.IsClosed ())
{
_polygon.Close ();
}
_polygon = _polygon.GetMirrorX();
_polygon.UpdateBounds ();
Vector2 translation = _polygon.GetPolygonCenter () * -1;
Vector2 mirror = new Vector2(1,-1);
// exprime le polygone en coordonnées monde, avec son repere centré sur son centre
PolygonRawData polyRaw = new PolygonRawData ();
foreach (Vector2 pt in _polygon.GenerateWithCurve ())
//foreach (Vector2 pt in _polygon.GenerateWithCurveInverse ())
//PolygonRawData polydata = _polygon.GenerateWithCurveInverse ();
//polydata.Reverse();
//foreach (Vector2 pt in polydata)
{
Vector2 transformedPt = (pt + translation) * _polygonScaleFactor;
/*Vector2 newpt = new Vector2();
newpt.x=pt.x;
newpt.y=pt.y;
newpt.y = 2*_polygon.bounds.center.z - newpt.y;
Vector2 transformedPt = (newpt + translation) * _polygonScaleFactor;*/
polyRaw.Add (transformedPt);
}
_transformedPolygon = new Polygon (polyRaw);
// generate liner
Mesh linerMesh = _liner.GetComponent<MeshFilter> ().mesh;
PolygonExtruder linerExtrusion = new PolygonExtruder (_transformedPolygon, linerMesh, -1.5f, false, true, true);
linerExtrusion.Generate ();
LinerScatteringMapper lsm = new LinerScatteringMapper (linerMesh);
lsm.Generate ();
PolygonExtruderMapper pem = new PolygonExtruderMapper (linerExtrusion);
pem.Generate ();
// generate sidewalk
Mesh sidewalkMesh = _sidewalk.GetComponent<MeshFilter> ().mesh;
SideWalkExtruder se = new SideWalkExtruder (_transformedPolygon, sidewalkMesh, -0.02f, 2);
se.Generate ();
PlannarMapper pm = new PlannarMapper (sidewalkMesh, Vector3.up);
pm.Generate ();
// generate rim
_rimGenerator.Generate (_polygon);
// generate occlusion
PolygonRawData occluShape = new PolygonRawData ();
occluShape.Add (new Vector2 (0.28f, 0));
occluShape.Add (new Vector2 (0.33f, 0));
Polygon occluProfile = new Polygon (occluShape);
occluProfile.SetClosed (false);
Mesh occluMesh = _occlusion.GetComponent<MeshFilter> ().mesh;
PolygonLofter occluLofter = new PolygonLofter (_transformedPolygon, occluProfile, occluMesh);
_occlusion.GetComponent<Renderer>().enabled = false;
occluLofter.Generate ();
// generate water
Mesh waterMesh = _water.GetComponent<MeshFilter> ().mesh;
PolygonExtruder waterPlan = new PolygonExtruder (_transformedPolygon, waterMesh, 0, true, false, false);
waterPlan.Generate ();
PlannarMapper waterMapper = new PlannarMapper (waterMesh, Vector3.down, UVChannel.uv0, 5);
waterMapper.Generate ();
// generate frieze
Mesh friezeMesh = _frieze.GetComponent<MeshFilter> ().mesh;
PolygonExtruder friezeExtrusion = new PolygonExtruder (_transformedPolygon, friezeMesh, -0.10f, false, false, true);
friezeExtrusion.Generate ();
PolygonExtruderMapper friezeMapper = new PolygonExtruderMapper (friezeExtrusion);
friezeMapper.Generate ();
LinerScatteringMapper lsmFrieze = new LinerScatteringMapper (friezeMesh);
lsmFrieze.Generate ();
// generate mask
Mesh maskMesh = _mask.GetComponent<MeshFilter> ().mesh;
PolygonExtruder maskExtrusion = new PolygonExtruder (_transformedPolygon, maskMesh, -0.10f, false, false, true);
maskExtrusion.Generate ();
PolygonExtruderMapper maskMapper = new PolygonExtruderMapper (maskExtrusion);
maskMapper.Generate ();
//.........这里部分代码省略.........