Пример #1
0
 public OutlineItem(Double dateValue, Double price, int index, PivotType type)
 {
     Price       = price;
     DateValue   = dateValue;
     Type        = type;
     RecordIndex = index;
 }
Пример #2
0
 public OutlineItem(DateTimeOffset time, Double price, int index, PivotType type)
 {
     Price       = price;
     Time        = time;
     Type        = type;
     RecordIndex = index;
 }
Пример #3
0
 public OutlineItem(OutlineItem original, double newPrice)
 {
     Price       = newPrice;
     DateValue   = original.DateValue;
     Type        = original.Type;
     RecordIndex = original.RecordIndex;
 }
Пример #4
0
        public static SingleQuery SetPivot(this SingleQuery singleQuery, PivotType type,
                                           string mainValue, params string[] secondaryValues)
        {
            singleQuery.NodesList.SetPivot(type, mainValue, secondaryValues);

            return(singleQuery);
        }
Пример #5
0
        public static Vector2 Convert(PivotType pivotType)
        {
            var x = 0f;
            var y = 0f;

            if (pivotType.HasFlag(PFlags.Top))
            {
                y = 1f;
            }
            else if (pivotType.HasFlag(PFlags.Middle))
            {
                y = 0.5f;
            }

            if (pivotType.HasFlag(PFlags.Right))
            {
                x = 1f;
            }
            else if (pivotType.HasFlag(PFlags.Center))
            {
                x = 0.5f;
            }

            return(new Vector2(x, y));
        }
Пример #6
0
 private void SetSideMaterial(SuperCube aCube, PivotType aSide, Material aMaterial)
 {
     if (aSide == PivotType.None)
     {
         return;
     }
     else if (aSide == PivotType.All)
     {
         aCube.GetComponent <Renderer>().sharedMaterial = aMaterial;
     }
     else if ((aSide & PivotType.Back) > 0)
     {
         aCube.OverrideBack = aMaterial;
     }
     else if ((aSide & PivotType.Front) > 0)
     {
         aCube.OverrideFront = aMaterial;
     }
     else if ((aSide & PivotType.Top) > 0)
     {
         aCube.OverrideTop = aMaterial;
     }
     else if ((aSide & PivotType.Bottom) > 0)
     {
         aCube.OverrideBottom = aMaterial;
     }
     else if ((aSide & PivotType.Right) > 0)
     {
         aCube.OverrideRight = aMaterial;
     }
     else if ((aSide & PivotType.Left) > 0)
     {
         aCube.OverrideLeft = aMaterial;
     }
 }
Пример #7
0
        /// <summary>
        /// Sets the component display pivot to the specified type.
        /// The only supported types are either left or right.
        /// </summary>
        public void SetSide(PivotType side)
        {
            if (side != PivotType.Left && side != PivotType.Right)
            {
                return;
            }

            bool       isLeftSide      = side == PivotType.Left;
            float      forwardDir      = isLeftSide ? 1f : -1f;
            AnchorType stretchedAnchor = isLeftSide ? AnchorType.LeftStretch : AnchorType.RightStretch;
            AnchorType oppositeAnchor  = isLeftSide ? AnchorType.Right : AnchorType.Left;

            this.Pivot = side;

            buttonTrigger.X = 4f * forwardDir;

            indicatorContainer.Anchor = stretchedAnchor;
            indicatorContainer.Pivot  = side;
            indicatorContainer.X      = -32f * forwardDir;

            bgFlipEffect.Component.horizontal     = !isLeftSide;
            shadowFlipEffect.Component.horizontal = !isLeftSide;
            shadowSprite.SetOffsetHorizontal(-4, -4);

            iconSprite.Anchor = oppositeAnchor;
            iconSprite.X      = -64 * forwardDir;
        }
Пример #8
0
        private static void AddExtrudeCube(SuperCube aBox, Vector3 aAt, PivotType aPivot, Vector3 aSize)
        {
            GameObject go  = SuperCube.CreatePivot(aBox.transform.InverseTransformPoint(aAt), aPivot, aSize, aBox.GetComponent <Renderer>().sharedMaterial);
            Vector3    pos = go.transform.position;

            go.transform.parent        = aBox.transform;
            go.transform.localPosition = pos;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;
            go.transform.parent        = aBox.transform.parent;
            go.isStatic = aBox.gameObject.isStatic;
            go.tag      = aBox.gameObject.tag;
            go.layer    = aBox.gameObject.layer;

            SuperCube box = go.GetComponent <SuperCube>();

            box.SliceFaces        = aBox.SliceFaces;
            box.SliceDistance     = aBox.SliceDistance;
            box.WallUVType        = aBox.WallUVType;
            box.WallUVTile        = aBox.WallUVTile;
            box.WallUVOffset      = aBox.WallUVOffset;
            box.TopBottomUVType   = aBox.TopBottomUVType;
            box.TopBottomUVTile   = aBox.TopBottomUVTile;
            box.TopBottomUVOffset = aBox.TopBottomUVOffset;
            box.OverrideTop       = aBox.OverrideBack;
            box.OverrideBottom    = aBox.OverrideBottom;
            box.OverrideFront     = aBox.OverrideFront;
            box.OverrideLeft      = aBox.OverrideLeft;
            box.OverrideRight     = aBox.OverrideRight;
            box.OverrideTop       = aBox.OverrideTop;
            box.Build(true);

            Selection.activeGameObject = go;
            EditorGUIUtility.PingObject(go);
        }
Пример #9
0
    /// <summary>
    /// Creates a SuperCube game object using a pivot point to determine location, and assigns the given data! This function will build the cube mesh right away.
    /// </summary>
    /// <param name="aPivotPt">Location in space for the pivot point to be placed.</param>
    /// <param name="aPivotType">A bit mask defining where on the cube the pivot is placed. Opposing sides indicate to center along that axis.</param>
    /// <param name="aSize">The width, height, and depth of the SuperCube.</param>
    /// <param name="aMaterial">The default material for the entire SuperCube.</param>
    /// <param name="aWallUV">The type of UV calculations to use for the +X, -X, +Z, -Z faces.</param>
    /// <param name="aTopBottomUV">The type of UV calculations to use for the +Y, -Y faces.</param>
    /// <param name="aSliceDistance">How far apart shall we try and place vertex slices on the faces? floor(size/sliceDistance)</param>
    /// <param name="aHideFaces">A bit mask describing which faces should be hidden.</param>
    /// <param name="aOverrideTop">Material override for the +Y face.</param>
    /// <param name="aOverrideBottom">Material override for the -Y face.</param>
    /// <param name="aOverrideLeft">Material override for the -X face.</param>
    /// <param name="aOverrideRight">Material override for the +X face.</param>
    /// <param name="aOverrideFront">Material override for the -Z face.</param>
    /// <param name="aOverrideBack">Material override for the +Z face.</param>
    /// <returns>A GameObject named "SuperCube" with a fully built SuperCube, MeshFilter, Renderer, and BoxCollider component!</returns>
    public static GameObject CreatePivot(Vector3 aPivotPt, PivotType aPivotType, Vector3 aSize, Material aMaterial, UVType aWallUV = UVType.WorldCoordinates, UVType aTopBottomUV = UVType.WorldCoordinates, float aSliceDistance = 0, PivotType aHideFaces = PivotType.None, Material aOverrideTop = null, Material aOverrideBottom = null, Material aOverrideLeft = null, Material aOverrideRight = null, Material aOverrideFront = null, Material aOverrideBack = null)
    {
        Vector3 halfSize = aSize / 2;
        Vector3 point    = aPivotPt;

        if ((aPivotType & PivotType.Top) > 0)
        {
            point.y -= halfSize.y;
        }
        if ((aPivotType & PivotType.Bottom) > 0)
        {
            point.y += halfSize.y;
        }
        if ((aPivotType & PivotType.Left) > 0)
        {
            point.x += halfSize.x;
        }
        if ((aPivotType & PivotType.Right) > 0)
        {
            point.x -= halfSize.x;
        }
        if ((aPivotType & PivotType.Front) > 0)
        {
            point.z += halfSize.z;
        }
        if ((aPivotType & PivotType.Back) > 0)
        {
            point.z -= halfSize.z;
        }

        return(Create(point, aSize, aMaterial, aWallUV, aTopBottomUV, aSliceDistance, aHideFaces, aOverrideTop, aOverrideBottom, aOverrideLeft, aOverrideRight, aOverrideFront, aOverrideBack));
    }
Пример #10
0
        protected override void OnStart()
        {
            if (base.Widget == null)
            {
                return;
            }
            Matrix4 identity = Matrix4.Identity;

            identity.M41            = base.Widget.X;
            identity.M42            = base.Widget.Y;
            base.Widget.Transform3D = identity;
            this.originalPosition   = identity;
            this.originalPivotType  = base.Widget.PivotType;
            base.Widget.PivotType   = PivotType.MiddleCenter;
            this.pivotOffsetX       = base.Widget.Width / 2f;
            this.pivotOffsetY       = base.Widget.Height / 2f;
            this.fromX              = base.Widget.X;
            this.fromY              = base.Widget.Y;
            this.outsideMargin      = (float)Math.Sqrt((double)(this.pivotOffsetX * this.pivotOffsetX + this.pivotOffsetY * this.pivotOffsetY));
            this.targetRadianSpeed  = 0f;
            this.targetRadian       = 0f;
            this.targetOffsetXSpeed = 0f;
            this.targetOffsetX      = 0f;
            this.targetOffsetYSpeed = 0f;
            this.targetOffsetY      = 0f;
            this.T        = 40f;
            this.leftTime = this.T / (14f + 4f * (float)this.rand.NextDouble());
            this.setupLeftPos();
            base.Widget.Visible = true;
        }
Пример #11
0
 public OutlineItem(OutlineItem original, double newPrice)
 {
     Price       = newPrice;
     Time        = original.Time;
     Type        = PivotType.Unknown;
     RecordIndex = original.RecordIndex;
 }
Пример #12
0
		internal static void Handle(PivotType aSides, Transform aTransform, bool aLockX, bool aLockY, bool aLockZ, Vector3 aSnap, ref Vector3 lbf, ref Vector3 rtb, Handles.DrawCapFunction aCap) {
			Vector3 pt = new Vector3(0,0,0);
			Vector3 mask = new Vector3(aLockX?1:0, aLockY?1:0, aLockZ?1:0);
			if ((aSides & PivotType.Left  ) > 0) pt.x = lbf.x;
			if ((aSides & PivotType.Right ) > 0) pt.x = rtb.x;
			if ((aSides & PivotType.Top   ) > 0) pt.y = rtb.y;
			if ((aSides & PivotType.Bottom) > 0) pt.y = lbf.y;
			if ((aSides & PivotType.Front ) > 0) pt.z = lbf.z;
			if ((aSides & PivotType.Back  ) > 0) pt.z = rtb.z;
			pt = aTransform.TransformPoint(pt);
			
			Vector3 result = Handles.FreeMoveHandle(pt, Quaternion.identity, HandleUtility.GetHandleSize(pt) * mHandleSize, Vector3.zero, aCap);
			if (result != pt) {
				Vector3 dir = SuperCubeEditorUtil.CreateBillboardNormal(pt, aLockX, aLockY, aLockZ);
				result = SuperCubeEditorUtil.SnapVector(Vector3.Scale(SuperCubeEditorUtil.GetPlanePoint(result, new Plane(dir, pt)), mask), aSnap);
				result = aTransform.InverseTransformPoint(result);
				
				if ((aSides & PivotType.Left  ) > 0) lbf.x = result.x;
				if ((aSides & PivotType.Right ) > 0) rtb.x = result.x;
				if ((aSides & PivotType.Top   ) > 0) rtb.y = result.y;
				if ((aSides & PivotType.Bottom) > 0) lbf.y = result.y;
				if ((aSides & PivotType.Front ) > 0) lbf.z = result.z;
				if ((aSides & PivotType.Back  ) > 0) rtb.z = result.z;
			}
		}
Пример #13
0
        public PivotLevels(Bars bars, PivotType type, string description)
            : base(bars, description)
        {
            DataSeries Pivot    = new DataSeries(bars, "Daily Pivot Level");
            DataSeries DayHigh  = new DataSeries(bars, "Previous Day's High Level");
            DataSeries DayClose = new DataSeries(bars, "Previous Day's Close Level");
            DataSeries DayLow   = new DataSeries(bars, "Previous Day's Low Level");
            DataSeries R1       = new DataSeries(bars, "Resistance Pivot Level 1");
            DataSeries S1       = new DataSeries(bars, "Support Pivot Level 1");
            DataSeries R2       = new DataSeries(bars, "Resistance Pivot Level 2");
            DataSeries S2       = new DataSeries(bars, "Support Pivot Level 2");
            DataSeries R3       = new DataSeries(bars, "Resistance Pivot Level 3");
            DataSeries S3       = new DataSeries(bars, "Support Pivot Level 3");
            DataSeries result   = new DataSeries(bars, "Result");

            base.FirstValidValue = 1;

            if (!bars.IsIntraday)   // Daily data
            {
                //base.FirstValidValue = bars.FirstActualBar;

                Pivot    = AveragePriceC.Series(bars);
                DayHigh  = bars.High;
                DayClose = bars.Close;
                DayLow   = bars.Low;

                CalcPivotLevel(type, Pivot, DayHigh, DayLow, ref R1, ref S1, ref R2, ref S2, ref R3, ref S3, ref result);
            }
            else    // Special logic for intraday data
            {
                try
                {
                    Bars eodBars = BarScaleConverter.ToDaily(bars);
                    Pivot    = AveragePriceC.Series(eodBars);
                    DayHigh  = eodBars.High;
                    DayClose = eodBars.Close;
                    DayLow   = eodBars.Low;

                    R1 = BarScaleConverter.Synchronize(R1, eodBars);
                    S1 = BarScaleConverter.Synchronize(S1, eodBars);
                    R2 = BarScaleConverter.Synchronize(R2, eodBars);
                    S2 = BarScaleConverter.Synchronize(S2, eodBars);
                    R3 = BarScaleConverter.Synchronize(R3, eodBars);
                    S3 = BarScaleConverter.Synchronize(S3, eodBars);

                    CalcPivotLevel(type, Pivot, DayHigh, DayLow, ref R1, ref S1, ref R2, ref S2, ref R3, ref S3, ref result);
                    result = BarScaleConverter.Synchronize(result, bars);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = result[bar];
            }
        }
Пример #14
0
        public static EventAction GetEventAction(HttpVerbs verb, PivotType pivotType, bool hasIdParameter)
        {
            if (hasIdParameter == false && pivotType == PivotType.Transaction && verb == HttpVerbs.Get)
            {
                return(EventAction.Query);
            }

            return(VerbsToActions[pivotType][verb]);
        }
Пример #15
0
        public void setPivot(string data)
        {
            PivotType type = PivotType.MiddleCenter;

            EnumConverter <PivotType> .Convert(data, ref type);

            var pivot = PivotTypeVector2Converter.Convert(type);

            Element.SetAttribute <Pivot, Vector2>(pivot);
        }
Пример #16
0
        private PivotType DrawPivotTypeField(MeshModel model, out bool isChanged)
        {
            EditorGUI.BeginChangeCheck();
            PivotType pivotType = (PivotType)EditorGUILayout.EnumPopup(new GUIContent("Pivot Type",
                                                                                      "type of the root object's world position"), model.pivotType);

            isChanged = EditorGUI.EndChangeCheck();

            return(pivotType);
        }
Пример #17
0
 public void NextPivotType()
 {
     if (ActivePivot == PivotType.WorldOrigin)
     {
         ActivePivot = PivotType.ObjectCenter;
     }
     else
     {
         ActivePivot++;
     }
 }
Пример #18
0
        private PivotType RaycastSide(SuperCube aCube, Ray aRay)
        {
            aRay.origin    = aCube.transform.InverseTransformPoint(aRay.origin);
            aRay.direction = aCube.transform.InverseTransformDirection(aRay.direction);
            aRay.direction.Normalize();

            Vector3   size    = aCube.Extents / 2;
            PivotType side    = PivotType.None;
            float     closest = float.MaxValue;
            float     dist    = 0;

            Bounds bounds = new Bounds();

            bounds.center  = Vector3.zero;
            bounds.extents = size;
            if (bounds.IntersectRay(aRay, out dist))
            {
                side    = PivotType.All;
                closest = dist + 0.1f;
            }

            if (CheckSide(aRay, new Vector3(0, 0, -1), size.z, Mathf.Min(size.x, size.y), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Back;
            }
            if (CheckSide(aRay, new Vector3(0, 0, 1), size.z, Mathf.Min(size.x, size.y), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Front;
            }
            if (CheckSide(aRay, new Vector3(-1, 0, 0), size.x, Mathf.Min(size.y, size.z), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Right;
            }
            if (CheckSide(aRay, new Vector3(1, 0, 0), size.x, Mathf.Min(size.y, size.z), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Left;
            }
            if (CheckSide(aRay, new Vector3(0, -1, 0), size.y, Mathf.Min(size.x, size.z), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Top;
            }
            if (CheckSide(aRay, new Vector3(0, 1, 0), size.y, Mathf.Min(size.x, size.z), closest, out dist))
            {
                closest = dist;
                side    = PivotType.Bottom;
            }

            return(side);
        }
Пример #19
0
    public void MoveCamera(PivotType pivot)
    {
        Vector3 move     = m_DicMoveDir[pivot] * m_MoveSpeed;
        Vector3 newPoint = m_MainCameraTrans.localPosition + move * Time.deltaTime;

        if (!IsContainArea(m_LimitPointA, m_LimitPointB, m_LimitPointC, m_LimitPointD, newPoint))
        {
            return;
        }

        m_MainCameraTrans.localPosition = newPoint;
    }
Пример #20
0
        public static PivotLevels Series(Bars bars, PivotType type)
        {
            string description = string.Concat(new object[] { "PivotLevels(", type.ToString(), ")" });

            if (bars.Cache.ContainsKey(description))
            {
                return((PivotLevels)bars.Cache[description]);
            }

            PivotLevels _PivotLevels = new PivotLevels(bars, type, description);

            bars.Cache[description] = _PivotLevels;
            return(_PivotLevels);
        }
Пример #21
0
        public static QueryNode SetPivot(this QueryNode queryNode, PivotType type, string mainValue,
                                         params string[] secondaryValues)
        {
            var pivotData = new PivotData
            {
                MainValue       = mainValue,
                SecondaryValues = secondaryValues?.ToList() ?? new List <string>(),
                PivotDefinition = ParserHelper.GetPivot(type)
            };

            queryNode.PivotData = pivotData;

            return(queryNode);
        }
Пример #22
0
 private bool IsEnabled(PivotType pivotType)
 {
     foreach (NodeData nodeData in _columns)
     {
         Type   table;
         String column;
         _columnSet.ResolveColumn(nodeData, out table, out column);
         if (pivotType.IsCrosstabValue(table, column))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #23
0
        public bool Pivot(string pivotName, PivotType pivot)
        {
            var command = new PivotCommand
            {
                AutomationIdentifier = CreateAutomationIdentifier(pivotName),
                PivotLast            = pivot == PivotType.Last,
                PivotNext            = pivot == PivotType.Next
            };

            var result = SyncExecuteCommand(command);

            Thread.Sleep(TimeSpan.FromSeconds(3)); // Wait for pivot animations to complete

            return(result is SuccessResult);
        }
Пример #24
0
        private bool DoDragDrop()
        {
            bool      rebuild = false;
            SuperCube cube    = target as SuperCube;

            if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)              // || Event.current.type == EventType.Repaint) {
            {
                Material dragMat = null;
                for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
                {
                    if (DragAndDrop.objectReferences[i] is Material)
                    {
                        dragMat = DragAndDrop.objectReferences[i] as Material;
                    }
                }

                if (dragMat != null)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    PivotType side = RaycastSide(cube, HandleUtility.GUIPointToWorldRay(Event.current.mousePosition));

                    if (side != mDragPrevSide)
                    {
                        if (mDragPrevSide != PivotType.None)
                        {
                            SetSideMaterial(cube, mDragPrevSide, mDragPrevMaterial);
                        }
                        mDragPrevMaterial = GetSideMaterial(cube, side);
                    }
                    SetSideMaterial(cube, side, dragMat);
                    rebuild       = true;
                    mDragPrevSide = side;

                    if (Event.current.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        mDragPrevMaterial = null;
                        mDragPrevSide     = PivotType.None;
                    }
                    if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)
                    {
                        Event.current.Use();
                    }
                }
            }

            return(rebuild);
        }
Пример #25
0
        public static void SetPivot(this RectTransform RT, PivotType type)
        {
            switch (type)
            {
            case PivotType.TopCenter:
                RT.pivot = new Vector2(0.5f, 1);
                break;

            case PivotType.LeftCenter:
                RT.pivot = new Vector2(0, 0.5f);
                break;

            case PivotType.RightCenter:
                RT.pivot = new Vector2(1, 0.5f);
                break;

            case PivotType.BottomCenter:
                RT.pivot = new Vector2(0.5f, 0);
                break;

            case PivotType.TopLeft:
                RT.pivot = new Vector2(0, 1);
                break;

            case PivotType.TopRight:
                RT.pivot = new Vector2(1, 1);
                break;

            case PivotType.BottomLeft:
                RT.pivot = new Vector2(0, 0);
                break;

            case PivotType.BottomRight:
                RT.pivot = new Vector2(1, 0);
                break;

            case PivotType.Center:
                RT.pivot = new Vector2(0.5f, 0.5f);
                break;

            default:
                //Center
                RT.pivot = new Vector2(0.5f, 0.5f);
                break;
            }
        }
Пример #26
0
        /// <summary>
        /// Calculate Main Pivots Series
        /// </summary>
        /// <param name="type"></param>
        /// <param name="Pivot"></param>
        /// <param name="DayHigh"></param>
        /// <param name="DayLow"></param>
        /// <param name="R1"></param>
        /// <param name="S1"></param>
        /// <param name="R2"></param>
        /// <param name="S2"></param>
        /// <param name="R3"></param>
        /// <param name="S3"></param>
        /// <param name="result"></param>
        private static void CalcPivotLevel(PivotType type, DataSeries Pivot, DataSeries DayHigh, DataSeries DayLow, ref DataSeries R1, ref DataSeries S1, ref DataSeries R2, ref DataSeries S2, ref DataSeries R3, ref DataSeries S3, ref DataSeries result)
        {
            R1 = 2 * Pivot - DayLow;
            S1 = 2 * Pivot - DayHigh;
            R2 = Pivot + (R1 - S1);
            S2 = Pivot - (R1 - S1);
            R3 = R1 + (DayHigh - DayLow);
            S3 = S1 - (DayHigh - DayLow);

            switch (type)
            {
            case PivotType.Pivot:
                result = Pivot;
                break;

            case PivotType.R1:
                result = R1;
                break;

            case PivotType.R2:
                result = R2;
                break;

            case PivotType.R3:
                result = R3;
                break;

            case PivotType.S1:
                result = S1;
                break;

            case PivotType.S2:
                result = S2;
                break;

            case PivotType.S3:
                result = S3;
                break;

            default:
                break;
            }
        }
Пример #27
0
    public void SetGameObjPosition(GameObject obj, Rect pos, float z, PivotType pivot = PivotType.CenterCenter)
    {
        switch (pivot)
        {
        case PivotType.CenterCenter:

            //pos.x = pos.x - (pos.width/2);

            //pos.y = pos.y - (pos.height/2);

            break;

        case PivotType.BottomCenter:

            //pos.x = pos.x - (pos.width/2);

            break;
        }



        Vector3 leftBottom = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, z));

        Vector3 rigthTop = Camera.main.ScreenToWorldPoint(new Vector3(pos.x + pos.width, pos.y + pos.height, z));



        Rect bound = new Rect(leftBottom.x, rigthTop.y,

                              rigthTop.x - leftBottom.x, rigthTop.y - leftBottom.y);



        float zRatio = obj.transform.localScale.z / obj.transform.localScale.x;



        obj.transform.localScale = new Vector3(bound.width, bound.height, bound.width * zRatio);

        obj.transform.position = new Vector3(bound.x + (bound.width / 2), bound.y - (bound.height / 2), Camera.main.transform.position.z + z);
    }
Пример #28
0
        public static void SetPivot(RectTransform RectTransform, PivotType PivotType)
        {
            switch (PivotType)
            {
            case PivotType.UpperLeft:
                RectTransform.pivot = new Vector2(0, 1);
                break;

            case PivotType.UpperMiddle:
                RectTransform.pivot = new Vector2(0.5f, 1);
                break;

            case PivotType.UpperRight:
                RectTransform.pivot = new Vector2(1, 1);
                break;

            case PivotType.MiddleLeft:
                RectTransform.pivot = new Vector2(0, 0.5f);
                break;

            case PivotType.MiddleMiddle:
                RectTransform.pivot = new Vector2(0.5f, 0.5f);
                break;

            case PivotType.MiddleRight:
                RectTransform.pivot = new Vector2(1, 0.5f);
                break;

            case PivotType.BottomLeft:
                RectTransform.pivot = new Vector2(0, 0);
                break;

            case PivotType.BottomMiddle:
                RectTransform.pivot = new Vector2(0.5f, 0);
                break;

            case PivotType.BottomRight:
                RectTransform.pivot = new Vector2(1f, 0);
                break;
            }
        }
Пример #29
0
        public Report GetReport()
        {
            bool replicate    = cbxPivotReplicate.Enabled && cbxPivotReplicate.Checked;
            bool isotopeLabel = cbxPivotIsotopeLabel.Enabled && cbxPivotIsotopeLabel.Checked;

            PivotType pivotType = null;

            if (replicate && isotopeLabel)
            {
                pivotType = PivotType.REPLICATE_ISOTOPE_LABEL;
            }
            else if (replicate)
            {
                pivotType = PivotType.REPLICATE;
            }
            else if (isotopeLabel)
            {
                pivotType = PivotType.ISOTOPE_LABEL;
            }
            return(_columnSet.GetReport(_columns, pivotType));
        }
Пример #30
0
 protected override void OnStart()
 {
     if (base.Widget.Width != this.NextWidget.Width || base.Widget.Height != this.NextWidget.Height)
     {
         Console.WriteLine("Not supported different widget size.");
         return;
     }
     this.nonJumpTime          = this.time * this.jumpDelay;
     this.orgCurrentPivotType  = base.Widget.PivotType;
     this.orgNextPivotType     = this.NextWidget.PivotType;
     base.Widget.PivotType     = PivotType.MiddleCenter;
     this.NextWidget.PivotType = PivotType.MiddleCenter;
     base.Widget.ZSort         = true;
     this.NextWidget.ZSort     = true;
     this.fromPosX             = base.Widget.X;
     this.fromPosY             = base.Widget.Y;
     this.toPosX             = this.NextWidget.X;
     this.toPosY             = this.NextWidget.Y;
     this.toDegree           = 180f;
     base.Widget.Visible     = true;
     this.NextWidget.Visible = false;
 }
Пример #31
0
        public BoxStairs()
        {
            // Initialization of parameters and structures
            Pivot            = PivotType.Downstairs;
            LastPivot        = Pivot;
            StairsWidth      = 1.0f;
            LastStairsWidth  = StairsWidth;
            StairsHeight     = 0.5f;
            LastStairsHeight = StairsHeight;
            StairsDepth      = 1.0f;
            LastStairsDepth  = StairsDepth;
            StepsNumber      = 4;
            LastStepsNumber  = StepsNumber;
            ThreeSides       = false;
            LastThreeSides   = ThreeSides;

            StairsHeightDrivedBySteps = false;
            HeightFoldout             = false;
            StepsHeight = new float[StepsNumber];
            ApplyDefaultStepsHeight();
            KeepCustomHeightValues = false;

            StairsDepthDrivedBySteps = false;
            DepthFoldout             = false;
            StepsDepth = new float[StepsNumber];
            ApplyDefaultStepsDepth();
            KeepCustomDepthValues = false;

            StairsMaterial     = null;
            LastStairsMaterial = StairsMaterial;
            MaterialsFoldout   = false;
            StepsMaterials     = new Material[StepsNumber];

            for (int i = 0; i < StepsNumber; i++)
            {
                StepsMaterials[i] = null;
            }
        }
Пример #32
0
 public Vector3[] resize(Vector2 pSize, PivotType pPivotType)
 {
     vertices = resize(pSize.x, pSize.y, pPivotType);
     return vertices;
 }
Пример #33
0
    public Vector3[] resize(float pWidth, float pHeigth, PivotType pPivotType)
    {
        switch (pPivotType)
        {
            case PivotType.center:
                vertices = new Vector3[]{
                    new Vector3(-pWidth/2,-pHeigth/2,0),
                    new Vector3(pWidth/2,-pHeigth/2,0),
                    new Vector3(pWidth/2,pHeigth/2,0),
                    new Vector3(-pWidth/2,pHeigth/2,0)
                };
                break;
            case PivotType.leftBottom:
                vertices = new Vector3[]{
                    new Vector3(0.0f,0.0f,0.0f),
                    new Vector3(pHeigth,0.0f,0.0f),
                    new Vector3(pHeigth,pWidth,0.0f),
                    new Vector3(0.0f,pWidth,0.0f)
                };
                break;
        }
        mesh.vertices = vertices;

        return vertices;
    }
Пример #34
0
        public void HandleInput(InputState input)
        {
            // -- Select Gizmo Mode -- //
            if (input.WasKeyPressed(Keys.D1))
            {
                ActiveMode = GizmoMode.Translate;
            }
            else if (input.WasKeyPressed(Keys.D2))
            {
                ActiveMode = GizmoMode.Rotate;
            }
            else if (input.WasKeyPressed(Keys.D3))
            {
                ActiveMode = GizmoMode.NonUniformScale;
            }
            else if (input.WasKeyPressed(Keys.D4))
            {
                ActiveMode = GizmoMode.UniformScale;
            }

            // -- Cycle TransformationSpaces -- //
            if (input.WasKeyPressed(Keys.Space))
            {
                if (ActiveSpace == TransformSpace.Local)
                    ActiveSpace = TransformSpace.World;
                else
                    ActiveSpace = TransformSpace.Local;
            }

            // -- Cycle PivotTypes -- //
            if (input.WasKeyPressed(Keys.P))
            {
                if (ActivePivot == PivotType.WorldOrigin)
                    ActivePivot = PivotType.ObjectCenter;
                else
                    ActivePivot++;
            }

            // -- Toggle PrecisionMode -- //
            if (input.IsKeyDown(Keys.LeftShift))
            {
                precisionMode = true;
            }
            else
                precisionMode = false;

            // -- Toggle Snapping -- //
            if (input.WasKeyPressed(Keys.C))
            {
                SnapEnabled = !SnapEnabled;
            }
            if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left) && ActiveAxis == GizmoAxis.None)
            {
                // add to selection or clear current selection
                if (input.IsKeyUp(addToSelection) && input.IsKeyUp(removeFromSelection) || input.IsKeyDown(Keys.LeftAlt))
                {
                    Selection.Clear();
                }

                PickObject(input.Mouse.Position, input.IsKeyDown(removeFromSelection));
            }
            else if (input.WasKeyPressed(Keys.R))
            {
                Selection.Clear();
            }

            if (Enabled)
            {
                if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left))
                {
                    // reset for intersection (plane vs. ray)
                    intersectPosition = Vector3.Zero;
                    // reset for snapping
                    translationScaleSnapDelta = Vector3.Zero;
                    rotationSnapDelta = 0;
                }

                lastIntersectionPosition = intersectPosition;

                if (input.Mouse.WasButtonHeld(Framework.MouseButtons.Left) && ActiveAxis != GizmoAxis.None)
                {
                    if (ActiveMode == GizmoMode.Translate || ActiveMode == GizmoMode.NonUniformScale || ActiveMode == GizmoMode.UniformScale)
                    {
                        #region Translate & Scale
                        Vector3 delta = Vector3.Zero;
                        Ray ray = Engine.ray;

                        Matrix transform = Matrix.Invert(rotationMatrix);
                        ray.Position = Vector3.Transform(ray.Position, transform);
                        ray.Direction = Vector3.TransformNormal(ray.Direction, transform);

                        if (ActiveAxis == GizmoAxis.X || ActiveAxis == GizmoAxis.XY)
                        {
                            Plane plane = new Plane(Vector3.Forward, Vector3.Transform(position,
                                Matrix.Invert(rotationMatrix)).Z);

                            float? intersection = ray.Intersects(plane);
                            if (intersection.HasValue)
                            {
                                intersectPosition = (ray.Position + (ray.Direction *
                                    intersection.Value));
                                if (lastIntersectionPosition != Vector3.Zero)
                                {
                                    translationDelta = intersectPosition -
                                        lastIntersectionPosition;
                                }
                                if (ActiveAxis == GizmoAxis.X)
                                    delta = new Vector3(translationDelta.X, 0, 0);
                                else
                                    delta = new Vector3(translationDelta.X, translationDelta.Y, 0);
                            }
                        }
                        else if (ActiveAxis == GizmoAxis.Y || ActiveAxis == GizmoAxis.YZ || ActiveAxis == GizmoAxis.Z)
                        {
                            Plane plane = new Plane(Vector3.Left, Vector3.Transform(position,
                                Matrix.Invert(rotationMatrix)).X);

                            float? intersection = ray.Intersects(plane);
                            if (intersection.HasValue)
                            {
                                intersectPosition = (ray.Position + (ray.Direction *
                                    intersection.Value));
                                if (lastIntersectionPosition != Vector3.Zero)
                                {
                                    translationDelta = intersectPosition -
                                        lastIntersectionPosition;
                                }
                                if (ActiveAxis == GizmoAxis.Y)
                                    delta = new Vector3(0, translationDelta.Y, 0);
                                else if (ActiveAxis == GizmoAxis.Z)
                                    delta = new Vector3(0, 0, translationDelta.Z);
                                else
                                    delta = new Vector3(0, translationDelta.Y, translationDelta.Z);
                            }
                        }
                        else if (ActiveAxis == GizmoAxis.ZX)
                        {
                            Plane plane = new Plane(Vector3.Down, Vector3.Transform(position,
                                Matrix.Invert(rotationMatrix)).Y);

                            float? intersection = ray.Intersects(plane);
                            if (intersection.HasValue)
                            {
                                intersectPosition = (ray.Position + (ray.Direction *
                                    intersection.Value));
                                if (lastIntersectionPosition != Vector3.Zero)
                                {
                                    translationDelta = intersectPosition -
                                        lastIntersectionPosition;
                                }
                            }

                            delta = new Vector3(translationDelta.X, 0, translationDelta.Z);
                        }

                        if (SnapEnabled)
                        {
                            float snapValue = TranslationSnapValue;
                            if (ActiveMode == GizmoMode.UniformScale || ActiveMode == GizmoMode.NonUniformScale)
                                snapValue = ScaleSnapValue;
                            if (precisionMode)
                            {
                                delta *= precisionModeScale;
                                snapValue *= precisionModeScale;
                            }

                            translationScaleSnapDelta += delta;

                            delta = new Vector3(
                                (int)(translationScaleSnapDelta.X / snapValue) * snapValue,
                                (int)(translationScaleSnapDelta.Y / snapValue) * snapValue,
                                (int)(translationScaleSnapDelta.Z / snapValue) * snapValue);

                            translationScaleSnapDelta -= delta;
                        }
                        else if (precisionMode)
                            delta *= precisionModeScale;

                        if (ActiveMode == GizmoMode.Translate)
                        {
                            // transform (local or world)
                            delta = Vector3.Transform(delta, rotationMatrix);

                            // apply
                            foreach (Framework.SceneEntity entity in Selection)
                            {
                                entity.position += delta;
                            }

                        }
                        else if (ActiveMode == GizmoMode.NonUniformScale)
                        {
                            // -- Apply Scale -- //
                            foreach (Framework.SceneEntity entity in Selection)
                            {
                                entity.scale += delta;
                                entity.scale = Vector3.Clamp(entity.scale, Vector3.Zero,
                                    entity.scale);
                            }
                        }
                        else if (ActiveMode == GizmoMode.UniformScale)
                        {

                            float diff = 1 + ((delta.X + delta.Y + delta.Z) / 3);
                            foreach (Framework.SceneEntity entity in Selection)
                            {
                                entity.scale *= diff;

                                entity.scale = Vector3.Clamp(entity.scale, Vector3.Zero,
                                    entity.scale);
                            }
                        }
                        #endregion
                    }
                    else if (ActiveMode == GizmoMode.Rotate)
                    {
                        #region Rotate
                        float delta = input.Mouse.Delta.X;
                        delta *= inputScale;

                        if (SnapEnabled)
                        {
                            float snapValue = MathHelper.ToRadians(RotationSnapValue);
                            if (precisionMode)
                            {
                                delta *= precisionModeScale;
                                snapValue *= precisionModeScale;
                            }

                            rotationSnapDelta += delta;

                            float snapped = (int)(rotationSnapDelta / snapValue) * snapValue;
                            rotationSnapDelta -= snapped;

                            delta = snapped;
                        }
                        else if (precisionMode)
                        {
                            delta *= precisionModeScale;
                        }

                        // rotation matrix to transform - if more than one objects selected, always use world-space.
                        Matrix rot = Matrix.Identity;
                        rot.Forward = sceneWorld.Forward;
                        rot.Up = sceneWorld.Up;
                        rot.Right = sceneWorld.Right;

                        if (ActiveAxis == GizmoAxis.X)
                        {
                            rot *= Matrix.CreateFromAxisAngle(rotationMatrix.Right, delta);
                        }
                        else if (ActiveAxis == GizmoAxis.Y)
                        {
                            rot *= Matrix.CreateFromAxisAngle(rotationMatrix.Up, delta);
                        }
                        else if (ActiveAxis == GizmoAxis.Z)
                        {
                            rot *= Matrix.CreateFromAxisAngle(rotationMatrix.Forward, delta);
                        }

                        // -- Apply rotation -- //
                        foreach (Framework.SceneEntity entity in Selection)
                        {
                            // use gizmo position for all PivotTypes except for object-center, it should use the entity.position instead.
                            Vector3 pos = position;
                            if (ActivePivot == PivotType.ObjectCenter)
                            {
                                pos = entity.position;
                            }

                            Matrix localRot = Matrix.Identity;
                            localRot.Forward = entity.forward;
                            localRot.Up = entity.up;
                            localRot.Right = Vector3.Cross(entity.forward, entity.up);
                            localRight.Normalize();
                            localRot.Translation = entity.position - pos;

                            Matrix newRot = localRot * rot;

                            entity.forward = newRot.Forward;
                            entity.up = newRot.Up;
                            entity.position = newRot.Translation + pos;

                        }
                        #endregion
                    }
                }
                else
                {
                    UpdateAxisSelection(input.Mouse.Position);
                }
            }

            // Enable only if something is selected.
            if (Selection.Count < 1)
                Enabled = false;
            else
                Enabled = true;
        }
Пример #35
0
		private void SetSideMaterial(SuperCube aCube, PivotType aSide, Material aMaterial) {
			if (aSide == PivotType.None) return;
			else if (aSide == PivotType.All) {
				aCube.GetComponent<Renderer>().sharedMaterial = aMaterial;
			} else if ((aSide & PivotType.Back) > 0) {
				aCube.OverrideBack = aMaterial;
			} else if ((aSide & PivotType.Front) > 0) {
				aCube.OverrideFront = aMaterial;
			} else if ((aSide & PivotType.Top) > 0) {
				aCube.OverrideTop = aMaterial;
			} else if ((aSide & PivotType.Bottom) > 0) {
				aCube.OverrideBottom = aMaterial;
			} else if ((aSide & PivotType.Right) > 0) {
				aCube.OverrideRight = aMaterial;
			} else if ((aSide & PivotType.Left) > 0) {
				aCube.OverrideLeft = aMaterial;
			}
		}
Пример #36
0
		private Material GetSideMaterial(SuperCube aCube, PivotType aSide) {
			if (aSide == PivotType.None) return null;
			else if (aSide == PivotType.All) {
				return aCube.GetComponent<Renderer>().sharedMaterial;
			} else if ((aSide & PivotType.Back) > 0) {
				return aCube.OverrideBack;
			} else if ((aSide & PivotType.Front) > 0) {
				return aCube.OverrideFront;
			} else if ((aSide & PivotType.Top) > 0) {
				return aCube.OverrideTop;
			} else if ((aSide & PivotType.Bottom) > 0) {
				return aCube.OverrideBottom;
			} else if ((aSide & PivotType.Left) > 0) {
				return aCube.OverrideLeft;
			} else if ((aSide & PivotType.Right) > 0) {
				return aCube.OverrideRight;
			}
			return null;
		}
Пример #37
0
	/// <summary>
	/// Creates a SuperCube game object, and assigns the given data! This function will build the cube mesh right away.
	/// </summary>
	/// <param name="aAt">The center of the SuperCube.</param>
	/// <param name="aSize">The width, height, and depth of the SuperCube.</param>
	/// <param name="aMaterial">The default material for the entire SuperCube.</param>
	/// <param name="aWallUV">The type of UV calculations to use for the +X, -X, +Z, -Z faces.</param>
	/// <param name="aTopBottomUV">The type of UV calculations to use for the +Y, -Y faces.</param>
	/// <param name="aSliceDistance">How far apart shall we try and place vertex slices on the faces? floor(size/sliceDistance)</param>
	/// <param name="aHideFaces">A bit mask describing which faces should be hidden.</param>
	/// <param name="aOverrideTop">Material override for the +Y face.</param>
	/// <param name="aOverrideBottom">Material override for the -Y face.</param>
	/// <param name="aOverrideLeft">Material override for the -X face.</param>
	/// <param name="aOverrideRight">Material override for the +X face.</param>
	/// <param name="aOverrideFront">Material override for the -Z face.</param>
	/// <param name="aOverrideBack">Material override for the +Z face.</param>
	/// <returns>A GameObject named "SuperCube" with a fully built SuperCube, MeshFilter, Renderer, and BoxCollider component!</returns>
	public static GameObject Create      (Vector3 aAt,                            Vector3 aSize, Material aMaterial, UVType aWallUV = UVType.WorldCoordinates, UVType aTopBottomUV = UVType.WorldCoordinates, float aSliceDistance = 0, PivotType aHideFaces = PivotType.None, Material aOverrideTop = null, Material aOverrideBottom = null, Material aOverrideLeft = null, Material aOverrideRight = null, Material aOverrideFront = null, Material aOverrideBack = null ) {
		GameObject go  = new GameObject("SuperCube");
		SuperCube  box = go.AddComponent<SuperCube>();
		box.mWallUVType        = aWallUV;
		box.mTopBottomUVType   = aTopBottomUV;
		box.Extents            = aSize;
		box.transform.position = aAt;
		if (aSliceDistance > 0) {
			box.mSliceDistance = aSliceDistance;
			box.mSliceFaces    = true;
		}

		if ((aHideFaces & PivotType.Back  ) > 0 ) box.FaceBack   = false;
		if ((aHideFaces & PivotType.Bottom) > 0 ) box.FaceBottom = false;
		if ((aHideFaces & PivotType.Front ) > 0 ) box.FaceFront  = false;
		if ((aHideFaces & PivotType.Left  ) > 0 ) box.FaceLeft   = false;
		if ((aHideFaces & PivotType.Right ) > 0 ) box.FaceRight  = false;
		if ((aHideFaces & PivotType.Top   ) > 0 ) box.FaceTop    = false;

		box.mOverrideBack   = aOverrideBack;
		box.mOverrideFront  = aOverrideFront;
		box.mOverrideTop    = aOverrideTop;
		box.mOverrideBottom = aOverrideBottom;
		box.mOverrideLeft   = aOverrideLeft;
		box.mOverrideRight  = aOverrideRight;

		box.Build(true);
		go.GetComponent<Renderer>().sharedMaterial = aMaterial;

		go.AddComponent<BoxCollider>();
		return go;
	}
Пример #38
0
		private static void AddExtrudeCube(SuperCube aBox, Vector3 aAt, PivotType aPivot, Vector3 aSize) {
			GameObject go = SuperCube.CreatePivot(aBox.transform.InverseTransformPoint(aAt), aPivot, aSize, aBox.GetComponent<Renderer>().sharedMaterial);
			Vector3 pos = go.transform.position;
			go.transform.parent = aBox.transform;
			go.transform.localPosition = pos;
			go.transform.localRotation = Quaternion.identity;
			go.transform.localScale    = Vector3.one;
			go.transform.parent = aBox.transform.parent;
			go.isStatic         = aBox.gameObject.isStatic;
			go.tag              = aBox.gameObject.tag;
			go.layer            = aBox.gameObject.layer;

			SuperCube box = go.GetComponent<SuperCube>();
			box.SliceFaces      = aBox.SliceFaces;
			box.SliceDistance   = aBox.SliceDistance;
			box.WallUVType      = aBox.WallUVType;
			box.WallUVTile      = aBox.WallUVTile;
			box.WallUVOffset    = aBox.WallUVOffset;
			box.TopBottomUVType = aBox.TopBottomUVType;
			box.TopBottomUVTile = aBox.TopBottomUVTile;
			box.TopBottomUVOffset=aBox.TopBottomUVOffset;
			box.OverrideTop     = aBox.OverrideBack;
			box.OverrideBottom  = aBox.OverrideBottom;
			box.OverrideFront   = aBox.OverrideFront;
			box.OverrideLeft    = aBox.OverrideLeft;
			box.OverrideRight   = aBox.OverrideRight;
			box.OverrideTop     = aBox.OverrideTop;
			box.Build(true);
			
			Selection.activeGameObject = go;
			EditorGUIUtility.PingObject(go);
			
		}
        public void Draw3D()
        {
            return;

            if (m_IsEnabled == false) { return; }

            m_ActiveMode = GizmoMode.TRANSLATE;
            m_ActiveAxis = GizmoAxis.XY;
            m_ActivePivot = PivotType.OBJECT_CENTER;

            GameFiles.GraphicsDevice.DepthStencilState = DepthStencilState.None;

            m_LineEffect.World = m_GizmoWorld;
            m_LineEffect.View = GameFiles.ViewMatrix;
            m_LineEffect.Projection = GameFiles.ProjectionMatrix;

            m_LineEffect.CurrentTechnique.Passes[0].Apply();
            GameFiles.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, m_TranslationLineVertices, 0, m_TranslationLineVertices.Length / 2);

            if (m_ActiveMode == GizmoMode.TRANSLATE || m_ActiveMode == GizmoMode.NON_LINEAR_SCALE)
            {
                if (m_ActiveAxis == GizmoAxis.XY || m_ActiveAxis == GizmoAxis.YZ || m_ActiveAxis == GizmoAxis.ZX)
                {
                    GameFiles.GraphicsDevice.BlendState = BlendState.AlphaBlend;
                    GameFiles.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

                    m_QuadEffect.World = m_GizmoWorld;
                    m_QuadEffect.View = GameFiles.ViewMatrix;
                    m_QuadEffect.Projection = GameFiles.ProjectionMatrix;

                    m_QuadEffect.CurrentTechnique.Passes[0].Apply();

                    Quad activeQuad = new Quad();
                    switch (m_ActiveAxis)
                    {
                        case GizmoAxis.XY:
                            activeQuad = m_Quads[0];
                            break;
                        case GizmoAxis.ZX:
                            activeQuad = m_Quads[1];
                            break;
                        case GizmoAxis.YZ:
                            activeQuad = m_Quads[2];
                            break;
                    }

                    GameFiles.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                        activeQuad.Vertices, 0, 4,
                        activeQuad.Indexes, 0, 2);

                    GameFiles.GraphicsDevice.BlendState = BlendState.Opaque;
                    GameFiles.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
                }

                if (m_ActiveMode == GizmoMode.TRANSLATE)
                {
                    for (int loop = 0; loop < 3; loop++)
                    {
                        for (int meshLoop = 0; meshLoop < m_TranslationModel.Meshes.Count; meshLoop++)
                        {
                            ModelMesh tempModelMesh = m_TranslationModel.Meshes[meshLoop];
                            for (int meshPartLoop = 0; meshPartLoop < m_TranslationModel.Meshes.Count; meshPartLoop++)
                            {
                                ModelMeshPart tempModelMeshPart = tempModelMesh.MeshParts[meshPartLoop];

                                BasicEffect effect = (BasicEffect)tempModelMeshPart.Effect;
                                Vector3 color = m_AxisColors[loop].ToVector3();

                                effect.World = m_ModelLocalSpace[loop] * m_GizmoWorld;
                                effect.DiffuseColor = color;
                                effect.EmissiveColor = color;

                                effect.EnableDefaultLighting();

                                effect.View = GameFiles.ViewMatrix;
                                effect.Projection = GameFiles.ProjectionMatrix;
                            }

                            tempModelMesh.Draw();
                        }
                    }
                }
                else
                {
                    for (int loop = 0; loop < 3; loop++)
                    {
                        for (int meshLoop = 0; meshLoop < m_ScaleModel.Meshes.Count; meshLoop++)
                        {
                            ModelMesh tempModelMesh = m_ScaleModel.Meshes[meshLoop];
                            for (int meshPartLoop = 0; meshPartLoop < m_ScaleModel.Meshes.Count; meshPartLoop++)
                            {
                                ModelMeshPart tempModelMeshPart = tempModelMesh.MeshParts[meshPartLoop];

                                BasicEffect effect = (BasicEffect)tempModelMeshPart.Effect;
                                Vector3 color = m_AxisColors[meshPartLoop].ToVector3();

                                effect.World = m_ModelLocalSpace[meshPartLoop] * m_GizmoWorld;
                                effect.DiffuseColor = color;
                                effect.EmissiveColor = color;

                                effect.EnableDefaultLighting();

                                effect.View = GameFiles.ViewMatrix;
                                effect.Projection = GameFiles.ProjectionMatrix;
                            }

                            tempModelMesh.Draw();
                        }
                    }
                }
            }
            else if (m_ActiveMode == GizmoMode.ROTATE)
            {
                for (int loop = 0; loop < 3; loop++)
                {
                    for (int meshLoop = 0; meshLoop < m_RotationModel.Meshes.Count; meshLoop++)
                    {
                        ModelMesh tempModelMesh = m_RotationModel.Meshes[meshLoop];
                        for (int meshPartLoop = 0; meshPartLoop < m_RotationModel.Meshes.Count; meshPartLoop++)
                        {
                            ModelMeshPart tempModelMeshPart = tempModelMesh.MeshParts[meshPartLoop];

                            BasicEffect effect = (BasicEffect)tempModelMeshPart.Effect;
                            Vector3 color = m_AxisColors[meshPartLoop].ToVector3();

                            effect.World = m_ModelLocalSpace[meshPartLoop] * m_GizmoWorld;
                            effect.DiffuseColor = color;
                            effect.EmissiveColor = color;

                            effect.EnableDefaultLighting();

                            effect.View = GameFiles.ViewMatrix;
                            effect.Projection = GameFiles.ProjectionMatrix;
                        }

                        tempModelMesh.Draw();
                    }
                }
            }
            else if (m_ActiveMode == GizmoMode.SCALE)
            {
                for (int loop = 0; loop < 3; loop++)
                {
                    for (int meshLoop = 0; meshLoop < m_RotationModel.Meshes.Count; meshLoop++)
                    {
                        ModelMesh tempModelMesh = m_RotationModel.Meshes[meshLoop];
                        for (int meshPartLoop = 0; meshPartLoop < m_RotationModel.Meshes.Count; meshPartLoop++)
                        {
                            ModelMeshPart tempModelMeshPart = tempModelMesh.MeshParts[meshPartLoop];

                            BasicEffect effect = (BasicEffect)tempModelMeshPart.Effect;
                            Vector3 color = m_AxisColors[meshPartLoop].ToVector3();

                            effect.World = m_ModelLocalSpace[meshPartLoop] * m_GizmoWorld;
                            effect.DiffuseColor = color;
                            effect.EmissiveColor = color;

                            effect.EnableDefaultLighting();

                            effect.View = GameFiles.ViewMatrix;
                            effect.Projection = GameFiles.ProjectionMatrix;
                        }

                        tempModelMesh.Draw();
                    }
                }

                if (m_ActiveAxis != GizmoAxis.NONE)
                {
                    GameFiles.GraphicsDevice.BlendState = BlendState.AlphaBlend;
                    GameFiles.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

                    m_QuadEffect.World = m_GizmoWorld;
                    m_QuadEffect.View = GameFiles.ViewMatrix;
                    m_QuadEffect.Projection = GameFiles.ProjectionMatrix;

                    m_QuadEffect.CurrentTechnique.Passes[0].Apply();

                    for (int loop = 0; loop < m_Quads.Length; loop++)
                    {
                        GameFiles.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                            m_Quads[loop].Vertices, 0, 4,
                            m_Quads[loop].Indexes, 0, 2);
                    }

                    GameFiles.GraphicsDevice.BlendState = BlendState.Opaque;
                    GameFiles.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
                }
            }

            GameFiles.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        }
Пример #40
0
 public static void SetPivot(this RectTransform RT, PivotType type)
 {
     switch (type)
     {
         case PivotType.TopCenter:
             RT.pivot = new Vector2(0.5f, 1);
             break;
         case PivotType.LeftCenter:
             RT.pivot = new Vector2(0, 0.5f);
             break;
         case PivotType.RightCenter:
             RT.pivot = new Vector2(1, 0.5f);
             break;
         case PivotType.BottomCenter:
             RT.pivot = new Vector2(0.5f, 0);
             break;
         case PivotType.TopLeft:
             RT.pivot = new Vector2(0, 1);
             break;
         case PivotType.TopRight:
             RT.pivot = new Vector2(1, 1);
             break;
         case PivotType.BottomLeft:
             RT.pivot = new Vector2(0, 0);
             break;
         case PivotType.BottomRight:
             RT.pivot = new Vector2(1, 0);
             break;
         case PivotType.Center:
             RT.pivot = new Vector2(0.5f, 0.5f);
             break;
         default:
             //Center
             RT.pivot = new Vector2(0.5f, 0.5f);
             break;
     }
 }
Пример #41
0
	/// <summary>
	/// Creates a SuperPlane game object, and assigns the given data! This function will build the mesh right away.
	/// </summary>
	/// <param name="aPivotPt">Location to place the pivot point of the object. This is not the actual position of the object after the pivot is applied.</param>
	/// <param name="aPivotType">A bit flag that represents where the pivot is located. This only accepts Top, Bottom, Left, Right flag options, Top being +Z</param>
	/// <param name="aSize">The width and height of the SuperPlane.</param>
	/// <param name="aMaterial">The material to assign to it, don't want that awful pink color!</param>
	/// <param name="aType">What type of UV coordinates do you want on the plane?</param>
	/// <param name="aSliceDistance">How far apart should extra verts be spaced out on the surface? 0 for none at all. floor(size/sliceDistance)</param>
	/// <returns>A ready-to-go SuperPlane GameObject named "SuperPlane" with a with a fully built SuperPlane, MeshFilter, Renderer, and BoxCollider component!</returns>
	public static GameObject CreatePivot (Vector3 aPivotPt, PivotType aPivotType, Vector2 aSize, Material aMaterial, UVType aType = UVType.Unit, float aSliceDistance = 0) {
		Vector2 halfSize = aSize/2;
		Vector3 point    = aPivotPt;
		
		if ((aPivotType & PivotType.Top   ) > 0) {
			point.z -= halfSize.y;
		}
		if ((aPivotType & PivotType.Bottom) > 0) {
			point.z += halfSize.y;
		}
		if ((aPivotType & PivotType.Left  ) > 0) {
			point.x += halfSize.x;
		}
		if ((aPivotType & PivotType.Right ) > 0) {
			point.x -= halfSize.x;
		}
		
		return Create(point, aSize, aMaterial, aType, aSliceDistance);
	}
Пример #42
0
	/// <summary>
	/// Creates a SuperCube game object using a pivot point to determine location, and assigns the given data! This function will build the cube mesh right away.
	/// </summary>
	/// <param name="aPivotPt">Location in space for the pivot point to be placed.</param>
	/// <param name="aPivotType">A bit mask defining where on the cube the pivot is placed. Opposing sides indicate to center along that axis.</param>
	/// <param name="aSize">The width, height, and depth of the SuperCube.</param>
	/// <param name="aMaterial">The default material for the entire SuperCube.</param>
	/// <param name="aWallUV">The type of UV calculations to use for the +X, -X, +Z, -Z faces.</param>
	/// <param name="aTopBottomUV">The type of UV calculations to use for the +Y, -Y faces.</param>
	/// <param name="aSliceDistance">How far apart shall we try and place vertex slices on the faces? floor(size/sliceDistance)</param>
	/// <param name="aHideFaces">A bit mask describing which faces should be hidden.</param>
	/// <param name="aOverrideTop">Material override for the +Y face.</param>
	/// <param name="aOverrideBottom">Material override for the -Y face.</param>
	/// <param name="aOverrideLeft">Material override for the -X face.</param>
	/// <param name="aOverrideRight">Material override for the +X face.</param>
	/// <param name="aOverrideFront">Material override for the -Z face.</param>
	/// <param name="aOverrideBack">Material override for the +Z face.</param>
	/// <returns>A GameObject named "SuperCube" with a fully built SuperCube, MeshFilter, Renderer, and BoxCollider component!</returns>
	public static GameObject CreatePivot (Vector3 aPivotPt, PivotType aPivotType, Vector3 aSize, Material aMaterial, UVType aWallUV = UVType.WorldCoordinates, UVType aTopBottomUV = UVType.WorldCoordinates, float aSliceDistance = 0, PivotType aHideFaces = PivotType.None, Material aOverrideTop = null, Material aOverrideBottom = null, Material aOverrideLeft = null, Material aOverrideRight = null, Material aOverrideFront = null, Material aOverrideBack = null ) {
		Vector3 halfSize = aSize/2;
		Vector3 point    = aPivotPt;
		
		if ((aPivotType & PivotType.Top   ) > 0) {
			point.y -= halfSize.y;
		}
		if ((aPivotType & PivotType.Bottom) > 0) {
			point.y += halfSize.y;
		}
		if ((aPivotType & PivotType.Left  ) > 0) {
			point.x += halfSize.x;
		}
		if ((aPivotType & PivotType.Right ) > 0) {
			point.x -= halfSize.x;
		}
		if ((aPivotType & PivotType.Front ) > 0) {
			point.z += halfSize.z;
		}
		if ((aPivotType & PivotType.Back ) > 0) {
			point.z -= halfSize.z;
		}
		
		return Create(point, aSize, aMaterial, aWallUV, aTopBottomUV, aSliceDistance, aHideFaces, aOverrideTop, aOverrideBottom, aOverrideLeft, aOverrideRight, aOverrideFront, aOverrideBack);
	}
Пример #43
0
        /// <summary>
        /// Probably temporary - we will want to have possibility to choose pivot type by some key maybe?
        /// </summary>
        static void SetActivePivot()
        {
            //Debug.Assert(!(SelectedSnapPoint != null && SelectedEntities.Count != 0));

            if (SelectedEntities.Count == 1 || SelectedSnapPoint != null)
            {
                ActivePivot = PivotType.OBJECT_CENTER;
                if (MyEditor.EnableObjectPivot)
                {
                    ActivePivot = PivotType.OBJECT_CENTER;
                }
                else
                {
                    ActivePivot = PivotType.MODEL_CENTER;
                }
            }
            else if (SelectedEntities.Count > 1)
            {
                ActivePivot = PivotType.SELECTION_CENTER;
            }
        }
Пример #44
0
		private bool DoDragDrop() {
			bool      rebuild = false;
			SuperCube cube    = target as SuperCube;
			
			if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) {// || Event.current.type == EventType.Repaint) {
				Material dragMat = null;
				for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i) {
					if (DragAndDrop.objectReferences[i] is Material) {
						dragMat = DragAndDrop.objectReferences[i] as Material;
					}
				}
				
				if (dragMat != null) {
					DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
					PivotType side = RaycastSide(cube, HandleUtility.GUIPointToWorldRay(Event.current.mousePosition));
					
					if (side != mDragPrevSide) {
						if (mDragPrevSide != PivotType.None) {
							SetSideMaterial(cube, mDragPrevSide, mDragPrevMaterial);
						}
						mDragPrevMaterial = GetSideMaterial(cube, side);
					}
					SetSideMaterial(cube, side, dragMat);
					rebuild = true;
					mDragPrevSide = side;
					
					if (Event.current.type == EventType.DragPerform) {
						DragAndDrop.AcceptDrag();
						mDragPrevMaterial = null;
						mDragPrevSide     = PivotType.None;
					}
					if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform) {
						Event.current.Use();
					}
				}
			}
			
			return rebuild;
		}
        public bool Pivot(string pivotName, PivotType pivot)
        {
            var command = new PivotCommand
                {
                    AutomationIdentifier = CreateAutomationIdentifier(pivotName),
                    PivotLast = pivot == PivotType.Last,
                    PivotNext = pivot == PivotType.Next
                };

            var result = SyncExecuteCommand(command);
            Thread.Sleep(TimeSpan.FromSeconds(3)); // Wait for pivot animations to complete

            return result is SuccessResult;
        }
Пример #46
0
 //public void SetGizmoMode(GizmoMode mode)
 //{
 //  ActiveMode = mode;
 //}
 //public void SetTransformSpace(TransformSpace space)
 //{
 //  ActiveSpace = space;
 //}
 //public void SetPivotType(PivotType pivot)
 //{
 //  ActivePivot = pivot;
 //}
 public void NextPivotType()
 {
     if (ActivePivot == PivotType.WorldOrigin)
     ActivePivot = PivotType.ObjectCenter;
       else
     ActivePivot++;
 }