Пример #1
0
		public static MatrixTransform3D Rotate3D(Transform3D transform, double x, double y, double z, Point3D center, Vector3D up, Vector3D look, RotationType type)
		{
			if (type != RotationType.LockAxisY)
			{
				up = transform.Transform(up);
			}
			if (type != RotationType.LockAxisZ)
			{
				look = transform.Transform(look);
			}
			center = transform.Transform(center);
			Vector3D axisX = Vector3D.CrossProduct(up, look);
			Matrix3D matrix = new Matrix3D();
			matrix.RotateAt(new Quaternion(axisX, x), center);
			matrix.RotateAt(new Quaternion(up, y), center);
			matrix.RotateAt(new Quaternion(look, z), center);
			MatrixTransform3D mOriginTransform = transform as MatrixTransform3D;
			//mOriginTransform.Matrix.RotateAt(
			try
			{
				return new MatrixTransform3D(Matrix3D.Multiply(mOriginTransform.Matrix, matrix));
			}
			catch (Exception err)
			{
				Exceptions.LogOnly(err);
				return null;
			}
		}
        // *** METHODS ***

        /// <summary>
        /// Rotates the point around a particular axis
        /// </summary>
        /// <param name="type">Rotation axis</param>
        /// <param name="angleInDeg">Angle to be rotated</param>
        public void Rotate(RotationType type, double angleInDeg)
        {
            // Rotation matrix: http://de.wikipedia.org/wiki/Drehmatrix
            var rad = angleInDeg * Math.PI / 180;
            var cosa = Math.Cos(rad);
            var sina = Math.Sin(rad);
            var x = this.X;
            var y = this.Y;
            var z = this.Z;

            switch (type)
            {
                case RotationType.X:
                    this.Y = y * cosa - z * sina;
                    this.Z = y * sina + z * cosa;
                    break;

                case RotationType.Y:
                    this.X = z * sina + x * cosa;
                    this.Z = z * cosa - x * sina;
                    break;

                case RotationType.Z:
                    this.X = x * cosa - y * sina;
                    this.Y = x * sina + y * cosa;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
            //GC.Collect();
        }
Пример #3
0
		public static Matrix3D CalcRotationMatrix(double x, double y, double z, Point3D center, Vector3D up, Vector3D look, Transform3D transform, RotationType type)
		{
			//Transform3DGroup trm = new Transform3DGroup();
			//trm.Children.Add(transform);
			Vector3D realup = transform.Transform(up);
			if (type != RotationType.LockAxisY)
			{
				up = realup;
			}
			if (type != RotationType.LockAxisZ)
			{
				look = transform.Transform(look);
			}
			center = transform.Transform(center);
			Vector3D axisX = Vector3D.CrossProduct(up, look);
			Matrix3D matrix = new Matrix3D();
			//Quaternion q = new Quaternion();
			//q.
			double ang = AngleBetween(realup, YAxis) + x;
			if (ang >= 90)
			{
				x = 90 - ang;
			}
			matrix.RotateAt(new Quaternion(axisX, x), center);
			matrix.RotateAt(new Quaternion(up, y), center);
			matrix.RotateAt(new Quaternion(look, z), center);
			return matrix;
		}
	// Update is called once per frame
	void Update () 
	{
		//Sólo si no se está rotando en este momento
		if(rotationType != RotationType.none)
		{
			//Cantidad a rotar
			float quantityRotation = Time.deltaTime * speedRotation;
			//Cantidad acumulada
			accumulatedRotation += quantityRotation;

			//¿Nos hemos pasado de 90?
			if(accumulatedRotation > ROTATION_QUANTITY)
			{
				//Descontamos quantityRotation
				accumulatedRotation -= quantityRotation;
				//Calculamos lo que falta para 90
				quantityRotation = ROTATION_QUANTITY - accumulatedRotation;
				//Rotamos
				Rotate(quantityRotation);
				//El próximo Update ya no se rota
				rotationType = RotationType.none;
			}
			else
			{
				//Rotamos
				Rotate(quantityRotation);
			}


		}
	}
Пример #5
0
 protected BlockFace()
 {
     TileNumber = 0;
     Flat = false;
     Flip = false;
     Rotation = RotationType.RotateNone;
 }
Пример #6
0
        // *** METHODS ***
        /// <summary>
        /// Rotates the point around a particular axis
        /// </summary>
        /// <param name="type">Rotation axis</param>
        /// <param name="angleInDeg">Angle to be rotated</param>
        public void Rotate(RotationType type, double angleInDeg)
        {
            // Rotation matrix: http://de.wikipedia.org/wiki/Drehmatrix
              double rad = angleInDeg * Math.PI / 180;
              double cosa = Math.Cos(rad);
              double sina = Math.Sin(rad);

              Point3D old = new Point3D(this.X, this.Y, this.Z);

              switch (type)
              {
            case RotationType.X:
              this.Y = old.Y * cosa - old.Z * sina;
              this.Z = old.Y * sina + old.Z * cosa;
              break;
            case RotationType.Y:
              this.X = old.Z * sina + old.X * cosa;
              this.Z = old.Z * cosa - old.X * sina;
              break;
            case RotationType.Z:
              this.X = old.X * cosa - old.Y * sina;
              this.Y = old.X * sina + old.Y * cosa;
              break;
              }
        }
Пример #7
0
        /// <summary>
        /// Gets the coordinates for the texture acording to its rotation and flip.
        /// </summary>
        /// <remarks>The return values are stored 0->BottonLeft; 1->BottonRight; 2->TopRight; 3->TopLeft</remarks>
        /// <param name="tileID">The ID of the texture.</param>
        /// <param name="rotation">The rotation to aply to the texture.</param>
        /// <param name="flip">If the Texture must be fliped.</param>
        /// <returns>A array with 4 positions where each position represent one of the vertices od the texture, it will be a square with 64px.</returns>
        public Vector2[] GetNormalTexture(UInt32 tileID, RotationType rotation, Boolean flip)
        {
            var texturePosition = new Vector2[4];
            CompactRectangle tex = tileAtlas[(int)tileID];

            var texTopLeft = new Vector2((tex.X + 1) * pixelPerWidth, (tex.Y + 1) * pixelPerHeight);
            var texTopRight = new Vector2((tex.X + tex.Width - 1) * pixelPerWidth, (tex.Y + 1) * pixelPerHeight);
            var texBottomLeft = new Vector2((tex.X + 1) * pixelPerWidth, (tex.Y + tex.Height - 1) * pixelPerHeight);
            var texBottomRight = new Vector2((tex.X + tex.Width - 1) * pixelPerWidth, (tex.Y + tex.Height - 1) * pixelPerHeight);

            if (flip)
            {
                Vector2 helper = texTopLeft;
                texTopLeft = texTopRight;
                texTopRight = helper;

                helper = texBottomLeft;
                texBottomLeft = texBottomRight;
                texBottomRight = helper;

                if (rotation == RotationType.Rotate90) //special cases.
                {
                    rotation = RotationType.Rotate270;
                }
                else if (rotation == RotationType.Rotate270)
                {
                    rotation = RotationType.Rotate90;
                }
            }

            switch (rotation)
            {
                case RotationType.RotateNone:
                    texturePosition[0] = texBottomLeft;
                    texturePosition[1] = texBottomRight;
                    texturePosition[2] = texTopRight;
                    texturePosition[3] = texTopLeft;
                    break;
                case RotationType.Rotate90:
                    texturePosition[3] = texBottomLeft;
                    texturePosition[0] = texBottomRight;
                    texturePosition[1] = texTopRight;
                    texturePosition[2] = texTopLeft;
                    break;
                case RotationType.Rotate180:
                    texturePosition[2] = texBottomLeft;
                    texturePosition[3] = texBottomRight;
                    texturePosition[0] = texTopRight;
                    texturePosition[1] = texTopLeft;
                    break;
                case RotationType.Rotate270:
                    texturePosition[1] = texBottomLeft;
                    texturePosition[2] = texBottomRight;
                    texturePosition[3] = texTopRight;
                    texturePosition[0] = texTopLeft;
                    break;
            }
            return texturePosition;
        }
        public void transform_images(RotationType rotate, FlippingType flip)
        {
            var image = Image.Load("TestImages/Backdrop.jpg");
            var watch = Stopwatch.StartNew();

            image = image.Transform(rotate, flip);

            Trace.WriteLine($"{ rotate }-{ flip }: { watch.ElapsedMilliseconds}ms");

            image.VerifyAndSave($"TestResult/Transformed/{ rotate }-{ flip }.jpg");
        }
        // *** METHODS ***

        /// <summary>
        /// Rotates the point around a particular axis
        /// </summary>
        /// <param name="type">Rotation axis</param>
        /// <param name="angle">Angle to be rotated</param>
        /// <param name="center">Center point of rotation</param>
        public Cube3D Rotate(RotationType type, double angle, Point3D center)
        {
            //Deep Clone
            var faces = new List<Face3D>();
            foreach (var f2 in from f in this.Faces let edges = f.Vertices.Select(p => new Point3D(p.X, p.Y, p.Z)).ToList() select new Face3D(edges, f.Color, f.Position, f.MasterPosition))
            {
                f2.Vertices.ToList().ForEach(e => { e.X -= center.X; e.Y -= center.Y; e.Z -= center.Z; });
                f2.Rotate(type, angle);
                f2.Vertices.ToList().ForEach(e => { e.X += center.X; e.Y += center.Y; e.Z += center.Z; });
                faces.Add(f2);
            }
            return new Cube3D(faces, this.Position, this.Location, this.Scale);
        }
        internal static Image Transform(Image source, RotationType rotationType, FlippingType flippingType)
        {
            Image target;

            switch (rotationType)
            {
                case RotationType.None:
                    {
                        byte[] targetPixels = source.Pixels;
                        byte[] sourcePixels = new byte[targetPixels.Length];

                        Array.Copy(targetPixels, sourcePixels, targetPixels.Length);

                        target = new Image(source.Width, source.Height, sourcePixels);
                    }
                    break;
                case RotationType.Rotate90:
                    {
                        target = Rotate90(source);
                    }
                    break;
                case RotationType.Rotate180:
                    {
                        target = Rotate180(source);
                    }
                    break;
                case RotationType.Rotate270:
                    {
                        target = Rotate270(source);
                    }
                    break;
                default:
                    {
                        target = source.Clone();
                    }
                    break;
            }

            switch (flippingType)
            {
                case FlippingType.Vertical:
                    FlipX(target);
                    break;
                case FlippingType.Horizontal:
                    FlipY(target);
                    break;
            }

            return target;
        }
        /// <summary>
        /// Transforms the specified image by flipping and rotating it. First the image
        /// will be rotated, then the image will be flipped. A new image will be returned. The original image
        /// will not be changed.
        /// </summary>
        /// <param name="source">The image, which should be transformed.</param>
        /// <param name="target">The new transformed image.</param>
        /// <param name="rotationType">Type of the rotation.</param>
        /// <param name="flippingType">Type of the flipping.</param>
        /// <exception cref="ArgumentNullException">
        /// 	<para><paramref name="source"/> is null (Nothing in Visual Basic).</para>
        /// 	<para>- or -</para>
        /// 	<para><paramref name="target"/> is null (Nothing in Visual Basic).</para>
        /// </exception>
        internal static void Transform(ImageBase source, ImageBase target, RotationType rotationType, FlippingType flippingType)
        {
            Contract.Requires<ArgumentNullException>(source != null, "Source image cannot be null.");
            Contract.Requires<ArgumentException>(source.IsFilled, "Source image has not been loaded.");
            Contract.Requires<ArgumentNullException>(target != null, "Target image cannot be null.");

            switch (rotationType)
            {
                case RotationType.None:
                    {
                        byte[] targetPixels = source.Pixels;
                        byte[] sourcePixels = new byte[targetPixels.Length];

                        Array.Copy(targetPixels, sourcePixels, targetPixels.Length);

                        target.SetPixels(source.PixelWidth, source.PixelHeight, sourcePixels);
                    }
                    break;
                case RotationType.Rotate90:
                    {
                        Rotate90(source, target);
                    }
                    break;
                case RotationType.Rotate180:
                    {
                        Rotate180(source, target);
                    }
                    break;
                case RotationType.Rotate270:
                    {
                        Rotate270(source, target);
                    }
                    break;
                default:
                    throw new InvalidOperationException();
            }

            switch (flippingType)
            {
                case FlippingType.FlipX:
                    FlipX(target);
                    break;
                case FlippingType.FlipY:
                    FlipY(target);
                    break;
            }
        }
Пример #12
0
    /// <summary>
    /// Rotate the specified towards.
    /// El parámetro towards lo pasa el botón
    /// </summary>
    /// <param name="towards">Towards.</param>
    public void SetRotataionType(string towards)
    {
        //Sólo si no se está rotando en este momento
        if(rotationType == RotationType.none)
        {
            if(towards == "left")
                rotationType = RotationType.left;
            else if(towards == "right")
                rotationType = RotationType.right;
            else if(towards == "up")
                rotationType = RotationType.up;
            else if(towards == "down")
                rotationType = RotationType.down;

            accumulatedRotation = 0;
        }
    }
        private double getRotationValue(RotationType typeR)
        {
            string text = range[0, 32].Text;
            if (typeR == RotationType.Y)
            {
                text = range[0, 33].Text;
            }
            else if (typeR == RotationType.Z)
            {
                text = range[0, 34].Text;
            }

            if (string.IsNullOrEmpty(text.Trim()))
            {
                //this.writeError("未填写,默认为0", "板件绕" + typeR.ToString() + "旋转角度");
                return 0;
            }

            return GetDoubleValue(text, "板件绕" + typeR.ToString() + "旋转角度", false, errors);
        }
Пример #14
0
 public CurveHolderNew(CurveHolderNew source)
 {
     name   = source.name;
     anglex = new AnimationCurve(source.anglex.keys);
     angley = new AnimationCurve(source.angley.keys);
     anglez = new AnimationCurve(source.anglez.keys);
     posx   = new AnimationCurve(source.posx.keys);
     posy   = new AnimationCurve(source.posy.keys);
     posz   = new AnimationCurve(source.posz.keys);
     rotx   = new AnimationCurve(source.rotx.keys);
     roty   = new AnimationCurve(source.roty.keys);
     rotz   = new AnimationCurve(source.rotz.keys);
     rotw   = new AnimationCurve(source.rotw.keys);
     mType  = source.mType;
     rType  = source.rType;
     if (source.animationStateData != null)
     {
         animationStateData = new List <string> (source.animationStateData);
     }
     isLocal = source.isLocal;
 }
Пример #15
0
        private double getRotationValue(RotationType typeR)
        {
            string text = range[0, 32].Text;

            if (typeR == RotationType.Y)
            {
                text = range[0, 33].Text;
            }
            else if (typeR == RotationType.Z)
            {
                text = range[0, 34].Text;
            }

            if (string.IsNullOrEmpty(text.Trim()))
            {
                //this.writeError("未填写,默认为0", "板件绕" + typeR.ToString() + "旋转角度");
                return(0);
            }

            return(GetDoubleValue(text, "板件绕" + typeR.ToString() + "旋转角度", false, errors));
        }
Пример #16
0
    float GetDegreesDistance(RotationType rotType, float initDeg, float destDeg)
    {
        float _destDeg = ( (int)destDeg )%360;
        int rounds = ( (int)_destDeg )/360;
        int remain = ( (int)_destDeg )%360;

        if( remain <= 0 )
            remain = 360 + remain;

        float distance = initDeg - remain;
        MZMove.RotationType resultRotType = ( distance >= 0 )? MZMove.RotationType.CW : MZMove.RotationType.CCW;
        distance = Mathf.Abs( distance );

        if( rotType != resultRotType )
            distance = 360 - distance;

        distance = distance*( ( rotType == MZMove.RotationType.CCW )? 1 : -1 );
        distance += 360*rounds;

        return distance;
    }
Пример #17
0
        protected override void OnMouseDown(MouseEventArgs e) {

            base.OnMouseDown(e);
            mouseWas = e.Location;

            switch(e.Button) {
                case System.Windows.Forms.MouseButtons.Left:
                    rotationType = RotationType.Model;
                    break;

                case System.Windows.Forms.MouseButtons.Right:
                    rotationType = RotationType.Camera;
                    break;

                default:
                    rotationType = RotationType.None;
                    break;

            }
            
        }
Пример #18
0
        public ElementCloud()
        {
            this.Background = Brushes.Transparent;

            canvas = new Canvas()
            {
                VerticalAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };
            this.Children.Add(canvas);
            rotateTransform = new RotateTransform3D();

            SizeChanged += OnPageSizeChanged;

            rotationType = RotationType.Mouse;
            rotateDirection = new Point(100, 0);
            slowDownCounter = 500;
            elementsCollection = new List<ElementCloudItem>();
            scaleRatio = 0.09;
            opacityRatio = 1.3;
        }
Пример #19
0
        /// <summary>
        /// Represents a face (left, right, top, bottom, lid) of a block.
        /// </summary>
        /// <param name="value">Base ushort value of this face.</param>
        protected BlockFace(ushort value)
        {
            if (value == 0)
            {
                return;
            }

            //parse ushort value
            //Bits 0-9: Tile number
            uint tile = 0;

            for (var i = 0; i < 10; i++)
            {
                tile = tile + (value & (uint)Math.Pow(2, i));
            }
            TileNumber = tile;

            Flat = BitHelper.CheckBit(value, 12); //Bit 12
            Flip = BitHelper.CheckBit(value, 13); //Bit 13

            var bit14 = BitHelper.CheckBit(value, 14);
            var bit15 = BitHelper.CheckBit(value, 15);

            if (!bit14 && !bit15)
            {
                Rotation = RotationType.RotateNone;
            }
            if (bit14 && !bit15)
            {
                Rotation = RotationType.Rotate90;
            }
            if (!bit14 && bit15)
            {
                Rotation = RotationType.Rotate180;
            }
            if (bit14 && bit15)
            {
                Rotation = RotationType.Rotate270;
            }
        }
Пример #20
0
        /// <summary>
        /// Returns the index of the next direction based on
        /// the current direction index and the rotation type.
        /// </summary>
        /// <param name="currentDirection"></param>
        /// <param name="rotation"></param>
        /// <returns></returns>
        private static int GetNextDirection(int currentDirection, RotationType rotation)
        {
            int directionsCount = directions.Length;

            if (rotation == RotationType.Right)
            {
                // get the index of the next element in the array
                return (currentDirection + 1) % directionsCount;
            }
            else // RotationType.Left
            {
                if (currentDirection == 0)
                {
                    return directionsCount - 1;
                }
                else
                {
                    // get the index of the previous element in the array
                    return currentDirection - 1;
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Returns the index of the next direction based on
        /// the current direction index and the rotation type.
        /// </summary>
        /// <param name="currentDirection"></param>
        /// <param name="rotation"></param>
        /// <returns></returns>
        private static int GetNextDirection(int currentDirection, RotationType rotation)
        {
            int directionsCount = directions.Length;

            if (rotation == RotationType.Right)
            {
                // get the index of the next element in the array
                return((currentDirection + 1) % directionsCount);
            }
            else // RotationType.Left
            {
                if (currentDirection == 0)
                {
                    return(directionsCount - 1);
                }
                else
                {
                    // get the index of the previous element in the array
                    return(currentDirection - 1);
                }
            }
        }
Пример #22
0
        protected virtual IConverter GetConverter(RotationType type)
        {
            switch (type)
            {
            case RotationType.ImproveXYPlanes:
            {
                return(new XYConverter());
            }

            case RotationType.ImproveXZPlanes:
            {
                return(new XZConverter());
            }

            case RotationType.Simplex:
            {
                return(new SimplexConverter());
            }
            }

            return(new NoneConverter());
        }
Пример #23
0
        private Color GetColorWithRotation(Texture2D tex, int x, int y, RotationType rotation)
        {
            int tempX = x;
            int tempY = y;

            switch (rotation)
            {
            case RotationType.None:
                break;

            case RotationType.ClockWise:
                tempX = CELLSIZE - tempY - 1;
                tempY = x;
                break;

            case RotationType.AntiClockWise:
                tempX = tempY;
                tempY = CELLSIZE - x - 1;
                break;

            case RotationType.OppositesUpDown:
                tempY = CELLSIZE - tempY - 1;
                break;

            case RotationType.OppositesLeftRight:
                tempX = CELLSIZE - tempX - 1;
                break;

            case RotationType.DuiJiaoRightTop:
                if ((tempX + tempY) != CELLSIZE - 1)
                {
                    tempX = CELLSIZE - tempY;
                    tempY = CELLSIZE - x;
                }
                break;
            }
            return(tex.GetPixel(tempX, tempY));
        }
Пример #24
0
        /// <summary>
        /// Gets the coordinates for the texture acording to its rotation and flip.
        /// </summary>
        /// <remarks>The return values are stored 0->BottonLeft; 1->BottonRight; 2->TopRight; 3->TopLeft</remarks>
        /// <param name="tileID">The ID of the texture.</param>
        /// <param name="rotation">The rotation to aply to the texture.</param>
        /// <param name="flip">If the Texture must be fliped.</param>
        /// <param name="position">The position of the texture inside the 64px texture.</param>
        /// <param name="vertical">Is a vertical Rectangle.</param>
        /// <returns>A array with 4 positions where each position represent one of the vertices od the texture, it will be a rectangle 64pxX24px.</returns>
        public Vector2[] GetRectangleTexture(UInt32 tileID, RotationType rotation, Boolean flip, RectangleTexturePosition position)
        {
            Vector2[] texture = GetNormalTexture(tileID, rotation, flip);

            switch (position)
            {
            case RectangleTexturePosition.Botton:
                return(bottomRectangle(texture, rotation));

            case RectangleTexturePosition.Top:
                return(topRectangle(texture, rotation));

            case RectangleTexturePosition.CenterHorizontal:
                break;

            case RectangleTexturePosition.Left:
                return(leftRectangle(texture, rotation));

            case RectangleTexturePosition.Right:
                return(rightRectangle(texture, rotation));
            }
            throw new NotImplementedException();
        }
Пример #25
0
        private Orientation Transform(FaceColor newUp,
                                      FaceColor newRight,
                                      FaceColor newFront,
                                      RotationType upRotationType,
                                      RotationType rightRotationType,
                                      RotationType frontRotationType,
                                      RotationType downRotationType,
                                      RotationType leftRotationType,
                                      RotationType backRotationType)
        {
            var up    = Colors.Forwards[newUp];
            var right = Colors.Forwards[newRight];
            var front = Colors.Forwards[newFront];


            return(new Orientation(up, right, front,
                                   Move(Directions[newUp], upRotationType),
                                   Move(Directions[newRight], rightRotationType),
                                   Move(Directions[newFront], frontRotationType),
                                   Move(Directions[GetOpposite(newUp)], downRotationType),
                                   Move(Directions[GetOpposite(newRight)], leftRotationType),
                                   Move(Directions[GetOpposite(newFront)], backRotationType)
                                   ));
        }
Пример #26
0
        /// <summary>
        /// Post the players score to the given social leaderboard.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - SocialLeaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="in_leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="in_score">
        /// The score to post
        /// </param>
        /// <param name="in_data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="in_leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="in_rotationType">
        /// Type of rotation
        /// </param>
        /// <param name="in_rotationReset">
        /// Date to reset the leaderboard (Date is converted to "dd-mm-yyyy hh:ss" format)
        /// </param>
        /// <param name="in_retainedCount">
        /// Hpw many rotations to keep
        /// </param>
        /// <param name="in_success">
        /// The success callback.
        /// </param>
        /// <param name="in_failure">
        /// The failure callback.
        /// </param>
        /// <param name="in_cbObject">
        /// The user object sent to the callback.
        /// </param>
        /// <returns> The JSON returned in the callback is as follows:
        /// {
        ///   "status":200,
        ///   "data":{
        ///   }
        /// }
        /// </returns>
        public void PostScoreToDynamicLeaderboard(
            string in_leaderboardId,
            long in_score,
            string in_jsonData,
            SocialLeaderboardType in_leaderboardType,
            RotationType in_rotationType,
            DateTime?in_rotationReset,
            int in_retainedCount,
            SuccessCallback in_success = null,
            FailureCallback in_failure = null,
            object in_cbObject         = null)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();

            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value]         = in_score;
            if (Util.IsOptionalParameterValid(in_jsonData))
            {
                Dictionary <string, object> customData = JsonReader.Deserialize <Dictionary <string, object> >(in_jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = in_leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value]    = in_rotationType.ToString();

            if (in_rotationReset.HasValue)
            {
                data[OperationParam.SocialLeaderboardServiceRotationReset.Value] = in_rotationReset.Value.ToString("d-MM-yyyy HH:mm");
            }

            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = in_retainedCount;

            ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject);
            ServerCall     sc       = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.PostScoreDynamic, data, callback);

            m_brainCloudClientRef.SendRequest(sc);
        }
Пример #27
0
        public RotationType GetRotationType(HunterTalents t)
        {
            RotationType curRotationType = RotationType.Custom;

            if (t != null)
            {
                if (t.HighestTree == (int)Specialization.BeastMastery)
                {
                    // Beast Mastery
                    curRotationType = Rotation.RotationType.BeastMastery;
                }
                else if (t.HighestTree == (int)Specialization.Marksmanship)
                {
                    // Marksmanship
                    curRotationType = Rotation.RotationType.Marksmanship;
                }
                if (t.HighestTree == (int)Specialization.Survival)
                {
                    // Survival
                    curRotationType = Rotation.RotationType.Survival;
                }
            }
            return(curRotationType);
        }
Пример #28
0
        /// <summary>
        /// Post the players score to the given social leaderboard.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - leaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="score">
        /// The score to post
        /// </param>
        /// <param name="data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="rotationType">
        /// Type of rotation
        /// </param>
        /// <param name="rotationReset">
        /// Date to reset the leaderboard UTC
        /// </param>
        /// <param name="retainedCount">
        /// How many rotations to keep
        /// </param>
        /// <param name="success">
        /// The success callback.
        /// </param>
        /// <param name="failure">
        /// The failure callback.
        /// </param>
        /// <param name="cbObject">
        /// The user object sent to the callback.
        /// </param>
        public void PostScoreToDynamicLeaderboard(
            string leaderboardId,
            long score,
            string jsonData,
            SocialLeaderboardType leaderboardType,
            RotationType rotationType,
            DateTime?rotationReset,
            int retainedCount,
            SuccessCallback success = null,
            FailureCallback failure = null,
            object cbObject         = null)
        {
            var data = new Dictionary <string, object>();

            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value]         = score;
            if (Util.IsOptionalParameterValid(jsonData))
            {
                var customData = JsonReader.Deserialize <Dictionary <string, object> >(jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value]    = rotationType.ToString();

            if (rotationReset.HasValue)
            {
                data[OperationParam.SocialLeaderboardServiceRotationResetTime.Value] = Util.DateTimeToUnixTimestamp(rotationReset.Value);
            }

            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = retainedCount;

            var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject);
            var sc       = new ServerCall(ServiceName.Leaderboard, ServiceOperation.PostScoreDynamic, data, callback);

            _client.SendRequest(sc);
        }
Пример #29
0
        static dynamic Decode(BinaryReader reader, int version, Type ensure = null, bool root = false)
        {
            Type t = DecodeID(reader);

            if (ensure != null && ensure != t)
            {
                throw new InvalidDataException();
            }

            if (t == typeof(Preferences) && root)
            {
                Preferences.AlwaysOnTop         = reader.ReadBoolean();
                Preferences.CenterTrackContents = reader.ReadBoolean();

                if (version >= 9)
                {
                    Preferences.LaunchpadStyle = (LaunchpadStyles)reader.ReadInt32();
                }

                if (version >= 14)
                {
                    Preferences.LaunchpadGridRotation = reader.ReadInt32() > 0;
                }

                Preferences.AutoCreateKeyFilter  = reader.ReadBoolean();
                Preferences.AutoCreatePageFilter = reader.ReadBoolean();

                if (version >= 11)
                {
                    Preferences.AutoCreatePattern = reader.ReadBoolean();
                }

                Preferences.FadeSmoothness    = reader.ReadDouble();
                Preferences.CopyPreviousFrame = reader.ReadBoolean();

                if (version >= 7)
                {
                    Preferences.CaptureLaunchpad = reader.ReadBoolean();
                }

                Preferences.EnableGestures = reader.ReadBoolean();

                if (version >= 7)
                {
                    Preferences.PaletteName   = reader.ReadString();
                    Preferences.CustomPalette = new Palette((from i in Enumerable.Range(0, 128) select(Color) Decode(reader, version)).ToArray());
                    Preferences.ImportPalette = (Palettes)reader.ReadInt32();

                    Preferences.Theme = (Themes)reader.ReadInt32();
                }

                if (version >= 10)
                {
                    Preferences.Backup   = reader.ReadBoolean();
                    Preferences.Autosave = reader.ReadBoolean();
                }

                if (version >= 12)
                {
                    Preferences.UndoLimit = reader.ReadBoolean();
                }

                if (version <= 0)
                {
                    Preferences.DiscordPresence = true;
                    reader.ReadBoolean();
                }
                else
                {
                    Preferences.DiscordPresence = reader.ReadBoolean();
                }

                Preferences.DiscordFilename = reader.ReadBoolean();

                ColorHistory.Set(
                    (from i in Enumerable.Range(0, reader.ReadInt32()) select(Color) Decode(reader, version)).ToList()
                    );

                if (version >= 2)
                {
                    MIDI.Devices = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Launchpad) Decode(reader, version)).ToList();
                }

                if (version >= 15)
                {
                    Preferences.Recents   = (from i in Enumerable.Range(0, reader.ReadInt32()) select reader.ReadString()).ToList();
                    Preferences.CrashName = reader.ReadString();
                    Preferences.CrashPath = reader.ReadString();
                }

                if (version >= 16)
                {
                    Preferences.CheckForUpdates = reader.ReadBoolean();
                }

                if (version >= 17)
                {
                    Preferences.BaseTime = reader.ReadInt64();
                }

                return(null);
            }
            else if (t == typeof(Copyable))
            {
                return(new Copyable()
                {
                    Contents = (from i in Enumerable.Range(0, reader.ReadInt32()) select(ISelect) Decode(reader, version)).ToList()
                });
            }
            else if (t == typeof(Project))
            {
                int          bpm    = reader.ReadInt32();
                int          page   = reader.ReadInt32();
                List <Track> tracks = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Track) Decode(reader, version)).ToList();

                string author  = "";
                long   time    = 0;
                long   started = 0;

                if (version >= 17)
                {
                    author  = reader.ReadString();
                    time    = reader.ReadInt64();
                    started = reader.ReadInt64();
                }

                return(new Project(bpm, page, tracks, author, time, started));
            }
            else if (t == typeof(Track))
            {
                Chain     chain = (Chain)Decode(reader, version);
                Launchpad lp    = (Launchpad)Decode(reader, version);
                string    name  = reader.ReadString();

                bool enabled = true;
                if (version >= 8)
                {
                    enabled = reader.ReadBoolean();
                }

                return(new Track(chain, lp, name)
                {
                    Enabled = enabled
                });
            }
            else if (t == typeof(Chain))
            {
                List <Device> devices = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Device) Decode(reader, version)).ToList();
                string        name    = reader.ReadString();

                bool enabled = true;
                if (version >= 6)
                {
                    enabled = reader.ReadBoolean();
                }

                return(new Chain(devices, name)
                {
                    Enabled = enabled
                });
            }
            else if (t == typeof(Device))
            {
                bool collapsed = false;
                if (version >= 5)
                {
                    collapsed = reader.ReadBoolean();
                }

                bool enabled = true;
                if (version >= 5)
                {
                    enabled = reader.ReadBoolean();
                }

                Device ret = (Device)Decode(reader, version);
                ret.Collapsed = collapsed;
                ret.Enabled   = enabled;

                return(ret);
            }
            else if (t == typeof(Launchpad))
            {
                string name = reader.ReadString();
                if (name == "")
                {
                    return(MIDI.NoOutput);
                }

                InputType format = InputType.DrumRack;
                if (version >= 2)
                {
                    format = (InputType)reader.ReadInt32();
                }

                RotationType rotation = RotationType.D0;
                if (version >= 9)
                {
                    rotation = (RotationType)reader.ReadInt32();
                }

                foreach (Launchpad lp in MIDI.Devices)
                {
                    if (lp.Name == name)
                    {
                        if (lp.GetType() == typeof(Launchpad))
                        {
                            lp.InputFormat = format;
                            lp.Rotation    = rotation;
                        }
                        return(lp);
                    }
                }

                Launchpad ret;
                if (name.Contains("Virtual Launchpad "))
                {
                    ret = new VirtualLaunchpad(name);
                }
                else if (name.Contains("Ableton Connector "))
                {
                    ret = new AbletonLaunchpad(name);
                }
                else
                {
                    ret = new Launchpad(name, format, rotation);
                }

                MIDI.Devices.Add(ret);

                return(ret);
            }
            else if (t == typeof(Group))
            {
                return(new Group(
                           (from i in Enumerable.Range(0, reader.ReadInt32()) select(Chain) Decode(reader, version)).ToList(),
                           reader.ReadBoolean()? (int?)reader.ReadInt32() : null
                           ));
            }

            else if (t == typeof(Choke))
            {
                return(new Choke(
                           reader.ReadInt32(),
                           (Chain)Decode(reader, version)
                           ));
            }

            else if (t == typeof(Clear))
            {
                return(new Clear(
                           (ClearType)reader.ReadInt32()
                           ));
            }

            else if (t == typeof(ColorFilter))
            {
                return(new ColorFilter(
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble()
                           ));
            }

            else if (t == typeof(Copy))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                return(new Copy(
                           time,
                           gate,
                           (CopyType)reader.ReadInt32(),
                           (GridType)reader.ReadInt32(),
                           reader.ReadBoolean(),
                           (from i in Enumerable.Range(0, reader.ReadInt32()) select(Offset) Decode(reader, version)).ToList()
                           ));
            }
            else if (t == typeof(Delay))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                return(new Delay(time, gate));
            }
            else if (t == typeof(Fade))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                FadePlaybackType playmode = (FadePlaybackType)reader.ReadInt32();

                int           count;
                List <Color>  colors    = (from i in Enumerable.Range(0, count = reader.ReadInt32()) select(Color) Decode(reader, version)).ToList();
                List <double> positions = (from i in Enumerable.Range(0, count) select(version <= 13)? (double)reader.ReadDecimal() : reader.ReadDouble()).ToList();

                return(new Fade(time, gate, playmode, colors, positions));
            }
            else if (t == typeof(Flip))
            {
                return(new Flip(
                           (FlipType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Hold))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                return(new Hold(
                           time,
                           gate,
                           reader.ReadBoolean(),
                           reader.ReadBoolean()
                           ));
            }
            else if (t == typeof(KeyFilter))
            {
                bool[] filter;
                if (version <= 18)
                {
                    List <bool> oldFilter = (from i in Enumerable.Range(0, 100) select reader.ReadBoolean()).ToList();
                    oldFilter.Insert(99, false);
                    filter = oldFilter.ToArray();
                }
                else
                {
                    filter = (from i in Enumerable.Range(0, 101) select reader.ReadBoolean()).ToArray();
                }

                return(new KeyFilter(filter));
            }
            else if (t == typeof(Layer))
            {
                int target = reader.ReadInt32();

                BlendingType blending = BlendingType.Normal;
                if (version >= 5)
                {
                    if (version == 5)
                    {
                        blending = (BlendingType)reader.ReadInt32();
                        if ((int)blending == 2)
                        {
                            blending = BlendingType.Mask;
                        }
                    }
                    else
                    {
                        blending = (BlendingType)reader.ReadInt32();
                    }
                }

                int range = 200;
                if (version >= 21)
                {
                    range = reader.ReadInt32();
                }

                return(new Layer(target, blending, range));
            }
            else if (t == typeof(Move))
            {
                return(new Move(
                           Decode(reader, version),
                           (GridType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Multi))
            {
                return(new Multi(
                           Decode(reader, version),
                           (from i in Enumerable.Range(0, reader.ReadInt32()) select(Chain) Decode(reader, version)).ToList(),
                           reader.ReadBoolean()? (int?)reader.ReadInt32() : null,
                           (MultiType)reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Output))
            {
                return(new Output(
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(PageFilter))
            {
                return(new PageFilter(
                           (from i in Enumerable.Range(0, 100) select reader.ReadBoolean()).ToArray()
                           ));
            }

            else if (t == typeof(Paint))
            {
                return(new Paint(
                           Decode(reader, version)
                           ));
            }

            else if (t == typeof(Pattern))
            {
                int repeats = 1;
                if (version >= 11)
                {
                    repeats = reader.ReadInt32();
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                List <Frame> frames = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Frame) Decode(reader, version)).ToList();
                PlaybackType mode   = (PlaybackType)reader.ReadInt32();

                bool chokeenabled = false;
                int  choke        = 8;

                if (version <= 10)
                {
                    chokeenabled = reader.ReadBoolean();

                    if (version <= 0)
                    {
                        if (chokeenabled)
                        {
                            choke = reader.ReadInt32();
                        }
                    }
                    else
                    {
                        choke = reader.ReadInt32();
                    }
                }

                bool infinite = false;
                if (version >= 4)
                {
                    infinite = reader.ReadBoolean();
                }

                int?rootkey = null;
                if (version >= 12)
                {
                    rootkey = reader.ReadBoolean()? (int?)reader.ReadInt32() : null;
                }

                bool wrap = false;
                if (version >= 13)
                {
                    wrap = reader.ReadBoolean();
                }

                int expanded = reader.ReadInt32();

                Pattern ret = new Pattern(repeats, gate, frames, mode, infinite, rootkey, wrap, expanded);

                if (chokeenabled)
                {
                    return(new Choke(choke, new Chain(new List <Device>()
                    {
                        ret
                    })));
                }

                return(ret);
            }
            else if (t == typeof(Preview))
            {
                return(new Preview());
            }

            else if (t == typeof(Rotate))
            {
                return(new Rotate(
                           (RotateType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Switch))
            {
                int page = reader.ReadInt32();

                if (18 <= version && version <= 21 && reader.ReadBoolean())
                {
                    return(new Group(new List <Chain>()
                    {
                        new Chain(new List <Device>()
                        {
                            new Switch(page), new Clear(ClearType.Multi)
                        }, "Switch Reset")
                    }));
                }

                return(new Switch(page));
            }
            else if (t == typeof(Tone))
            {
                return(new Tone(
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble()
                           ));
            }

            else if (t == typeof(Color))
            {
                return(new Color(
                           reader.ReadByte(),
                           reader.ReadByte(),
                           reader.ReadByte()
                           ));
            }

            else if (t == typeof(Frame))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                Color[] screen;
                if (version <= 19)
                {
                    List <Color> oldScreen = (from i in Enumerable.Range(0, 100) select(Color) Decode(reader, version)).ToList();
                    oldScreen.Insert(99, new Color(0));
                    screen = oldScreen.ToArray();
                }
                else
                {
                    screen = (from i in Enumerable.Range(0, 101) select(Color) Decode(reader, version)).ToArray();
                }

                return(new Frame(time, screen));
            }
            else if (t == typeof(Length))
            {
                return(new Length(
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Offset))
            {
                return(new Offset(
                           reader.ReadInt32(),
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Time))
            {
                return(new Time(
                           reader.ReadBoolean(),
                           Decode(reader, version),
                           reader.ReadInt32()
                           ));
            }

            throw new InvalidDataException();
        }
Пример #30
0
 void Start()
 {
     _sprite       = GetComponent <SpriteRenderer>();
     _audio        = GetComponent <AudioSource>();
     _rotationType = RotationType.ClickTwo;
 }
        /// <summary>
        /// Post the players score to the given social leaderboard.
        /// Pass leaderboard config data to dynamically create if necessary.
        /// You can optionally send a user-defined json string of data
        /// with the posted score. This string could include information
        /// relevant to the posted score.
        /// </summary>
        /// <remarks>
        /// Service Name - SocialLeaderboard
        /// Service Operation - PostScoreDynamic
        /// </remarks>
        /// <param name="in_leaderboardId">
        /// The leaderboard to post to
        /// </param>
        /// <param name="in_score">
        /// The score to post
        /// </param>
        /// <param name="in_data">
        /// Optional user-defined data to post with the score
        /// </param>
        /// <param name="in_leaderboardType">
        /// leaderboard type
        /// </param>
        /// <param name="in_rotationType">
        /// Type of rotation
        /// </param>
        /// <param name="in_rotationReset">
        /// Date to reset the leaderboard
        /// </param>
        /// <param name="in_retainedCount">
        /// Hpw many rotations to keep
        /// </param>
        /// <param name="in_success">
        /// The success callback.
        /// </param>
        /// <param name="in_failure">
        /// The failure callback.
        /// </param>
        /// <param name="in_cbObject">
        /// The user object sent to the callback.
        /// </param>
        /// <returns> The JSON returned in the callback is as follows:
        /// {
        ///   "status":200,
        ///   "data":{
        ///   }
        /// }
        /// </returns>
        public void PostScoreToDynamicLeaderboard(
            string in_leaderboardId,
            long in_score,
            string in_jsonData,
            SocialLeaderboardType in_leaderboardType,
            RotationType in_rotationType,
            DateTime? in_rotationReset,
            int in_retainedCount,
            SuccessCallback in_success = null,
            FailureCallback in_failure = null,
            object in_cbObject = null)
        {
            Dictionary<string, object> data = new Dictionary<string, object>();
            data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId;
            data[OperationParam.SocialLeaderboardServiceScore.Value] = in_score;
            if (Util.IsOptionalParameterValid(in_jsonData))
            {
                Dictionary<string, object> customData = JsonReader.Deserialize<Dictionary<string, object>>(in_jsonData);
                data[OperationParam.SocialLeaderboardServiceData.Value] = customData;
            }
            data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = in_leaderboardType.ToString();
            data[OperationParam.SocialLeaderboardServiceRotationType.Value] = in_rotationType.ToString();

            if (in_rotationReset.HasValue)
                data[OperationParam.SocialLeaderboardServiceRotationReset.Value] = in_rotationReset.Value.ToString("d-MM-yyyy HH:mm");

            data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = in_retainedCount;

            ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject);
            ServerCall sc = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.PostScoreDynamic, data, callback);
            m_brainCloudClientRef.SendRequest(sc);
        }
Пример #32
0
 public override string GetRotateAnim(MotionType motionType, RotationType rotationType)
 {
     return(null);
 }
Пример #33
0
 public void Rotate(RotationType rotation)
 {
     transform.Rotate(Vector3.up, ((int)rotation) * 90);
     ColorsData = ColorsData.Rotate(rotation);
 }
Пример #34
0
 /// <summary>
 /// �f�V���A���C�Y���ꂽ��]����I�u�W�F�N�g��擾����
 /// </summary>
 /// <param name="type">��]����^</param>
 /// <param name="bytes">�V���A���C�Y�ς݉�]����f�[�^</param>
 /// <param name="offset">���[�V�����f�[�^�̊J�n�ʒu</param>
 /// <param name="nextOffset">���̃��[�V�����f�[�^�̊J�n�ʒu</param>
 /// <returns>���s����]����I�u�W�F�N�g</returns>
 public static RotationBase2D GetDeserializedRotation(RotationType type, byte[] bytes, int offset, out int nextOffset)
 {
     // ��]����I�u�W�F�N�g�쐬
     var rotation = CreateInstance(type);
     // ��]����f�[�^�̃f�V���A���C�Y
     nextOffset = rotation.Deserialize(bytes, offset);
     return rotation;
 }
Пример #35
0
 /// <summary>
 /// �f�V���A���C�Y���ꂽ��]����I�u�W�F�N�g��擾����
 /// </summary>
 /// <param name="type">��]����^</param>
 /// <param name="bytes">�V���A���C�Y�ς݉�]����f�[�^</param>
 /// <returns>���s����]����I�u�W�F�N�g</returns>
 public static RotationBase2D GetDeserializedRotation(RotationType type, byte[] bytes)
 {
     // ��]����I�u�W�F�N�g�쐬
     var rotation = CreateInstance(type);
     if ( bytes != null ) {
         // ��]����f�[�^�̃f�V���A���C�Y
         rotation.Deserialize(bytes, 0);
     }
     return rotation;
 }
Пример #36
0
 public LineInfo(int ID)
 {
     this.ID           = ID;
     this.Position     = 0.5d;
     this.RotationType = RotationType.Default;
 }
Пример #37
0
 public Drawable TransformRotateSimple(RotationType rotate_type, 
     bool auto_center,
     int center_x, int center_y,
     bool clip_result)
 {
     return new Drawable(gimp_drawable_transform_rotate_simple
       (ID, rotate_type, auto_center, center_x, center_y,
        clip_result));
 }
Пример #38
0
 static extern Int32 gimp_drawable_transform_rotate_simple(Int32 drawable_ID,
     RotationType rotate_type,
     bool auto_center,
     int center_x,
     int center_y,
     bool clip_result);
Пример #39
0
        // *** METHODS ***

        /// <summary>
        /// Rotates the point around a particular axis
        /// </summary>
        /// <param name="type">Rotation axis</param>
        /// <param name="angleInDeg">Angle to be rotated</param>
        public void Rotate(RotationType type, double angleInDeg)
        {
            this.Vertices.ToList().ForEach(v => v.Rotate(type, angleInDeg));
        }
Пример #40
0
        static extern bool gimp_image_rotate(Int32 image_ID,
					 RotationType rotate_type);
Пример #41
0
    public TileIndex tileIndex = new TileIndex();                               // the tile's location on the board

    public LineTile(LineTileType lineTileType, RotationType rotationType)
    {
        this.lineTileType = lineTileType;
        this.rotationType = rotationType;

        // set up sprite
        switch (lineTileType)
        {
        case LineTileType.Nub:
            sprite = new FSprite("lineTileNub");
            break;

        case LineTileType.Line:
            sprite = new FSprite("lineTileLine");
            break;

        case LineTileType.Corner:
            sprite = new FSprite("lineTileCorner");
            break;

        case LineTileType.Threeway:
            sprite = new FSprite("lineTileThreeway");
            break;

        case LineTileType.Cross:
            sprite = new FSprite("lineTileCross");
            break;

        default:
            throw new FutileException("invalid line tile type");
        }

        AddChild(sprite);

        // set up sprite rotation
        switch (rotationType)
        {
        case RotationType.Rotation0:
            sprite.rotation = 0;
            break;

        case RotationType.Rotation90:
            sprite.rotation = 90;
            break;

        case RotationType.Rotation180:
            sprite.rotation = 180;
            break;

        case RotationType.Rotation270:
            sprite.rotation = 270;
            break;

        default:
            throw new FutileException("invalid rotation type");
        }

        // set up bitmask by doing bitwise OR with each side that is included in the shape

        // so for example, a tile that has all four sides solid (e.g. the cross tile) would be
        // 1 | 2 | 4 | 8 = 15, which is the same as 0001 | 0010 | 0100 | 1000 = 1111 in binary

        if (lineTileType == LineTileType.Nub)
        {
            if (rotationType == RotationType.Rotation0)
            {
                bitmask = kBitmaskTop;
            }
            if (rotationType == RotationType.Rotation90)
            {
                bitmask = kBitmaskRight;
            }
            if (rotationType == RotationType.Rotation180)
            {
                bitmask = kBitmaskBottom;
            }
            if (rotationType == RotationType.Rotation270)
            {
                bitmask = kBitmaskLeft;
            }
        }

        if (lineTileType == LineTileType.Line)
        {
            if (rotationType == RotationType.Rotation0 || rotationType == RotationType.Rotation180)
            {
                bitmask = kBitmaskTop | kBitmaskBottom;
            }
            if (rotationType == RotationType.Rotation90 || rotationType == RotationType.Rotation270)
            {
                bitmask = kBitmaskRight | kBitmaskLeft;
            }
        }

        if (lineTileType == LineTileType.Corner)
        {
            if (rotationType == RotationType.Rotation0)
            {
                bitmask = kBitmaskTop | kBitmaskRight;
            }
            if (rotationType == RotationType.Rotation90)
            {
                bitmask = kBitmaskRight | kBitmaskBottom;
            }
            if (rotationType == RotationType.Rotation180)
            {
                bitmask = kBitmaskBottom | kBitmaskLeft;
            }
            if (rotationType == RotationType.Rotation270)
            {
                bitmask = kBitmaskLeft | kBitmaskTop;
            }
        }

        if (lineTileType == LineTileType.Threeway)
        {
            if (rotationType == RotationType.Rotation0)
            {
                bitmask = kBitmaskTop | kBitmaskRight | kBitmaskBottom;
            }
            if (rotationType == RotationType.Rotation90)
            {
                bitmask = kBitmaskRight | kBitmaskBottom | kBitmaskLeft;
            }
            if (rotationType == RotationType.Rotation180)
            {
                bitmask = kBitmaskBottom | kBitmaskLeft | kBitmaskTop;
            }
            if (rotationType == RotationType.Rotation270)
            {
                bitmask = kBitmaskLeft | kBitmaskTop | kBitmaskRight;
            }
        }

        if (lineTileType == LineTileType.Cross)
        {
            bitmask = kBitmaskTop | kBitmaskRight | kBitmaskBottom | kBitmaskLeft;
        }
    }
Пример #42
0
        private string ROT(string str, RotationType typ)
        {
            StringBuilder sb = new StringBuilder();

            switch (typ)
            {
            case RotationType.None:
                return(str);

            case RotationType.ROT5:
                for (int i = 0; i < str.Length; ++i)
                {
                    if (str[i] >= '0' && str[i] <= '4')
                    {
                        sb.Append((char)((int)str[i] + 5));
                    }
                    else if (str[i] >= '5' && str[i] <= '9')
                    {
                        sb.Append((char)((int)str[i] - 5));
                    }
                    else
                    {
                        sb.Append(str[i]);
                    }
                }
                break;

            case RotationType.ROT13:
                for (int i = 0; i < str.Length; ++i)
                {
                    if ((str[i] >= 'a' && str[i] <= 'm') || (str[i] >= 'A' && str[i] <= 'M'))
                    {
                        sb.Append((char)((int)str[i] + 13));
                    }
                    else if ((str[i] >= 'n' && str[i] <= 'z') || (str[i] >= 'N' && str[i] <= 'Z'))
                    {
                        sb.Append((char)((int)str[i] - 13));
                    }
                    else
                    {
                        sb.Append(str[i]);
                    }
                }
                break;

            case RotationType.ROT18:
                for (int i = 0; i < str.Length; ++i)
                {
                    if (str[i] >= '0' && str[i] <= '4')
                    {
                        sb.Append((char)((int)str[i] + 5));
                    }
                    else if (str[i] >= '5' && str[i] <= '9')
                    {
                        sb.Append((char)((int)str[i] - 5));
                    }
                    else if ((str[i] >= 'a' && str[i] <= 'm') || (str[i] >= 'A' && str[i] <= 'M'))
                    {
                        sb.Append((char)((int)str[i] + 13));
                    }
                    else if ((str[i] >= 'n' && str[i] <= 'z') || (str[i] >= 'N' && str[i] <= 'Z'))
                    {
                        sb.Append((char)((int)str[i] - 13));
                    }
                    else
                    {
                        sb.Append(str[i]);
                    }
                }
                break;

            case RotationType.ROT47:
                for (int i = 0; i < str.Length; ++i)
                {
                    if (str[i] >= '!' && str[i] <= 'O')
                    {
                        sb.Append((char)((int)str[i] + 47));
                    }
                    else if (str[i] >= 'P' && str[i] <= '~')
                    {
                        sb.Append((char)((int)str[i] - 47));
                    }
                    else
                    {
                        sb.Append(str[i]);
                    }
                }
                break;
            }
            return(sb.ToString());
        }
Пример #43
0
 private MeshCombineUtility.HiddenFaces CalculateHiddenFaces(MapDataStore.Tile tile, RotationType rotation)
 {
     MeshCombineUtility.HiddenFaces hiddenFaces = MeshCombineUtility.HiddenFaces.None;
     if (rotation == RotationType.None)
     {
         if (tile.North != null && (tile.North.isWall || tile.North.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.North;
         }
         if (tile.South != null && (tile.South.isWall || tile.South.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.South;
         }
         if (tile.East != null && (tile.East.isWall || tile.East.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.East;
         }
         if (tile.West != null && (tile.West.isWall || tile.West.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.West;
         }
     }
     if (rotation != RotationType.TreeRound && rotation != RotationType.TreeRoundTall)//these two rotations don't give a flat rotation.
     {
         if (tile.Up != null && (tile.Up.isSolidBase || tile.Up.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.Up;
         }
         if (tile.Down != null && (tile.Down.isWall || tile.Down.Hidden))
         {
             hiddenFaces |= MeshCombineUtility.HiddenFaces.Down;
         }
     }
     return(hiddenFaces);
 }
Пример #44
0
 public abstract string GetRotateAnim(MotionType motionType, RotationType rotationType);
Пример #45
0
		// *** METHODS ***

		/// <summary>
		/// Rotates the point around a particular axis
		/// </summary>
		/// <param name="type">Rotation axis</param>
		/// <param name="angleInDeg">Angle to be rotated</param>
    public void Rotate(RotationType type, double angleInDeg)
    {
      this.Vertices.ToList().ForEach(v => v.Rotate(type, angleInDeg));
    }
Пример #46
0
 public Voxel(MeshShapeType meshShape, RotationType rotation, bool upsideDown, ushort blockType)
 {
     ShapeData = CalcShape(meshShape, rotation, upsideDown);
     BlockType = blockType;
 }
Пример #47
0
    public static Quaternion TranslateRotation(RotationType rotationType, MapDataStore.Tile tile)
    {
        switch (rotationType)
        {
        case RotationType.None:
            return(Quaternion.identity);

        case RotationType.AwayFromWall:
        {
            Directions wallSides = tile.WallBuildingSides;
            Vector2    average   = Vector2.zero;
            if ((wallSides & Directions.NorthWest) == Directions.NorthWest)
            {
                average += new Vector2(-1, 1);
            }
            if ((wallSides & Directions.North) == Directions.North)
            {
                average += new Vector2(0, 1);
            }
            if ((wallSides & Directions.NorthEast) == Directions.NorthEast)
            {
                average += new Vector2(1, 1);
            }

            if ((wallSides & Directions.West) == Directions.West)
            {
                average += new Vector2(-1, 0);
            }
            if ((wallSides & Directions.East) == Directions.East)
            {
                average += new Vector2(1, -0);
            }

            if ((wallSides & Directions.SouthWest) == Directions.SouthWest)
            {
                average += new Vector2(-1, -1);
            }
            if ((wallSides & Directions.South) == Directions.South)
            {
                average += new Vector2(0, -1);
            }
            if ((wallSides & Directions.SouthEast) == Directions.SouthEast)
            {
                average += new Vector2(1, -1);
            }

            if (average.magnitude < 0.001)
            {
                return(Quaternion.Euler(0, 0, 0));
            }


            float angle = Mathf.Atan2(average.x, average.y) * 180 / Mathf.PI;

            float angle90 = Mathf.Round(angle / 90) * 90;
            float angle45 = Mathf.Round(angle / 45) * 45;

            if (Mathf.Abs(angle90 - angle) < 30)
            {
                return(Quaternion.Euler(0, angle90, 0));
            }
            else
            {
                return(Quaternion.Euler(0, angle45, 0));
            }
        }

        case RotationType.Door:
        {
            Directions wallSides = tile.WallBuildingSides;

            if ((wallSides & (Directions.North | Directions.South | Directions.East | Directions.West)) == (Directions.North | Directions.South | Directions.East | Directions.West))
            {
                return(Quaternion.identity);
            }
            if ((wallSides & (Directions.North | Directions.South)) == (Directions.North | Directions.South))
            {
                return(Quaternion.Euler(0, 90, 0));
            }
            ;

            return(Quaternion.identity);
        }

        case RotationType.Random:
        {
            if (noise == null)
            {
                noise = new OpenSimplexNoise();
            }
            float rot = (float)noise.eval(tile.position.x, tile.position.y, tile.position.z);
            return(Quaternion.Euler(0, rot * 360, 0));
        }

        case RotationType.Random90:
        {
            if (noise == null)
            {
                noise = new OpenSimplexNoise();
            }
            float rot = (float)noise.eval(tile.position.x, tile.position.y, tile.position.z);
            rot = Mathf.Round(rot * 4) * 90;
            return(Quaternion.Euler(0, rot, 0));
        }

        case RotationType.TreeFlat:
        {
            Vector2 treeDir = new Vector2(-tile.positionOnTree.x, tile.positionOnTree.y);
            if (treeDir.sqrMagnitude < 0.001)
            {
                return(Quaternion.identity);
            }

            float angle = Mathf.Atan2(treeDir.x, treeDir.y) * 180 / Mathf.PI;
            return(Quaternion.Euler(0, angle, 0));
        }

        case RotationType.TreeRound:
        {
            Vector3 treeDir = new Vector3(-tile.positionOnTree.x, tile.positionOnTree.z, tile.positionOnTree.y);
            if (treeDir.sqrMagnitude < 0.001)
            {
                return(Quaternion.identity);
            }
            return(Quaternion.LookRotation(treeDir, Vector3.up));
        }

        case RotationType.TreeRoundTall:
        {
            if (noise == null)
            {
                noise = new OpenSimplexNoise();
            }
            float   mainRot  = (float)noise.eval(tile.position.x, tile.position.y, tile.position.z);
            Vector3 smallRot = new Vector3((float)noise.eval(tile.position.x, tile.position.y, tile.position.z * 17), (float)noise.eval(tile.position.x * 17, tile.position.y, tile.position.z), 0);
            Vector3 treeDir  = new Vector3(-tile.positionOnTree.x, tile.positionOnTree.z / 2.0f, tile.positionOnTree.y);
            if (treeDir.sqrMagnitude < 0.001)
            {
                return(Quaternion.identity);
            }
            return(Quaternion.LookRotation(treeDir, Vector3.up) * Quaternion.Euler(smallRot * 15) * Quaternion.AngleAxis(mainRot * 360.0f, Vector3.back));
        }

        default:
            return(Quaternion.identity);
        }
    }
        /// <summary>
        /// Transforms the specified image by flipping and rotating it. First the image
        /// will be rotated, then the image will be flipped. A new image will be returned. The original image
        /// will not be changed.
        /// </summary>
        /// <param name="source">The image, which should be transformed.</param>
        /// <param name="rotationType">Type of the rotation.</param>
        /// <param name="flippingType">Type of the flipping.</param>
        /// <returns>The new and transformed image.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null
        /// (Nothing in Visual Basic).</exception>
        public static ExtendedImage Transform(ExtendedImage source, RotationType rotationType, FlippingType flippingType)
        {
            Contract.Requires<ArgumentNullException>(source != null, "Source image cannot be null.");
            Contract.Requires<ArgumentException>(source.IsFilled, "Source image has not been loaded.");

            return PerformAction(source, false, (sourceImage, targetImage) => ImageBase.Transform(sourceImage, targetImage, rotationType, flippingType));
        }
Пример #49
0
 protected static RotationType RotateEnum(RotationType type, byte rotation)
 {
     for (int i = 0; i < rotation; i++)
     {
         switch (type)
         {
             case RotationType.RotateNone:
                 type = RotationType.Rotate90;
                 break;
             case RotationType.Rotate90:
                 type = RotationType.Rotate180;
                 break;
             case RotationType.Rotate180:
                 type = RotationType.Rotate270;
                 break;
             case RotationType.Rotate270:
                 type = RotationType.RotateNone;
                 break;
         }
     }
     return type;
 }
 // *** METHODS ***
 /// <summary>
 /// Rotates the point around a particular axis
 /// </summary>
 /// <param name="type">Rotation axis</param>
 /// <param name="angle">Angle to be rotated</param>
 /// <param name="center">Center point of rotation</param>
 public Cube3D Rotate(RotationType type, double angle, Point3D center)
 {
     //Deep Clone
       List<Face3D> faces = new List<Face3D>();
       foreach (Face3D f in Faces)
       {
     List<Point3D> edges = new List<Point3D>();
     foreach (Point3D p in f.Vertices) { edges.Add(new Point3D(p.X, p.Y, p.Z)); }
     Face3D f2 = new Face3D(edges, f.Color, f.Position, f.MasterPosition);
     f2.Vertices.ToList().ForEach(e => { e.X -= center.X; e.Y -= center.Y; e.Z -= center.Z; });
     f2.Rotate(type, angle);
     f2.Vertices.ToList().ForEach(e => { e.X += center.X; e.Y += center.Y; e.Z += center.Z; });
     faces.Add(f2);
       }
       return new Cube3D(faces, this.Position, this.Location,this.Scale);
 }
Пример #51
0
 public void Rotate(RotationType rotate_type)
 {
     if (!gimp_image_rotate(ID, rotate_type))
     {
       throw new GimpSharpException();
     }
 }
Пример #52
0
 static extern Int32 gimp_item_transform_rotate_simple(Int32 item_ID,
                                                       RotationType rotate_type,
                                                       bool auto_center,
                                                       int center_x,
                                                       int center_y);
Пример #53
0
 public CEC2005Function(IContinuousFunction function, double sigma, double lambda, RotationType rotationType, double bias, double horizontalShift, int condition = 1)
 {
     _initialized       = false;
     _rotationDecorator = new RotationDecorator(function);
     _rotationDecorator.RotationType = rotationType;
     Sigma           = sigma;
     Lambda          = lambda;
     Bias            = bias;
     HorizontalShift = horizontalShift;
     _rotationDecorator.Condition = condition;
 }
Пример #54
0
 /// <summary>
 /// Execute a rotation of the whole cube
 /// </summary>
 /// <param name="type">Defines the axis to be rotated on</param>
 /// <param name="direction">Defines the direction of the rotation (true == clockwise)</param>
 public void RotateCube(RotationType type, bool direction)
 {
     switch (type)
       {
     case RotationType.X:
       RotateLayer(new LayerMove(CubeFlag.RightSlice, direction) & new LayerMove(CubeFlag.MiddleSliceSides, direction) & new LayerMove(CubeFlag.LeftSlice, !direction));
       break;
     case RotationType.Y:
       RotateLayer(new LayerMove(CubeFlag.TopLayer, direction) & new LayerMove(CubeFlag.MiddleLayer, direction) & new LayerMove(CubeFlag.BottomLayer, !direction));
       break;
     case RotationType.Z:
       RotateLayer(new LayerMove(CubeFlag.FrontSlice, direction) & new LayerMove(CubeFlag.MiddleSlice, direction) & new LayerMove(CubeFlag.BackSlice, !direction));
       break;
       }
 }
Пример #55
0
 public RotationJob(ref Rotation _rotation, GroupData group, string _name)
 {
     rotation = _rotation;
     type     = RotationType.GroupDone;
     name     = _name;
 }
Пример #56
0
    void OnGUI()
    {
        EditorGUILayout.Space();

        int paletteIndex = palettes.IndexOf(palette);

        paletteIndex = EditorGUILayout.Popup("Palette", paletteIndex, paletteNames);
        palette      = paletteIndex < 0 ? null : palettes[paletteIndex];

        if (palette == null)
        {
            return;
        }

        if (ev.isMouse)
        {
            mousePos = ev.mousePosition;
            Repaint();
        }

        optionsToggle = EditorGUILayout.Foldout(optionsToggle, "Options");
        if (optionsToggle)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical();

            raycastMask = LayerMaskField("Raycast Mask", raycastMask);

            var par = EditorGUILayout.ObjectField("Parent To", parentTo, typeof(Transform), true) as Transform;
            if (par != parentTo)
            {
                if (par == null || (PrefabUtility.GetCorrespondingObjectFromSource(par) == null && PrefabUtility.GetPrefabObject(par) == null))
                {
                    parentTo = par;
                }
            }

            onlyUpwards = EditorGUILayout.Toggle("Only Up Normals", onlyUpwards);

            //Snapping
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Snap");
            snap        = EditorGUILayout.Toggle(snap, GUILayout.Width(15f));
            GUI.enabled = snap;
            snapValue   = EditorGUILayout.FloatField(snapValue);
            snapValue   = Mathf.Max(snapValue, 0f);
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            //Rotation mode
            rotationMode = (RotationType)EditorGUILayout.EnumPopup("Rotation Mode", rotationMode);
            if (rotationMode == RotationType.Random)
            {
                minRotation = EditorGUILayout.Vector3Field("Min Rotation", minRotation);
                maxRotation = EditorGUILayout.Vector3Field("Max Rotation", maxRotation);
            }
            else if (rotationMode == RotationType.Custom)
            {
                customRotation = EditorGUILayout.Vector3Field("Rotation", customRotation);
            }

            //Scale mode
            scaleMode = (ScaleType)EditorGUILayout.EnumPopup("Scale Mode", scaleMode);
            if (scaleMode == ScaleType.Random)
            {
                minScale = EditorGUILayout.Vector3Field("Min Scale", minScale);
                maxScale = EditorGUILayout.Vector3Field("Max Scale", maxScale);
            }
            else if (scaleMode == ScaleType.RandomXYZ)
            {
                minScaleU = EditorGUILayout.FloatField("Min Scale", minScaleU);
                maxScaleU = EditorGUILayout.FloatField("Max Scale", maxScaleU);
            }
            else if (scaleMode == ScaleType.Custom)
            {
                customScale = EditorGUILayout.Vector3Field("Scale", customScale);
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();

        var header = EditorGUILayout.GetControlRect();

        GUI.Label(header, "Prefabs", EditorStyles.boldLabel);
        header.y     += header.height - 1f;
        header.height = 1f;
        EditorGUI.DrawRect(header, EditorStyles.label.normal.textColor);

        GUILayout.Space(2f);

        GUI.enabled = selected != null;
        if (GUILayout.Button("Stop Placement (ESC)", EditorStyles.miniButton))
        {
            Deselect();
        }
        GUI.enabled = true;
        if (ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Escape)
        {
            Deselect();
        }

        var buttonHeight = EditorGUIUtility.singleLineHeight * 2f;
        var heightStyle  = GUILayout.Height(buttonHeight);

        var lastRect    = GUILayoutUtility.GetLastRect();
        var scrollMouse = mousePos;

        scrollMouse.x -= lastRect.xMin - prefabScroll.x;
        scrollMouse.y -= lastRect.yMax - prefabScroll.y;

        prefabScroll = EditorGUILayout.BeginScrollView(prefabScroll);

        foreach (var prefab in palette.prefabs)
        {
            if (prefab == null)
            {
                continue;
            }

            var rect = EditorGUILayout.GetControlRect(heightStyle);

            var bgRect = rect;
            bgRect.x      -= 1f;
            bgRect.y      -= 1f;
            bgRect.width  += 2f;
            bgRect.height += 2f;
            if (prefab == selected)
            {
                EditorGUI.DrawRect(bgRect, new Color32(0x42, 0x80, 0xe4, 0xff));
            }
            else
            {
                EditorGUIUtility.AddCursorRect(bgRect, MouseCursor.Link);

                if (bgRect.Contains(scrollMouse))
                {
                    EditorGUI.DrawRect(bgRect, new Color32(0x42, 0x80, 0xe4, 0x40));
                    if (ev.type == EventType.MouseDown)
                    {
                        EditorApplication.delayCall += () =>
                        {
                            selected = prefab;
                            SceneView.RepaintAll();
                        };
                    }
                }
            }

            var iconRect = new Rect(rect.x, rect.y, rect.height, rect.height);

            var icon = AssetPreview.GetAssetPreview(prefab);
            if (icon != null)
            {
                GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit, true, 1f, Color.white, Vector4.zero, Vector4.one * 4f);
            }
            else
            {
                EditorGUI.DrawRect(iconRect, EditorStyles.label.normal.textColor * 0.25f);
            }

            var labelRect = rect;
            labelRect.x     += iconRect.width + 4f;
            labelRect.width -= iconRect.width + 4f;
            labelRect.height = EditorGUIUtility.singleLineHeight;
            labelRect.y     += (buttonHeight - labelRect.height) * 0.5f;
            var labelStyle = prefab == selected ? EditorStyles.whiteBoldLabel : EditorStyles.label;
            GUI.Label(labelRect, prefab.name, labelStyle);
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndScrollView();

        if (AssetPreview.IsLoadingAssetPreviews())
        {
            Repaint();
        }
    }
Пример #57
0
 public Voxel ChangeShape(MeshShapeType meshShape, RotationType rotation, bool upsideDown)
 {
     return(new Voxel(meshShape, rotation, upsideDown, BlockType));
 }
        /// <summary>
        /// Execute a rotation of the whole cube
        /// </summary>
        /// <param name="type">Defines the axis to be rotated on</param>
        /// <param name="direction">Defines the direction of the rotation (true == clockwise)</param>
        public void RotateCube(RotationType type, bool direction)
        {
            switch (type)
            {
                case RotationType.X:
                    this.RotateLayer(new LayerMove(CubeFlag.RightSlice, direction) & new LayerMove(CubeFlag.MiddleSliceSides, direction) & new LayerMove(CubeFlag.LeftSlice, !direction));
                    break;

                case RotationType.Y:
                    this.RotateLayer(new LayerMove(CubeFlag.TopLayer, direction) & new LayerMove(CubeFlag.MiddleLayer, direction) & new LayerMove(CubeFlag.BottomLayer, !direction));
                    break;

                case RotationType.Z:
                    this.RotateLayer(new LayerMove(CubeFlag.FrontSlice, direction) & new LayerMove(CubeFlag.MiddleSlice, direction) & new LayerMove(CubeFlag.BackSlice, !direction));
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
Пример #59
0
    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");

        if (fileAtt == null)
        {
            //Add error message here
            return(false);
        }


        if (storeContainer.shapeStore != null &&
            (elemtype.Attribute("normal") != null ||
             elemtype.Attribute("occlusion") != null ||
             elemtype.Attribute("alpha") != null
            ))
        {
            _normalTexture = new NormalContent();
            _normalTexture.ExternalStorage = storeContainer.shapeStore;
            if (!_normalTexture.AddTypeElement(elemtype))
            {
                _normalTexture = null;
            }
        }

        if (storeContainer.specialStore != null &&
            (elemtype.Attribute("metallic") != null ||
             elemtype.Attribute("illumination") != null
            ))
        {
            _specialTexture = new SpecialMapContent();
            _specialTexture.ExternalStorage = storeContainer.specialStore;
            if (!_specialTexture.AddTypeElement(elemtype))
            {
                _specialTexture = null;
            }
        }

        if (storeContainer.materialStore != null &&
            (elemtype.Attribute("pattern") != null ||
             elemtype.Attribute("specular") != null
            ))
        {
            _matTexture = new TextureContent();
            _matTexture.ExternalStorage = storeContainer.materialStore;
            if (!_matTexture.AddTypeElement(elemtype))
            {
                _matTexture = null;
            }
        }


        if (fileAtt.Value == "NONE")
        {
            //This means we don't want to actually store a mesh,
            //but still want to use the category.
            MeshData = new Dictionary <MeshLayer, CPUMesh>();
        }
        else
        {
            string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
            filePath = Path.GetFullPath(filePath);

            //	Load the OBJ in
            var lStream  = new FileStream(filePath, FileMode.Open);
            var lOBJData = OBJLoader.LoadOBJ(lStream);
            lStream.Close();
            MeshData = new Dictionary <MeshLayer, CPUMesh>();
            Mesh tempMesh = new Mesh();
            foreach (MeshLayer layer in Enum.GetValues(typeof(MeshLayer)))
            {
                MeshLayer translatedLayer;
                if (layer == MeshLayer.GrowthCutout1 ||
                    layer == MeshLayer.GrowthCutout2 ||
                    layer == MeshLayer.GrowthCutout3)
                {
                    translatedLayer = MeshLayer.GrowthCutout;
                }
                else if (layer == MeshLayer.GrowthMaterial1 ||
                         layer == MeshLayer.GrowthMaterial2 ||
                         layer == MeshLayer.GrowthMaterial3)
                {
                    translatedLayer = MeshLayer.GrowthMaterial;
                }
                else if (layer == MeshLayer.GrowthTransparent1 ||
                         layer == MeshLayer.GrowthTransparent2 ||
                         layer == MeshLayer.GrowthTransparent3)
                {
                    translatedLayer = MeshLayer.GrowthTransparent;
                }
                else
                {
                    translatedLayer = layer;
                }
                tempMesh.LoadOBJ(lOBJData, (layer.ToString()));
                if (tempMesh == null || tempMesh.vertexCount == 0)
                {
                    continue;
                }
                tempMesh.name = filePath + "." + layer.ToString();
                if (translatedLayer == MeshLayer.GrowthCutout ||
                    translatedLayer == MeshLayer.GrowthMaterial ||
                    translatedLayer == MeshLayer.GrowthTransparent)
                {
                    for (int i = (int)translatedLayer; i < (int)translatedLayer + 4; i++)
                    {
                        //This is because the tree growths can be in any order
                        //So we just copy the un-numbered one onto the rest.
                        MeshData[(MeshLayer)i] = new CPUMesh(tempMesh);
                    }
                }
                else
                {
                    MeshData[layer] = new CPUMesh(tempMesh);
                }
                tempMesh.Clear();
            }
            lStream  = null;
            lOBJData = null;
        }

        XAttribute rotAtt = elemtype.Attribute("rotation");

        if (rotAtt == null)
        {
            rotationType = RotationType.None;
        }
        else
        {
            try
            {
                rotationType = (RotationType)Enum.Parse(typeof(RotationType), rotAtt.Value);
            }
            catch
            {
                rotationType = RotationType.None;
                Debug.Log("Unknown rotation value: " + rotAtt.Value);
            }
        }
        return(true);
    }
Пример #60
0
	// Use this for initialization
	void Start () 
	{
		tr = transform;
		rotationType = RotationType.none;
	}