当前位置: 首页>>代码示例>>C#>>正文


C# Vector2.Transform方法代码示例

本文整理汇总了C#中System.Vector2.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Transform方法的具体用法?C# Vector2.Transform怎么用?C# Vector2.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Vector2的用法示例。


在下文中一共展示了Vector2.Transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToWorld

        public Vector2 ToWorld(Vector2 screenPoint, float parallax = 1)
        {
            /*
            Vector2 shift = new Vector2(_origin.X * scrWidth, _origin.Y * scrHeight);

            screenPoint.X -= shift.X;
            screenPoint.Y -= shift.Y;

            screenPoint = Vector2.Transform(screenPoint, Quaternion.FromAxisAngle(Vector3.UnitZ, -_rotation));//Vector3.Transform(new Vector3(screenPoint), Matrix4.CreateRotationZ(-_rotation)).Xy;
            screenPoint /= _scale;

            //screenPoint.X += shift.X;
            //screenPoint.Y += shift.Y;

            screenPoint.X += _position.X * parallax;
            screenPoint.Y += _position.Y * parallax;
             */
            return screenPoint.Transform(Matrix4.Invert(GetViewMatrix(parallax)));
            //return screenPoint;
        }
开发者ID:mokujin,项目名称:DN,代码行数:20,代码来源:Camera.cs

示例2: DrawInternal

        private void DrawInternal(
			Texture2D texture,
			Vector2 destination,
			int width,
			int height,
			Rectangle? source,
			Color4? tint,
			Vector2? origin,
			Vector2? scale,
			float rotation,
			float layerDepth)
        {
            this.EnsureDrawInProgress();

            if (texture == null)
                throw new ArgumentNullException("texture");

            if (texture != this.texture)
                this.Flush();

            this.texture = texture;

            if (source == null)
                source = new Rectangle(0, 0, texture.Width, texture.Height);

            if (tint == null)
                tint = Color4.White;

            if (origin == null)
                origin = Vector2.Zero;

            if (scale == null)
                scale = Vector2.One;

            Vector2 topLeft = new Vector2(-origin.Value.X, -origin.Value.Y);
            Vector2 topRight = new Vector2(width - origin.Value.X, -origin.Value.Y);
            Vector2 bottomRight = new Vector2(width - origin.Value.X, height - origin.Value.Y);
            Vector2 bottomLeft = new Vector2(-origin.Value.X, height - origin.Value.Y);

            Matrix4 rotationMatrix;
            Matrix4.CreateRotationZ(rotation, out rotationMatrix);

            Matrix4 scaleMatrix;
            Matrix4.CreateScale(scale.Value.X, scale.Value.Y, 1.0f, out scaleMatrix);

            Matrix4 translationMatrix;
            Matrix4.CreateTranslation(destination.X, destination.Y, out translationMatrix);

            Matrix4 identity = Matrix4.Identity;

            Matrix4 transform1;
            Matrix4.Multiply(ref identity, ref scaleMatrix, out transform1);

            Matrix4 transform2;
            Matrix4.Multiply(ref transform1, ref rotationMatrix, out transform2);

            Matrix4 transform3;
            Matrix4.Multiply(ref transform2, ref translationMatrix, out transform3);

            topLeft = topLeft.Transform(ref transform3);
            topRight = topRight.Transform(ref transform3);
            bottomRight = bottomRight.Transform(ref transform3);
            bottomLeft = bottomLeft.Transform(ref transform3);

            this.AddQuad(
                ref topLeft,
                ref topRight,
                ref bottomRight,
                ref bottomLeft,
                source.Value,
                tint.Value,
                layerDepth);
        }
开发者ID:smack0007,项目名称:Samurai,代码行数:73,代码来源:SpriteRenderer.cs

示例3: ToScreen

        public Vector2 ToScreen(Vector2 worldPoint, float parallax = 1)
        {
            /*
            Vector2 shift = new Vector2(_origin.X * scrWidth, _origin.Y * scrHeight);

            worldPoint.X -= _position.X * parallax;
            worldPoint.Y -= _position.Y * parallax;
            //worldPoint.X -= shift.X;
            //worldPoint.Y -= shift.Y;

            worldPoint = Vector2.Transform(worldPoint, Quaternion.FromAxisAngle(Vector3.UnitZ, -_rotation));
            worldPoint *= _scale;

            worldPoint.X += shift.X;
            worldPoint.Y += shift.Y;
            */
            return worldPoint.Transform(GetViewMatrix(parallax));
            //return worldPoint;
        }
开发者ID:mokujin,项目名称:DN,代码行数:19,代码来源:Camera.cs


注:本文中的System.Vector2.Transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。