当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Count方法代码示例

本文整理汇总了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;

	}
开发者ID:gongchangyou,项目名称:Jackal,代码行数:7,代码来源:StatePatrol.cs

示例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;
//.........这里部分代码省略.........
开发者ID:mofr,项目名称:FimbulWinter,代码行数:101,代码来源:Puppet2D_CreatePolygonFromSprite.cs

示例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);

                }
            }
开发者ID:jesusHERCULESchrist,项目名称:PlanetFactory,代码行数:55,代码来源:PlanetFactory.cs


注:本文中的Vector3.Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。