Tag: 旋转

在Unity中向两个方向旋转门

我在Unity创建了一个开门和关门。 我可以通过调用Interact()打开那扇门。 现在我想创建一个始终远离玩家的门。 就像一个沙龙的门。 如果玩家在房间前面,门会旋转到房间,如果玩家在房间内,则门会旋转出来。 目前我创建了一个bool opensAwayFromPlayer 。 如果这是真的,打开门时应该固定目标旋转。 [SerializeField] private Vector3 targetRotation; // rotation angles [SerializeField] private float duration; // rotation speed [SerializeField] private bool closeAgain; // close the door again? [SerializeField] private float waitInterval; // close the door after x seconds [SerializeField] private Vector3 pivotPosition; // Vector3 of the pivot [SerializeField] private bool […]

统一在最小和最大距离之间旋转

我试图让对象拖动成为可能。 这个对象只能旋转那么多。 (Similair到门口)。 这是编辑的代码,用于旋转有效的对象。 我有2个用于maxrotation和minrotation的载体。 只要用户拖动可交互对象,就会调用此代码。 (比如更新但仅在拖动时) if (GestureManager.Instance.IsNavigating && HandsManager.Instance.FocusedGameObject == gameObject) { //speed and navigiation of rotation float rotationFactor; rotationFactor = ManipulationManager.Instance.ManipulationPosition.y * RotationSensitivity; totransform.Rotate(new Vector3(rotationFactor, 0, 0)); } 如果我能在这里使用if语句会很棒。 我尝试了很多东西,但它仍然没有用。 如上所述,此处的代码粘贴有效。 对象应该是可拖动的,但只能达到某个点。 totransform是将被轮换的变换 任何想法都会很棒,也非常受欢迎。 亲切的问候。

如何在墨迹上进行缩放和旋转?

使用以下XAML: Testing 我试图围绕图像的中心旋转,并使用滚轮鼠标进行缩放。 我已经设置了这个转换组和事件: public MainWindow() { InitializeComponent(); DataContext = new MainWindowViewModel(); transformGroup = new TransformGroup(); scaleTransform = new ScaleTransform(); rotateTransform = new RotateTransform(); translateTransform = new TranslateTransform(); transformGroup.Children.Add(rotateTransform); transformGroup.Children.Add(scaleTransform); transformGroup.Children.Add(translateTransform); imgViewbox.RenderTransform = transformGroup; imgViewbox.MouseWheel += ImageViewboxMouseWheel; } 旋转很简单: void Rotate(object sender, RoutedEventArgs e) { //imgViewbox.RenderTransformOrigin = new Point(0.5,0.5); rotateTransform.Angle += 90; } 但是缩放正在做各种奇怪的东西在屏幕上跳跃。 缩放代码在这里: […]

Helix工具包旋转3D模型

我是WPF的新手,我正在尝试创建一个显示3D模型的程序(保存在我的计算机上)并根据按钮点击进行旋转。 我想有三个按钮来围绕x,y和z轴旋转对象。 我有代码显示模型,但我不确定如何使用按钮点击旋转它。 这是我到目前为止所拥有的; C# public MainWindow() { InitializeComponent(); ModelVisual3D device3D = new ModelVisual3D(); device3D.Content = Display3d(MODEL_PATH); // Add to view port viewPort3d.Children.Add(device3D); } private Model3D Display3d(string model) { Model3D device = null; try { //Adding a gesture here viewPort3d.RotateGesture = new MouseGesture(MouseAction.LeftClick); //Import 3D model file ModelImporter import = new ModelImporter(); //Load the 3D […]

维护区域时旋转位图(矩形)

如何在保持原始位图区域的同时将位图旋转给定的度数。 即,我旋转宽度的位图:100,高度:200,我的最终结果将是一个更大的图像,但旋转部分仍将有100 * 200的面积

旋转图像X度C#wpf

这一直困扰着我多年,我只想要一个简单的方法将图像旋转X度。 (这是炮塔防御游戏,其中炮塔需要向某个方向射击) 我想要这样的东西: public Image getRotatedImage(Image img, float angle) { //Code here to rotate the image return img } 所有这些都在c#wpf ofcourse和动态..希望你们可以帮助我在这里:D

标准化0到360之间的方向

我正在研究一个简单的旋转程序,它将物体旋转归一化到0到360度之间。 我的C#代码似乎正在运行,但我并不完全满意。 任何人都可以改进下面的代码,使其更健壮吗? public void Rotate(int degrees) { this.orientation += degrees; if (this.orientation < 0) { while (this.orientation = 360) { while (this.orientation >= 360) { this.orientation -= 360; } } }

为什么相机在Unity3D中围绕z轴旋转?

我在Unity3D中有一个主摄像头 ,我想根据鼠标输入进行旋转,因此它可以作为第一人称video游戏,根据您想要查看的位置移动鼠标。 摄像机的起始值(Unity中的“检查器”选项卡中的“变换”选项卡)为: 位置 :X = -1,Y = 1,Z = -11。 旋转 :X = 0,Y = 0,Z = 0。 比例 :X = 1,Y = 1,Z = 1。 我为主摄像头添加了一个脚本组件。 它是以下类: using UnityEngine; using System.Collections; public class CameraMove : MonoBehaviour { float deltaRotation = 50f; // Use this for initialization void Start () { } // Update […]

在C#中将旋转的文本绘制到图像

我正在使用Graphics类的drawtring方法在Image上绘制一个String。 g.DrawString(mytext, font, brush, 0, 0); 我正在尝试使用图形对象的旋转变换function按角度旋转文本,以便可以以任何角度绘制文本。如何使用旋转变换来执行此操作。 我使用的旋转变换代码是 Bitmap m = new Bitmap(pictureBox1.Image); Graphics x=Graphics.FromImage(m); x.RotateTransform(30); SolidBrush brush = new SolidBrush(Color.Red); x.DrawString(“hi”, font,brush,image.Width/2,image.Height/2); //image=picturebox1.image pictureBox1.Image = m; 文本是以旋转的角度绘制的,但它不是在我想要的中心绘制.Plz帮助我。

C#中的旋转文本对齐

我需要能够旋转标签中的文本并将其与左,右或中心对齐。 到目前为止,我能够在派生标签的onPaint方法中使用此代码进行旋转: float width = graphics.MeasureString(Text, this.Font).Width; float height = graphics.MeasureString(Text, this.Font).Height; double angle = (_rotationAngle / 180) * Math.PI; graphics.TranslateTransform( (ClientRectangle.Width + (float)(height * Math.Sin(angle)) – (float)(width * Math.Cos(angle))) / 2, (ClientRectangle.Height – (float)(height * Math.Cos(angle)) – (float)(width * Math.Sin(angle))) / 2); graphics.RotateTransform(270f); graphics.DrawString(Text, this.Font, textBrush, new PointF(0,0), stringFormat); graphics.ResetTransform(); 它工作正常。 我可以看到文字旋转了270度。 但是当我尝试在stringFormat中设置对齐时,它变得疯狂,我无法弄清楚发生了什么。 如何将文本旋转270度并将其对齐?