本文整理汇总了C#中Vector3.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Count方法的具体用法?C# Vector3.Count怎么用?C# Vector3.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector3
的用法示例。
在下文中一共展示了Vector3.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatePatrol
public StatePatrol(Person person, Vector3[] list) : base( person ){
pointList = new Vector3[list.Count()];
List<Vector3> tmp = new List<Vector3> (list);
pointList = tmp.Select (point => point + owner.ComponentTransform.localPosition).ToArray ();
pathLength = pointList.Length;
}
示例2: CreateMeshFromVerts
public Mesh CreateMeshFromVerts(Vector3[] vertsToCopy, Mesh mesh, List<int> pathSplitIds, Transform SpriteGO = null)
{
List<Vector3> resultsLocal = new List<Vector3>();
List<int> resultsTriIndexesLocal = new List<int>();
List<int> resultsTriIndexesReversedLocal = new List<int>();
List<Vector2> uvsLocal = new List<Vector2>();
List<Vector3> normalsLocal = new List<Vector3>();
Sprite spr = new Sprite();
Rect rec = new Rect();
Vector3 bound = Vector3.zero;
TextureImporter textureImporter = new TextureImporter();
if(SpriteGO !=null && SpriteGO.GetComponent<SpriteRenderer>() && SpriteGO.GetComponent<SpriteRenderer>().sprite)
{
spr = SpriteGO.GetComponent<SpriteRenderer>().sprite;
rec = spr.rect;
bound = SpriteGO.GetComponent<Renderer>().bounds.max- SpriteGO.GetComponent<Renderer>().bounds.min ;
textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(spr)) as TextureImporter;
}
List<PolygonPoint> p2 = new List<PolygonPoint>();
List<TriangulationPoint> extraPoints = new List<TriangulationPoint>();
int i = 0;
for (i = 0; i < vertsToCopy.Count(); i ++)
{
if(i<pathSplitIds[0])
p2.Add(new PolygonPoint(vertsToCopy [i].x, vertsToCopy [i].y));
else
extraPoints.Add(new TriangulationPoint(vertsToCopy [i].x, vertsToCopy [i].y));
}
Polygon _polygon = new Polygon(p2);
// this is how to add more points
_polygon.AddSteinerPoints (extraPoints);
P2T.Triangulate(_polygon);
if (spr == null)
{
bound = new Vector3((float)(_polygon.Bounds.MaxX - _polygon.Bounds.MinX),(float)(_polygon.Bounds.MaxY - _polygon.Bounds.MinY),0 ) ;
}
int idx = 0;
foreach (DelaunayTriangle triangle in _polygon.Triangles)
{
Vector3 v = new Vector3();
foreach (TriangulationPoint p in triangle.Points)
{
v = new Vector3((float)p.X, (float)p.Y,0);
if(!resultsLocal.Contains(v))
{
resultsLocal.Add(v);
resultsTriIndexesLocal.Add(idx);
Vector2 newUv = new Vector2(((v.x-(float)_polygon.Bounds.MinX) /bound.x) , ((v.y-(float)_polygon.Bounds.MinY) /bound.y) );
if (spr != null)
{
newUv = new Vector2 ((v.x / bound.x) + 0.5f, (v.y / bound.y) + 0.5f);
newUv.x *= rec.width/ spr.texture.width;
newUv.y *= rec.height/ spr.texture.height;
newUv.x += (rec.x)/ spr.texture.width;
newUv.y += (rec.y) / spr.texture.height;
SpriteMetaData[] smdArray = textureImporter.spritesheet;
Vector2 pivot = new Vector2(.0f,.0f);;
for (int k = 0; k < smdArray.Length; k++)
{
if (smdArray[k].name == spr.name)
{
switch(smdArray[k].alignment)
{
case(0):
smdArray[k].pivot = Vector2.zero;
break;
case(1):
smdArray[k].pivot = new Vector2(0f,1f) -new Vector2(.5f,.5f);
break;
case(2):
smdArray[k].pivot = new Vector2(0.5f,1f) -new Vector2(.5f,.5f);
break;
case(3):
smdArray[k].pivot = new Vector2(1f,1f) -new Vector2(.5f,.5f);
break;
case(4):
smdArray[k].pivot = new Vector2(0f,.5f) -new Vector2(.5f,.5f);
break;
case(5):
smdArray[k].pivot = new Vector2(1f,.5f) -new Vector2(.5f,.5f);
break;
case(6):
smdArray[k].pivot = new Vector2(0f,0f) -new Vector2(.5f,.5f);
break;
//.........这里部分代码省略.........
示例3: LoadScaledPlanet
public static void LoadScaledPlanet(GameObject smallPlanet, string name,bool bLoadTemp=false)
{
var root = ConfigNode.Load(DataPath + name + ".cfg");
if (root != null)
{
var sConfig = root.nodes.GetNode("ScaledTransform");
//print(cbConfig);
if (sConfig != null)
{
var scaledBody = PFUtil.FindScaled(name);
var ratio = float.Parse(sConfig.GetValue("ratio"));
var newScale = (float)PFUtil.FindCB(name).Radius * ratio;
scaledBody.transform.localScale = new Vector3(newScale, newScale, newScale);
}
}
var binName = name + ".bin";
if (!bLoadTemp)
{
var colorTexture = PFUtil.LoadTexture(DataPath + name + "_map.png");
var bumpTexture = PFUtil.LoadTexture(DataPath + name + "_normal.png");
LoadScaledPlanetTextures(name, colorTexture, bumpTexture);
}
else
{
var colorTexture = PFUtil.LoadTexture(DataPath + name + "_map_.png");
var bumpTexture = PFUtil.LoadTexture(DataPath + name + "_normal_.png");
binName = name + "_.bin";
LoadScaledPlanetTextures(name, colorTexture, bumpTexture);
}
if (KSP.IO.File.Exists<PlanetFactory>(binName))
{
//print("Loading mesh");
var smallPlanetMeshFilter = (MeshFilter) smallPlanet.GetComponentInChildren((typeof (MeshFilter)));
var newVerts = new Vector3[smallPlanetMeshFilter.mesh.vertices.Count()];
var reader = KSP.IO.BinaryReader.CreateForType<PlanetFactory>(binName);
for (var i = 0; i < newVerts.Count(); i++)
{
newVerts[i].x = reader.ReadSingle();
newVerts[i].y = reader.ReadSingle();
newVerts[i].z = reader.ReadSingle();
}
smallPlanetMeshFilter.mesh.vertices = newVerts;
smallPlanetMeshFilter.mesh.RecalculateNormals();
//smallPlanetMeshFilter.mesh.tangents = null;
PFUtil.RecalculateTangents(smallPlanetMeshFilter.mesh);
}
}