Example #1
0
        private static Vector2[] JustifyUVs(Vector2[] uvs, pb_UV.Justify j)
        {
            Vector2 amt = new Vector2(0f, 0f);

            switch (j)
            {
            case pb_UV.Justify.Left:
                amt = new Vector2(pb_Math.SmallestVector2(uvs).x, 0f);
                break;

            case pb_UV.Justify.Right:
                amt = new Vector2(pb_Math.LargestVector2(uvs).x - 1f, 0f);
                break;

            case pb_UV.Justify.Top:
                amt = new Vector2(0f, pb_Math.LargestVector2(uvs).y - 1f);
                break;

            case pb_UV.Justify.Bottom:
                amt = new Vector2(0f, pb_Math.SmallestVector2(uvs).y);
                break;

            case pb_UV.Justify.Center:
                amt = pb_Math.Average(uvs) - (new Vector2(.5f, .5f));
                break;
            }

            for (int i = 0; i < uvs.Length; i++)
            {
                uvs[i] -= amt;
            }

            return(uvs);
        }
Example #2
0
 private static void SetJustify(pb_UV.Justify justify, pb_Object[] sel)
 {
     pbUndo.RecordObjects(sel, "Justify UVs");
     for (int i = 0; i < sel.Length; i++)
     {
         foreach (pb_Face q in sel[i].SelectedFaces)
         {
             q.uv.justify = justify;
         }
     }
 }
Example #3
0
 private void SetJustify(pb_UV.Justify justify, pb_Object[] sel)
 {
     for (int i = 0; i < sel.Length; i++)
     {
         foreach (pb_Face q in sel[i].SelectedFaces)
         {
             q.uv.justify = justify;
         }
         sel[i].RefreshUV(SelectedFacesInEditZone[i]);
     }
 }
 // The pb_SerializedMesh constructor is used to deserialize values.
 public pb_SerializableUV(SerializationInfo info, StreamingContext context)
 {
     this.useWorldSpace		= (bool)			info.GetValue("useWorldSpace", 	typeof(bool));
     this.flipU				= (bool)			info.GetValue("flipU", 			typeof(bool));
     this.flipV				= (bool)			info.GetValue("flipV", 			typeof(bool));
     this.swapUV				= (bool)			info.GetValue("swapUV", 		typeof(bool));
     this.fill				= (pb_UV.Fill)		info.GetValue("fill", 			typeof(pb_UV.Fill));
     this.scale				= (pb_Vector2) 		info.GetValue("scale", 			typeof(pb_Vector2));
     this.offset				= (pb_Vector2) 		info.GetValue("offset", 		typeof(pb_Vector2));
     this.rotation			= (float)			info.GetValue("rotation", 		typeof(float));
     this.justify			= (pb_UV.Justify)	info.GetValue("justify", 		typeof(pb_UV.Justify));
 }
 public pb_SerializableUV(pb_UV uv)
 {
     this.useWorldSpace		= uv.useWorldSpace;
     this.flipU				= uv.flipU;
     this.flipV				= uv.flipV;
     this.swapUV				= uv.swapUV;
     this.fill				= uv.fill;
     this.scale				= uv.scale;
     this.offset				= uv.offset;
     this.rotation			= uv.rotation;
     this.justify			= uv.justify;
 }