MESH

本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/Unity_meshtest.html 

A class that allows creating or modifying meshes from scripts.
一个允许通过脚本来创建和修改meshes的类.
Meshes contain vertices and multiple triangle arrays. See the Procedural example project for examples of using the mesh interface.
网格(meshes)包括顶点和多个三角形数组。参考Procedural example project中的例子来使用网格的界面。

The triangle arrays are simply indices into the vertex arrays; three indices for each triangle.
三角形数组仅仅是顶点的索引数组,每个三角形包含三个索引。

For every vertex there can be a normal, two texture coordinates, color and tangent. These are optional though and can be removed at will. All vertex information is stored in separate arrays of the same size, so if your mesh has 10 vertices, you would also have 10-size arrays for normals and other attributes.
每个顶点可以有一条法线,两个纹理坐标,及颜色和切线。虽然这些是可选的,但是也可以去掉。所有的顶点信息是被储存在单独的同等规格的数组中,所以如果你的网格(mesh)有10个顶点,你同样应该有大小为10的数组来存储法线和其它属性。

There are probably 3 things you might want to use the modifyable mesh interface for:
大概有3件事情是你想要使用可修改的表格.

1. Building a mesh from scratch: should always be done in the following order: 1) assign vertices 2) assign triangles
新建立一个网格 :应该总是按照这个顺序来做:
1)为顶点数组赋值
2)为三角形数组赋值

示例:

clipboard

2. Modifying vertex attributes every frame: 1) get vertices, 2) modify them, 3) assign them back to the mesh.

每帧修改定点属性
1)获取顶点数组
2)修改它们
3)把它们放回网格
示例:

clipboard[1]

3. Continously changing the mesh triangles and vertices: 1) call Clear to start fresh, 2) assign vertices and other attributes, 3) assign triangle indices.

连续的改变网格的三角形数组值和顶点值
1)使用Clean刷新
2)赋予顶点值和其他属性
3)赋予索引值

It is important to call Clear before assigning new vertices or triangles. Unity always checks the supplied triangle indices whether they don't reference out of bounds vertices. Calling Clear then assigning vertices then triangles makes sure you never have out of bounds data.
调用Clean函数在赋予新的顶点值和三角形索引值之前是非常重要的,Unity总是检查三角形的索引值,判断它们是否超出边界。调用Clear函数后,给顶点赋值,再给三角形数组赋值,以确保没有超出数组的边界。
示例:

clipboard[2]

本文由博主(YinaPan)原创或者转载,如若转载请务必注明出处,谢谢合作!
原文地址:https://www.cnblogs.com/YinaPan/p/Unity_meshtest.html