예제 #1
0
        /**
         * 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);
        }
예제 #2
0
	/**
	 * 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;
	}
예제 #3
0
        /**
         * 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);
        }
	/**
	 * 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;
	}