• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Mesh类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mesh的典型用法代码示例。如果您正苦于以下问题:C# Mesh类的具体用法?C# Mesh怎么用?C# Mesh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mesh类属于命名空间,在下文中一共展示了Mesh类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RobotCellUR

 internal RobotCellUR(string name, RobotArm robot, IO io, Plane basePlane, Mesh environment) : base(name, Manufacturers.UR, io, basePlane, environment)
 {
     this.Robot = robot as RobotUR;
     this.DisplayMesh = new Mesh();
     DisplayMesh.Append(robot.DisplayMesh);
     this.DisplayMesh.Transform(this.BasePlane.ToTransform());
 }
开发者ID:visose,项目名称:Robots,代码行数:7,代码来源:RobotCellUR.cs


示例2: Initialize

	public void Initialize (Mesh mesh, Material[] materials, Color32 color, bool additive, float speed, int sortingLayerID, int sortingOrder) {
		StopAllCoroutines();

		gameObject.SetActive(true);


		meshRenderer.sharedMaterials = materials;
		meshRenderer.sortingLayerID = sortingLayerID;
		meshRenderer.sortingOrder = sortingOrder;

		meshFilter.sharedMesh = (Mesh)Instantiate(mesh);

		colors = meshFilter.sharedMesh.colors32;

		if ((color.a + color.r + color.g + color.b) > 0) {
			for (int i = 0; i < colors.Length; i++) {
				colors[i] = color;
			}
		}

		fadeSpeed = speed;

		if (additive)
			StartCoroutine(FadeAdditive());
		else
			StartCoroutine(Fade());
	}
开发者ID:Colorwen,项目名称:spine-runtimes,代码行数:27,代码来源:SkeletonGhostRenderer.cs


示例3: Start

    private void Start()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;

        CreateMesh();
    }
开发者ID:J-Roux,项目名称:project_pathfinder,代码行数:7,代码来源:PointCloud.cs


示例4: 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


示例5: BakePatternDesign

    public void BakePatternDesign()
    {
        List<InstanceData> positions = GeneratePositions();

        lastCount = positions.Count;
        var lastBuiltMesh = BakeMesh(positions.ToArray());

        #if UNITY_EDITOR
        string assetPath;

        if (generatedBakedMesh != null)
        {
            assetPath = UnityEditor.AssetDatabase.GetAssetPath(generatedBakedMesh);
        }
        else
        {
            assetPath = UnityEditor.AssetDatabase.GenerateUniqueAssetPath("Assets/AsteroidBelt.asset");
        }

        UnityEditor.AssetDatabase.CreateAsset(lastBuiltMesh, assetPath);
        UnityEditor.AssetDatabase.Refresh(UnityEditor.ImportAssetOptions.Default);
        UnityEditor.AssetDatabase.SaveAssets();

        generatedBakedMesh = UnityEditor.AssetDatabase.LoadAssetAtPath<Mesh>(assetPath);
        #endif
    }
开发者ID:Ronmenator,项目名称:GalaxyExplorer,代码行数:26,代码来源:AsteroidRing.cs


示例6: Setup

 public void Setup(Mesh m)
 {
     for (int index = 0; index < m.SubMeshes.Count; index++)
     {
         addSubMeshFunc(m.SubMeshes[index]);
     }
 }
开发者ID:justshiv,项目名称:LightSavers,代码行数:7,代码来源:BlockBasedSceneGraph.cs


示例7: Renumber

        /// <summary>
        /// Gets the permutation vector for the Reverse Cuthill-McKee numbering.
        /// </summary>
        /// <param name="mesh">The mesh.</param>
        /// <returns>Permutation vector.</returns>
        public int[] Renumber(Mesh mesh)
        {
            // Algorithm needs linear numbering of the nodes.
            mesh.Renumber(NodeNumbering.Linear);

            return Renumber(new AdjacencyMatrix(mesh));
        }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:12,代码来源:CuthillMcKee.cs


示例8: Prepare

 public override void Prepare(Mesh mesh)
 {
   base.Prepare(mesh);
   this.randomSeed.Set(new Vector3(RandomHelper.Unit(), RandomHelper.Unit(), RandomHelper.Unit()));
   this.material.Diffuse = mesh.Material.Diffuse;
   this.material.Opacity = mesh.Material.Opacity;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:7,代码来源:ShimmeringPointsEffect.cs


示例9: Awake

    void Awake()
    {
        if (mesh == null)
            mesh = new Mesh();
        mf.sharedMesh = mesh;
        mr.sharedMaterial = material;
        var verts = new Vector3[4];
        var tris = new int[] {0, 1, 2, 0, 2, 3};
        var uvs = new Vector2[4];
        verts[0] = targetPosition - size;
        verts[1] = targetPosition + Vector3.up * size.y - Vector3.right * size.x;
        verts[2] = targetPosition + size;
        verts[3] = targetPosition - Vector3.up * size.y + Vector3.right * size.x;

        uvs[0] = new Vector2(0, 0);
        uvs[1] = new Vector2(0, size.y);
        uvs[2] = new Vector2(size.x, size.y);
        uvs[3] = new Vector2(size.x, 0);

        mesh.vertices = verts;
        mesh.triangles = tris;
        mesh.uv = uvs;

        if (!underGround) {
            var bc = gameObject.GetComponent<BoxCollider2D>();
            bc.size = size * 2f;
        }
    }
开发者ID:kirlosev,项目名称:projectjumpius,代码行数:28,代码来源:Ground.cs


示例10: CreateQuad

    static void CreateQuad(Mesh mesh, float W, float H)
    {
        Vector3[] verts = new Vector3[4];
        Vector2[] uvs = new Vector2[4];

        verts[0] = new Vector3(-W/2, H/2, 0);
        verts[1] = new Vector3(W/2, H/2, 0);
        verts[2] = new Vector3(W/2, -H/2, 0);
        verts[3] = new Vector3(-W/2, -H/2, 0);

        uvs[0] = new Vector2(0, 1);
        uvs[1] = new Vector2(1, 1);
        uvs[2] = new Vector3(1, 0);
        uvs[3] = new Vector3(0, 0);

        int[] triangles = new int[6];
        triangles[0] = 0;
        triangles[1] = 1;
        triangles[2] = 3;
        triangles[3] = 3;
        triangles[4] = 1;
        triangles[5] = 2;

        mesh.Clear();
        mesh.vertices = verts;
        mesh.uv = uvs;
        mesh.triangles = triangles;
    }
开发者ID:joeriedel,项目名称:DarkForcesUnity,代码行数:28,代码来源:Game.cs


示例11: Start

    void Start()
    {
        // Create Vector2 vertices
        Vector3[] vertices3D = new Vector3[] {
            new Vector3(5, 10, 0),
            new Vector3(10, -5, 0),
            new Vector3(-7, -3, 0),
            new Vector3(-2, -8, 0),
            new Vector3(9, -10, 0),
        };

        // Use the triangulator to get indices for creating triangles
        MidpointTriangulator tr = new MidpointTriangulator(vertices3D);

        Vector3[] vertices = tr.Triangulate().ToArray();
        int[] indices = new int[vertices.Length];

        // Create the Vector3 vertices
        for (int i = 0; i < vertices.Length; i++)
        {
          indices[i] = i;
        }

        // Create the mesh
        Mesh msh = new Mesh();
        msh.vertices = vertices;
        msh.triangles = indices;
        msh.RecalculateNormals();
        msh.RecalculateBounds();

        // Set up game object with mesh;
        MeshFilter filter = gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter;
        filter.mesh = msh;
    }
开发者ID:jonas-halbach,项目名称:DestructibleGeometry,代码行数:34,代码来源:TriangulatorTest.cs


示例12: createCylinder

    public void createCylinder(float radius, float height, int slices, GameObject go, Matrix4x4 matrix)
    {
        Mesh cylinderMesh = new Mesh();
        vertices = new Vector3[(slices+1) * 4];
        Vector3[] cylPoints1 = createCylinderPoints(radius, height, slices, true);
        Vector3[] cylPoints2 = createCylinderPoints(radius, height, slices, false);
        for (int i = 0; i <cylPoints1.Length; i++) {
            vertices[i] = cylPoints1[i];
        }
        for (int k = 0; k < cylPoints2.Length; k++) {
            vertices[k + cylPoints1.Length] = cylPoints2[k];
        }

        createCylinderNormals(vertices, radius);
        for (int j = 0; j < vertices.Length; j++) {
            vertices[j] = matrix.MultiplyPoint(vertices[j]);
            normals[j] = matrix.MultiplyPoint(normals[j]);
        }

        trianglesIndex = 0;
        createCylinderTriangles(slices+1);

        cylinderMesh.vertices = vertices;
        cylinderMesh.triangles = triangles;
        cylinderMesh.normals = normals;
        cylinderMesh.uv = uvs;

        MeshFilter filter = (MeshFilter)go.GetComponent("MeshFilter");
        filter.mesh = cylinderMesh;
    }
开发者ID:nyuvlg,项目名称:4DExperiments,代码行数:30,代码来源:MeshGenerator.cs


示例13: encode

        public virtual void encode(Mesh m, CtmOutputStream output)
        {
            int vc = m.getVertexCount();

            output.writeLittleInt(MeshDecoder.INDX);
            writeIndicies(m.indices, output);

            output.writeLittleInt(MeshDecoder.VERT);
            writeFloatArray(m.vertices, output, vc * 3, 1);

            // Write normals
            if (m.normals != null) {
                output.writeLittleInt(MeshDecoder.NORM);
                writeFloatArray(m.normals, output, vc, 3);
            }

            foreach (AttributeData ad in m.texcoordinates) {
                output.writeLittleInt(MeshDecoder.TEXC);
                output.writeString(ad.name);
                output.writeString(ad.materialName);
                writeFloatArray(ad.values, output, vc, 2);
            }

            foreach (AttributeData ad in m.attributs) {
                output.writeLittleInt(MeshDecoder.ATTR);
                output.writeString(ad.name);
                writeFloatArray(ad.values, output, vc, 4);
            }
        }
开发者ID:archimy,项目名称:OpenCtm-CSharp,代码行数:29,代码来源:RawEncoder.cs


示例14: Start

    // Use this for initialization
    void Start()
    {
        theTarget = building1;

        initialMesh = building1.GetComponent<MeshFilter>().mesh;
        swapMesh = building1alt.GetComponent<MeshFilter>().mesh;
    }
开发者ID:Haserde,项目名称:Week-4,代码行数:8,代码来源:MeshChange.cs


示例15: Generate

        /// <summary>
        /// Generate the Voronoi diagram from given triangle mesh..
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="bounded"></param>
        protected void Generate(Mesh mesh)
        {
            mesh.Renumber();

            base.edges = new List<HalfEdge>();
            this.rays = new List<HalfEdge>();

            // Allocate space for Voronoi diagram.
            var vertices = new Vertex[mesh.triangles.Count + mesh.hullsize];
            var faces = new Face[mesh.vertices.Count];

            if (factory == null)
            {
                factory = new DefaultVoronoiFactory();
            }

            factory.Initialize(vertices.Length, 2 * mesh.NumberOfEdges, faces.Length);

            // Compute triangles circumcenters.
            var map = ComputeVertices(mesh, vertices);

            // Create all Voronoi faces.
            foreach (var vertex in mesh.vertices.Values)
            {
                faces[vertex.id] = factory.CreateFace(vertex);
            }

            ComputeEdges(mesh, vertices, faces, map);

            // At this point all edges are computed, but the (edge.next) pointers aren't set.
            ConnectEdges(map);

            base.vertices = new List<Vertex>(vertices);
            base.faces = new List<Face>(faces);
        }
开发者ID:cmberryau,项目名称:Triangle.NET-3.5,代码行数:40,代码来源:VoronoiBase.cs


示例16: OnGUI

 void OnGUI()
 {
     if(obj) {
         if(mesh) {
             p.x = EditorGUILayout.Slider("X", p.x, -1.0f, 1.0f);
             p.y = EditorGUILayout.Slider("Y", p.y, -1.0f, 1.0f);
             p.z = EditorGUILayout.Slider("Z", p.z, -1.0f, 1.0f);
             if(p != last_p) { //Detects user input on any of the three sliders
                 //Only create instance of mesh when user changes pivot
                 if(pivotUnchanged) mesh = meshFilter.mesh; pivotUnchanged = false;
                 UpdatePivot();
                 last_p = p;
             }
             if(GUILayout.Button("Center")) { //Set pivot to the center of the mesh bounds
                 //Only create instance of mesh when user changes pivot
                 if(pivotUnchanged) mesh = meshFilter.mesh; pivotUnchanged = false;
                 p = Vector3.zero;
                 UpdatePivot();
                 last_p = p;
             }
             GUILayout.Label("Bounds " + mesh.bounds.ToString());
         } else {
             GUILayout.Label("Selected object does not have a Mesh specified.");
         }
     } else {
         GUILayout.Label("No object selected in Hierarchy.");
     }
 }
开发者ID:BibleUs,项目名称:vgd-monopoly-uniba,代码行数:28,代码来源:SetPivot.cs


示例17: Generate

    private Mesh Generate()
    {
        Debug.Assert(starCount < 65536, "Number of stars must less than 65536");

        var random = new System.Random(seed);

        var mesh = new Mesh();
        var vertices = new Vector3[starCount];
        var indices = new int[starCount];
        var colors = new Color[starCount];

        for (var i = 0; i < starCount; ++i)
        {
            vertices[i] = random.OnUnitSphere();

            indices[i] = i;

            colors[i] = starColors[random.Next(starColors.Length)];
            colors[i].a = (0.2f + 0.8f * MathUtils.NextFloat(random)) * (1 - (Mathf.Abs(vertices[i].y)));
        }

        mesh.vertices = vertices;
        mesh.colors = colors;
        mesh.SetIndices(indices, MeshTopology.Points, 0);

        return mesh;
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:27,代码来源:StarfieldMeshGenerator.cs


示例18: MakeCircle

 public void MakeCircle(int numOfPoints)
 {
     //Debug.Log(numOfPoints + " --- " + AudioToWave.currentValue);
     float angleStep = 360.0f / (float)numOfPoints;
     List<Vector3> vertexList = new List<Vector3>();
     List<int> triangleList = new List<int>();
     Quaternion quaternion = Quaternion.Euler(0.0f, 0.0f, angleStep);
     // Make first triangle.
     vertexList.Add(new Vector3(0.0f, 0.0f, 10f));  // 1. Circle center.
     vertexList.Add(new Vector3(0.0f, 0.5f, 10f));  // 2. First vertex on circle outline (radius = 0.5f)
     vertexList.Add(quaternion * vertexList[1]);     // 3. First vertex on circle outline rotated by angle)
                                                     // Add triangle indices.
     triangleList.Add(0);
     triangleList.Add(1);
     triangleList.Add(2);
     for (int i = 0; i < numOfPoints - 1; i++)
     {
         triangleList.Add(0);                      // Index of circle center.
         triangleList.Add(vertexList.Count - 1);
         triangleList.Add(vertexList.Count);
         vertexList.Add(quaternion * vertexList[vertexList.Count - 1]);
     }
     Mesh mesh = new Mesh();
     mesh.vertices = vertexList.ToArray();
     mesh.triangles = triangleList.ToArray();
     mf.mesh = mesh;
 }
开发者ID:Badeye,项目名称:impulse,代码行数:27,代码来源:AudioToCircle.cs


示例19: OnTriggerEnter

  public void OnTriggerEnter(Collider c)
  {
    if (c.tag == "Player")
    {
      Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
      float playAreaDistance;
      playArea.Raycast(ray, out playAreaDistance);
      enterPoint = ray.GetPoint(playAreaDistance);

      SkinnedMeshRenderer skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>();
      if (skinnedMeshRenderer != null)
      {
        Mesh mesh = new Mesh();
        skinnedMeshRenderer.BakeMesh(mesh);
        Destroy(skinnedMeshRenderer);
        Destroy(GetComponent<Animator>());

        MeshRenderer renderer = gameObject.AddComponent<MeshRenderer>();
        MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
        meshFilter.sharedMesh = mesh;
        renderer.material = bloodMaterial;
        transform.localScale = new Vector3(1, 1, 1);
      }
    }
  }
开发者ID:knuke,项目名称:GoatNinja,代码行数:25,代码来源:Goat.cs


示例20: GenerateMesh

 private static void GenerateMesh(Mesh mesh)
 {
     int num = 1;
     Vector3[] array = new Vector3[4 * num];
     Vector2[] array2 = new Vector2[4 * num];
     int[] array3 = new int[6 * num];
     for (int i = 0; i < num; i++)
     {
         Vector3 zero = Vector3.zero;
         int num2 = 4 * i;
         array[num2] = zero;
         array[num2 + 1] = zero;
         array[num2 + 2] = zero;
         array[num2 + 3] = zero;
         array2[num2] = new Vector2(0f, 0f);
         array2[num2 + 1] = new Vector2(0f, 1f);
         array2[num2 + 2] = new Vector2(1f, 0f);
         array2[num2 + 3] = new Vector2(1f, 1f);
         int num3 = 6 * i;
         array3[num3] = 0 + num2;
         array3[num3 + 1] = 1 + num2;
         array3[num3 + 2] = 2 + num2;
         array3[num3 + 3] = 2 + num2;
         array3[num3 + 4] = 1 + num2;
         array3[num3 + 5] = 3 + num2;
     }
     mesh.vertices = array;
     mesh.uv = array2;
     mesh.triangles = array3;
     mesh.RecalculateNormals();
     mesh.bounds = new Bounds(Vector3.zero, Vector3.one);
     mesh.Optimize();
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:33,代码来源:SheenBillboard.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MeshBuilder类代码示例发布时间:2022-05-24
下一篇:
C# MersenneTwister类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap