Ejemplo n.º 1
0
    /**
     *	\brief Duplicates and mirrors the passed pb_Object.
     *	@param pb The donor pb_Object.
     *	@param axe The axis to mirror the object on.
     *	\returns The newly duplicated pb_Object.
     *	\sa ProBuilder.Axis
     */
    public static pb_Object Mirror(pb_Object pb, Vector3 scale)
    {
        pb_Object p = ProBuilder.CreateObjectWithObject(pb);

        p.MakeUnique();

        p.transform.parent = pb.transform.parent;

        p.transform.position      = pb.transform.position;
        p.transform.localRotation = pb.transform.localRotation;

        Vector3 lScale = p.gameObject.transform.localScale;

        p.transform.localScale = new Vector3(lScale.x * scale.x, lScale.y * scale.y, lScale.z * scale.z);

        // if flipping on an odd number of axes, flip winding order
        if ((scale.x * scale.y * scale.z) < 0)
        {
            p.ReverseWindingOrder(p.faces);
        }

        p.FreezeScaleTransform();

        p.Refresh();
        p.GenerateUV2(true);

        pb_Editor_Utility.InitObjectFlags(p, ColliderType.MeshCollider, pb.entity.entityType);
        return(p);
    }
Ejemplo n.º 2
0
    /**
     *	\brief Duplicates and mirrors the passed pb_Object.
     *	@param pb The donor pb_Object.
     *	@param axe The axis to mirror the object on.
     *	\returns The newly duplicated pb_Object.
     *	\sa ProBuilder.Axis
     */
    public static pb_Object Mirror(pb_Object pb, Vector3 scale)
    {
        pb_Object p = ProBuilder.CreateObjectWithObject(pb);

        // p.SetName(p.GetName()+"-DUPLICATE-");

        p.transform.position      = pb.transform.position;
        p.transform.localRotation = pb.transform.localRotation;

        Vector3 lScale = p.gameObject.transform.localScale;

        p.transform.localScale = new Vector3(lScale.x * scale.x, lScale.y * scale.y, lScale.z * scale.z);

        // if flipping on an odd number of axes, flip winding order
        if ((scale.x * scale.y * scale.z) < 0)
        {
            p.ReverseWindingOrder();
        }

        p.FreezeScaleTransform();

        EditorUtility.SetDirty(p);

        return(p);
    }
Ejemplo n.º 3
0
        /**
         *	\brief Duplicates and mirrors the passed pb_Object.
         *	@param pb The donor pb_Object.
         *	@param axe The axis to mirror the object on.
         *	\returns The newly duplicated pb_Object.
         *	\sa ProBuilder.Axis
         */
        public static pb_Object Mirror(pb_Object pb, Vector3 scale)
        {
            pb_Object p = pb_Object.InitWithObject(pb);

            p.MakeUnique();

            p.transform.parent = pb.transform.parent;

            p.transform.localRotation = pb.transform.localRotation;

            Vector3 lScale = p.gameObject.transform.localScale;

            p.transform.localScale = new Vector3(lScale.x * scale.x, lScale.y * scale.y, lScale.z * scale.z);

            // if flipping on an odd number of axes, flip winding order
            if ((scale.x * scale.y * scale.z) < 0)
            {
                p.ReverseWindingOrder(p.faces);
            }

            p.FreezeScaleTransform();

            p.transform.localScale = pb.transform.localScale;

            Collider     col     = pb.GetComponent <Collider>();
            ColliderType colType = ColliderType.None;

            if (col != null)
            {
                if (col is MeshCollider)
                {
                    colType = ColliderType.MeshCollider;
                }
                else
                {
                    colType = ColliderType.BoxCollider;
                }
            }

            pb_Editor_Utility.InitObjectFlags(p, colType, pb.GetComponent <pb_Entity>().entityType);

            p.ToMesh();
            p.Refresh();

            // InitObjectFlags runs ScreenCenter()
            p.transform.position = pb.transform.position;

            Undo.RegisterCreatedObjectUndo(p.gameObject, "Mirror Object");

            return(p);
        }