當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.MeshFilter類代碼示例

本文整理匯總了C#中UnityEngine.MeshFilter的典型用法代碼示例。如果您正苦於以下問題:C# MeshFilter類的具體用法?C# MeshFilter怎麽用?C# MeshFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MeshFilter類屬於UnityEngine命名空間,在下文中一共展示了MeshFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RestoreOriginalMeshesUV

 private void RestoreOriginalMeshesUV(MeshFilter[] meshFilters, Vector2[][] backupUVs)
 {
     for (int i = 0; i < meshFilters.Length; i++)
     {
         meshFilters[i].mesh.uv = backupUVs[i];
     }
 }
開發者ID:Shkoda,項目名稱:RenderCombine,代碼行數:7,代碼來源:ObjectFromMeshesBuilder.cs

示例2: NewTarget

    public void NewTarget(GameObject targ)
    {
        if ( target != targ )
        {
            target = targ;
            t = 0.0f;

            if ( target )
            {
                filter = (MeshFilter)target.GetComponent(typeof(MeshFilter));

                if ( filter != null )
                    center = filter.mesh.bounds.center;
                else
                {
                    render = (MeshRenderer)target.GetComponent(typeof(MeshRenderer));

                    if ( render != null )
                        center = render.bounds.center;
                    else
                    {
                        srender = (SkinnedMeshRenderer)target.GetComponent(typeof(SkinnedMeshRenderer));

                        if ( srender != null )
                            center = srender.bounds.center;
                    }
                }
            }
        }
    }
開發者ID:mobeid,項目名稱:NP_SIMULATOR,代碼行數:30,代碼來源:MOrbit.cs

示例3: Reset

    public virtual void Reset()
    {
        if (meshFilter != null) meshFilter.sharedMesh = null;
        if (mesh != null) DestroyImmediate(mesh);
        if (renderer != null) renderer.sharedMaterial = null;
        mesh = null;
        mesh1 = null;
        mesh2 = null;
        lastVertexCount = 0;
        vertices = null;
        colors = null;
        uvs = null;
        sharedMaterials = new Material[0];
        submeshMaterials.Clear();
        submeshes.Clear();
        valid = false;

        if(skeleton==null)
        {
            return;
        }
        valid = true;
        meshFilter = GetComponent<MeshFilter>();
        mesh1 = newMesh();
        mesh2 = newMesh();
        vertices = new Vector3[0];

        if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
            skeleton.SetSkin(initialSkinName);
    }
開發者ID:GraphicGame,項目名稱:CSLightStudio,代碼行數:30,代碼來源:SkeletonRendererCL.cs

示例4: MeshToString

    public static string MeshToString(MeshFilter mf)
    {
        Mesh m = mf.mesh;
        //Material[] mats = mf.GetComponent<Renderer>().sharedMaterials;

        StringBuilder sb = new StringBuilder();

        sb.Append("g ").Append(mf.name).Append("\n");
        foreach (Vector3 v in m.vertices)
        {
            sb.Append(string.Format("v {0} {1} {2}\n", v.x, v.y, v.z));
        }
        sb.Append("\n");
        foreach (Vector3 v in m.normals)
        {
            sb.Append(string.Format("vn {0} {1} {2}\n", v.x, v.y, v.z));
        }
        sb.Append("\n");
        foreach (Vector3 v in m.uv)
        {
            sb.Append(string.Format("vt {0} {1}\n", v.x, v.y));
        }

        sb.Append("\n");
        int[] triangles = m.GetTriangles(0);
        for (int i = 0; i < triangles.Length; i += 3)
        {
            sb.Append(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n",
                triangles[i] + 1, triangles[i + 1] + 1, triangles[i + 2] + 1));
        }

        return sb.ToString();
    }
開發者ID:ja003,項目名稱:Fractal-Nature-II,代碼行數:33,代碼來源:ObjExporter.cs

示例5: MeshToFile

 public static void MeshToFile(MeshFilter mf, string filename)
 {
     using (StreamWriter streamWriter = new StreamWriter(filename))
     {
         streamWriter.Write(RTPObjExporter.MeshToString(mf));
     }
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:7,代碼來源:RTPObjExporter.cs

示例6: Start

	void Start ()
	{
	    meshFilter = GetComponent<MeshFilter>();
	    switch (shape)
	    {
	        case PGMesh.Shape.Triangle:
                meshFilter.sharedMesh = PGMesh.Triangle(Vector3.left / 2 + Vector3.down / 2, Vector3.up, Vector3.right / 2 + Vector3.down / 2);
	            break;
	        case PGMesh.Shape.Quad:
                meshFilter.sharedMesh = PGMesh.Quad(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up);
	            break;
            case PGMesh.Shape.Plane:
                meshFilter.sharedMesh = PGMesh.Plane(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up, 1, 3);
	            break;
	        case PGMesh.Shape.Tetrahedron:
                meshFilter.sharedMesh = PGMesh.Tetrahedron(1);
	            break;
            case PGMesh.Shape.Cube:
                meshFilter.sharedMesh = PGMesh.Cube(1);
	            break;
            case PGMesh.Shape.Octahedron:
                meshFilter.sharedMesh = PGMesh.Octahedron(1);
                break;
	        case PGMesh.Shape.Icosahedron:
                meshFilter.sharedMesh = PGMesh.Icosahedron(1);
                break;
	    }
	}
開發者ID:cupsster,項目名稱:ProceduralExperiments,代碼行數:28,代碼來源:ProceduralGeneratedMesh.cs

示例7: Awake

		// Use this for initialization
		protected void Awake()
		{
			Filter = gameObject.GetComponent<MeshFilter>();
			Coll = gameObject.GetComponent<MeshCollider>();

			//past here is just to set up an example chunk
			//Blocks = new VoxBlock[ChunkSize, ChunkSize, ChunkSize];

			for (var x = 0; x < World.ChunkSize; x++)
			{
				for (var y = 0; y < World.ChunkSize; y++)
				{
					for (var z = 0; z < World.ChunkSize; z++)
					{
						Blocks[x, y, z] = new Block(Color.white) { BlockType = VoxBlockType.Empty };
					}
				}
			}

			//Blocks[1, 14, 1] = new VoxBlock();

			//Blocks[3, 5, 2] = new VoxBlock();
			//Blocks[4, 5, 2] = new VoxBlock();


			//UpdateChunk();

		}
開發者ID:Quixotic7,項目名稱:VR-Vox,代碼行數:29,代碼來源:Chunk.cs

示例8: Start

 void Start()
 {
     mesh = new Mesh();
     mesh.name = "GeneratedMesh";
     meshFilter = GetComponent<MeshFilter>();
     meshFilter.mesh = mesh;
 }
開發者ID:brulo,項目名稱:the_pantry,代碼行數:7,代碼來源:GenerateMesh.cs

示例9: Awake

        private void Awake()
        {
            mf = GetComponent<MeshFilter>();
            if (mf != null)
            {
                //modify collider points to snipping tringle
                //poll.points

                Vector2[] vert2d = new Vector2[mf.mesh.vertexCount];

                for (int v = 0; v < mf.mesh.vertexCount; v++)
                {
                    vert2d[v] = new Vector2(mf.mesh.vertices[v].x, mf.mesh.vertices[v].y);
                }

                Triangulator tr = new Triangulator(vert2d);
                int[] indices = tr.Triangulate();
                Vector3[] vertices = new Vector3[indices.Length];
                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i] = new Vector3(vertices[i].x, vertices[i].y, 0);
                }

                // Create the mesh
                Mesh msh = mf.mesh;
                msh.vertices = vertices;
                msh.triangles = indices;
                msh.RecalculateNormals();
                msh.RecalculateBounds();
                mf.mesh = msh;
                // mesh.mesh.triangles = newTriangles;
            }
        }
開發者ID:Badeye,項目名稱:impulse,代碼行數:33,代碼來源:MoveTriangle.cs

示例10: Start

    // Use this for initialization
    void Start ()
    {
        m_Creature = PlayerPrefs.GetString("m_Character" + m_PlayerProperty);

        m_Appearance = GetComponent<MeshFilter>();
        rb_MyRigidBody = this.GetComponent<Rigidbody>();

        switch (m_Creature)
        {
            case "Cochon":
                m_Appearance.mesh = s_VisuArray.a_MeshArray[0];
                break;

            case "Paresseux":
                m_Appearance.mesh = s_VisuArray.a_MeshArray[1];
                break;

            case "Mouton":
                m_Appearance.mesh = s_VisuArray.a_MeshArray[2];
                break;

            case "Canard":
                m_Appearance.mesh = s_VisuArray.a_MeshArray[3];
                break;
        }
	}
開發者ID:daviddelseray,項目名稱:OuKaShaHi,代碼行數:27,代碼來源:ScriptSideCreature.cs

示例11: BoidController

        public BoidController(MeshFilter meshFilter)
        {
            template = MeshDraft.Tetrahedron(0.3f);

            // Avoid vertex count overflow
            swarmCount = Mathf.Min(65000/template.vertices.Count, swarmCount);
            // Optimization trick: in each frame we simulate only small percent of all boids
            simulationUpdate = Mathf.RoundToInt(swarmCount*simulationPercent);
            int vertexCount = swarmCount*template.vertices.Count;

            draft = new MeshDraft
            {
                name = "Boids",
                vertices = new List<Vector3>(vertexCount),
                triangles = new List<int>(vertexCount),
                normals = new List<Vector3>(vertexCount),
                uv = new List<Vector2>(vertexCount),
                colors = new List<Color>(vertexCount)
            };
            for (var i = 0; i < swarmCount; i++)
            {
                boids.Add(new Boid());
                draft.Add(template);
            }

            mesh = draft.ToMesh();
            mesh.MarkDynamic();
            meshFilter.mesh = mesh;
        }
開發者ID:rickoskam,項目名稱:ShepherdGame,代碼行數:29,代碼來源:BoidController.cs

示例12: VoronoiDiagram

 public VoronoiDiagram(MeshFilter mesh, Transform transform)
 {
     _initial = new Triangle(new Pnt(-10000, -10000), new Pnt(10000, -10000), new Pnt(0, 10000));
     _delaunay = new Triangulation(_initial);
     _mesh = mesh;
     _transform = transform;
 }
開發者ID:cybergen,項目名稱:bri-lib,代碼行數:7,代碼來源:VoronoiDiagram.cs

示例13: Start

 void Start()
 {
     //renderer  = gameObject.AddComponent<MeshRenderer>();
     //renderer.material = SetMaterial();
     mesh      = gameObject.AddComponent<MeshFilter>();// = mesh = new MeshFilter();
     mesh.mesh = CreateQuad();
 }
開發者ID:TheVirtualBoys,項目名稱:TOJam9,代碼行數:7,代碼來源:SimpleSprite.cs

示例14: ManualUpdate

    public void ManualUpdate(Mesh mesh, Material material, Quaternion rotation)
    {
        if (Ring != null)
        {
            if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>();

            if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>();

            if (MeshFilter.sharedMesh != mesh)
            {
                SgtHelper.BeginStealthSet(MeshFilter);
                {
                    MeshFilter.sharedMesh = mesh;
                }
                SgtHelper.EndStealthSet();
            }

            if (MeshRenderer.sharedMaterial != material)
            {
                SgtHelper.BeginStealthSet(MeshRenderer);
                {
                    MeshRenderer.sharedMaterial = material;
                }
                SgtHelper.EndStealthSet();
            }

            SgtHelper.SetLocalRotation(transform, rotation);
        }
    }
開發者ID:JasonSlingsCode,項目名稱:Mindjammer,代碼行數:29,代碼來源:SgtRingSegment.cs

示例15: ManualUpdate

    public void ManualUpdate(Mesh mesh, Material material)
    {
        if (Jovian != null)
        {
            if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>();

            if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>();

            if (MeshFilter.sharedMesh != mesh)
            {
                SgtHelper.BeginStealthSet(MeshFilter);
                {
                    MeshFilter.sharedMesh = mesh;
                }
                SgtHelper.EndStealthSet();
            }

            if (MeshRenderer.sharedMaterial != material)
            {
                SgtHelper.BeginStealthSet(MeshRenderer);
                {
                    MeshRenderer.sharedMaterial = material;
                }
                SgtHelper.EndStealthSet();
            }
        }
    }
開發者ID:Battlespud,項目名稱:ducking-octo-shame,代碼行數:27,代碼來源:SgtJovianModel.cs


注:本文中的UnityEngine.MeshFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。