本文整理汇总了C#中Mesh类的典型用法代码示例。如果您正苦于以下问题:C# Mesh类的具体用法?C# Mesh怎么用?C# Mesh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mesh类属于命名空间,在下文中一共展示了Mesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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());
}
示例3: Start
private void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
CreateMesh();
}
示例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);
}
示例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
}
示例6: Setup
public void Setup(Mesh m)
{
for (int index = 0; index < m.SubMeshes.Count; index++)
{
addSubMeshFunc(m.SubMeshes[index]);
}
}
示例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));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例14: Start
// Use this for initialization
void Start()
{
theTarget = building1;
initialMesh = building1.GetComponent<MeshFilter>().mesh;
swapMesh = building1alt.GetComponent<MeshFilter>().mesh;
}
示例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);
}