コード例 #1
0
        void RefreshSelectedFacePreview()
        {
            pb_Face face = new pb_Face(currentSelection.face);                  // Copy the currently selected face

            face.ShiftIndicesToZero();                                          // Shift the selected face indices to zero

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

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

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

            if (preview)
            {
                Destroy(preview.gameObject);
            }

            preview = pb_Object.CreateInstanceWithVerticesFaces(verts, new pb_Face[1] {
                face
            });
            preview.SetFaceMaterial(preview.faces, previewMaterial);
            preview.ToMesh();
            preview.Refresh();
        }
コード例 #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
ファイル: pbAppendDelete.cs プロジェクト: itubeasts/I-eaT-U
	/**
	 * 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;
	}
コード例 #4
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);
        }
コード例 #5
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;
	}
コード例 #6
0
	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);
	}