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


C# pb_Face.Concat方法代码示例

本文整理汇总了C#中pb_Face.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# pb_Face.Concat方法的具体用法?C# pb_Face.Concat怎么用?C# pb_Face.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pb_Face的用法示例。


在下文中一共展示了pb_Face.Concat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StairGenerator


//.........这里部分代码省略.........

			vertices[v+4] = new Vector3(x0, y1, z0);
			vertices[v+5] = new Vector3(x1, y1, z0);
			vertices[v+6] = new Vector3(x0, y1, z1);
			vertices[v+7] = new Vector3(x1, y1, z1);

			faces[t+0] = new pb_Face( new int[] { 	v + 0,
													v + 1,
													v + 2,
													v + 1,
													v + 3,
													v + 2 });

			faces[t+1] = new pb_Face( new int[] { 	v + 4,
													v + 5,
													v + 6,
													v + 5,
													v + 7,
													v + 6 });

			v += 8;
			t += 2;
		}

		/// sides
		if(buildSides)
		{
			/// first step is special case - only needs a quad, but all other steps need
			/// a quad and tri.
			float x = 0f;

			for(int side = 0; side < 2; side++)
			{
				Vector3[] sides_v = new Vector3[ steps * 4 + (steps - 1) * 3 ];
				pb_Face[] sides_f = new pb_Face[ steps + steps-1 ];

				int sv = 0, st = 0;

				for(int i = 0; i < steps; i++)
				{
					float y0 = (Mathf.Max(i, 1) / (float) steps) * size.y;
					float y1 = ((i+1) / (float) steps) * size.y;

					float z0 = (i / (float)steps) * size.z;
					float z1 = ((i+1) / (float) steps) * size.z;

					sides_v[sv+0] = new Vector3(x, 0f, z0);
					sides_v[sv+1] = new Vector3(x, 0f, z1);
					sides_v[sv+2] = new Vector3(x, y0, z0);
					sides_v[sv+3] = new Vector3(x, y1, z1);

					sides_f[st++] = new pb_Face( side % 2 == 0 ?
						new int[] { v+0, v+1, v+2, v+1, v+3, v+2 } :
						new int[] { v+2, v+1, v+0, v+2, v+3, v+1 } );

					sides_f[st-1].textureGroup = side + 1;

					v += 4;
					sv += 4;

					/// that connecting triangle
					if(i > 0)
					{
						sides_v[sv+0] = new Vector3(x, y0, z0);
						sides_v[sv+1] = new Vector3(x, y1, z0);
						sides_v[sv+2] = new Vector3(x, y1, z1);

						sides_f[st++] = new pb_Face( side % 2 == 0 ? 
							new int[] { v+2, v+1, v+0 } :
							new int[] { v+0, v+1, v+2 } );

						sides_f[st-1].textureGroup = side + 1;

						v += 3;
						sv += 3;
					}
				}

				vertices = vertices.Concat(sides_v);
				faces = faces.Concat(sides_f);

				x += size.x;
			}

			// add that last back face
			vertices = vertices.Concat(new Vector3[] {
				new Vector3(0f, 0f, size.z),
				new Vector3(size.x, 0f, size.z),
				new Vector3(0f, size.y, size.z),
				new Vector3(size.x, size.y, size.z)
				});

			faces = faces.Add(new pb_Face(new int[] {v+0, v+1, v+2, v+1, v+3, v+2}));
		}

		pb_Object pb = pb_Object.CreateInstanceWithVerticesFaces(vertices, faces);
		pb.SetName("Stairs"); 

		return pb;	
	}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:101,代码来源:pb_ShapeGenerator.cs

示例2: CurvedStairGenerator


//.........这里部分代码省略.........
			/// a quad and tri.
			float x = noInnerSide ? innerRadius + stairWidth : innerRadius;;

			for(int side = (noInnerSide ? 1 : 0); side < 2; side++)
			{
				Vector3[] sides_v = new Vector3[ steps * 4 + (steps - 1) * 3 ];
				pb_Face[] sides_f = new pb_Face[ steps + steps-1 ];

				int sv = 0, st = 0;

				for(int i = 0; i < steps; i++)
				{
					float inc0 = (i / (float) steps) * cir;
					float inc1 = ((i + 1) / (float) steps) * cir;

					float h0 = ((Mathf.Max(i, 1) / (float) steps) * height);
					float h1 = (((i+1) / (float) steps) * height);

					Vector3 v0 = new Vector3(-Mathf.Cos(inc0), 0f, Mathf.Sin(inc0) ) * x;
					Vector3 v1 = new Vector3(-Mathf.Cos(inc1), 0f, Mathf.Sin(inc1) ) * x;	

					sides_v[sv+0] = v0;
					sides_v[sv+1] = v1;
					sides_v[sv+2] = v0;
					sides_v[sv+3] = v1;

					sides_v[sv+0].y = 0f;
					sides_v[sv+1].y = 0f;
					sides_v[sv+2].y = h0;
					sides_v[sv+3].y = h1;

					sides_f[st++] = new pb_Face( side % 2 == 0 ?
						new int[] { v+2, v+1, v+0, v+2, v+3, v+1 } :
						new int[] { v+0, v+1, v+2, v+1, v+3, v+2 } );

					
					v += 4;
					sv += 4;

					/// that connecting triangle
					if(i > 0)
					{
						sides_f[st-1].textureGroup = (side * steps) + i;

						sides_v[sv+0] = v0;
						sides_v[sv+1] = v1;
						sides_v[sv+2] = v0;
						sides_v[sv+0].y = h0;
						sides_v[sv+1].y = h1;
						sides_v[sv+2].y = h1;

						sides_f[st++] = new pb_Face( side % 2 == 0 ? 
							new int[] { v+2, v+1, v+0 } :
							new int[] { v+0, v+1, v+2 } );

						sides_f[st-1].textureGroup = (side * steps) + i;

						v += 3;
						sv += 3;
					}
				}

				vertices = vertices.Concat(sides_v);
				faces = faces.Concat(sides_f);

				x += stairWidth;
			}

			// // add that last back face
			float cos = -Mathf.Cos(cir), sin = Mathf.Sin(cir);

			vertices = vertices.Concat(new Vector3[] 
			{
				new Vector3(cos, 0f, sin) * innerRadius,
				new Vector3(cos, 0f, sin) * outerRadius,
				new Vector3(cos * innerRadius, height, sin * innerRadius),
				new Vector3(cos * outerRadius, height, sin * outerRadius)
				});

			faces = faces.Add(new pb_Face(new int[] {v+2, v+1, v+0, v+2, v+3, v+1}));
		}

		if(circumference < 0f)
		{
			Vector3 flip = new Vector3(-1f, 1f, 1f);

			for(int i = 0; i < vertices.Length; i++)
			{
				vertices[i].Scale(flip);
			}

			foreach(pb_Face f in faces)
				f.ReverseIndices();
		}

		pb_Object pb = pb_Object.CreateInstanceWithVerticesFaces(vertices, faces);
		pb.SetName("Stairs"); 

		return pb;	
	}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:101,代码来源:pb_ShapeGenerator.cs


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