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


C# pb_Face.ShiftIndicesToZero方法代码示例

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


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

示例1: AppendFace

	/**
	 * Append a new face to the pb_Object using sharedIndex array to set the face indices to sharedIndex groups.
	 */
	public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, Color[] c, Vector2[] u, pb_Face face, int[] sharedIndex)
	{
		int vertexCount = pb.vertexCount;

		Vector3[] _verts = new Vector3[vertexCount + v.Length];
		Color[] _colors = new Color[vertexCount + c.Length];
		Vector2[] _uvs = new Vector2[pb.uv.Length + u.Length];

		List<pb_Face> _faces = new List<pb_Face>(pb.faces);
		pb_IntArray[] sharedIndices = pb.sharedIndices;

		// copy new vertices
		System.Array.Copy(pb.vertices, 0, _verts, 0, vertexCount);
		System.Array.Copy(v, 0, _verts, vertexCount, v.Length);

		// copy new colors
		System.Array.Copy(pb.colors, 0, _colors, 0, vertexCount);
		System.Array.Copy(c, 0, _colors, vertexCount, c.Length);

		// copy new uvs
		System.Array.Copy(pb.uv, 0, _uvs, 0, pb.uv.Length);
		System.Array.Copy(u, 0, _uvs, pb.uv.Length, u.Length);

		face.ShiftIndicesToZero();
		face.ShiftIndices(vertexCount);
		face.RebuildCaches();

		_faces.Add(face);

		for(int i = 0; i < sharedIndex.Length; i++)
			pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, sharedIndex[i], i+vertexCount);

		pb.SetVertices( _verts );
		pb.SetColors( _colors );
		pb.SetUV( _uvs );
		
		pb.SetSharedIndices(sharedIndices);
		pb.SetFaces(_faces.ToArray());

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

示例2: AppendFace

	/**
	 * Append a new face to the pb_Object.
	 */
	public static pb_Face AppendFace(this pb_Object pb, Vector3[] v, pb_Face face, int[] sharedIndex)
	{
		List<Vector3> _verts = new List<Vector3>(pb.vertices);
		List<pb_Face> _faces = new List<pb_Face>(pb.faces);
		pb_IntArray[] sharedIndices = pb.sharedIndices;
		int vertexCount = pb.vertexCount;

		_verts.AddRange(v);
		face.ShiftIndicesToZero();
		face.ShiftIndices(vertexCount);
		face.RebuildCaches();
		_faces.Add(face);

		// Dictionary<int, int> grp = new Dictionary<int, int>();	// this allows append face to add new vertices to a new shared index group
		// 														// if the sharedIndex is negative and less than -1, it will create new gorup
		// 														// that other sharedIndex members can then append themselves to.
		for(int i = 0; i < sharedIndex.Length; i++)
		{
			// if(sharedIndex[i] < -1)
			// {
			// 	if(grp.ContainsKey(sharedIndex[i]))
			// 		AddIndexToSharedIndexArray(grp[sharedIndex[i]], i+vertexCount);
			// 	else
			// 		grp.Add(sharedIndex[i], AddIndexToSharedIndexArray(sharedIndex[i], i+vertexCount));
			// }
			// else
				pb_IntArrayUtility.AddValueAtIndex(ref sharedIndices, sharedIndex[i], i+vertexCount);
		}

		pb.SetSharedIndices(sharedIndices);
		pb.SetVertices(_verts.ToArray() );
		pb.SetFaces(_faces.ToArray());

		pb.ToMesh();

		return face;
	}
开发者ID:BasmanovDaniil,项目名称:RoyalDefenestrator,代码行数:40,代码来源:pbAppendDelete.cs

示例3: RefreshSelectedFacePreview

	void RefreshSelectedFacePreview()
	{
		pb_Face face = new pb_Face(currentSelection.face);	// Copy the currently selected face
		face.ShiftIndicesToZero();							// Shift the selected face indices to zero

		Vector3[] verts = currentSelection.pb.VerticesInWorldSpace(
			currentSelection.face);							// Copy the currently selected vertices in world space.
															// World space so that we don't have to apply transforms
															// to match the current selection.
															

		// Now go through and move the verts we just grabbed out about .1m from the original face.
		Vector3 normal = pb_Math.PlaneNormal(verts);

		for(int i = 0; i < verts.Length; i++)
			verts[i] += normal.normalized * .01f;

		if(preview)
			Destroy(preview.gameObject);

		preview = ProBuilder.CreateObjectWithVerticesFaces(verts, new pb_Face[1]{face});
		preview.SetName("Preview");
		preview.SetObjectMaterial(previewMaterial);
	}
开发者ID:GDxU,项目名称:incomplete-richman,代码行数:24,代码来源:RuntimeEdit.cs


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