Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Gizmo OpenTK(或OpenGL)_C#_C++_Opengl_Opentk - Fatal编程技术网

C# Gizmo OpenTK(或OpenGL)

C# Gizmo OpenTK(或OpenGL),c#,c++,opengl,opentk,C#,C++,Opengl,Opentk,这里有没有人编写了使用Gizmo移动对象的代码? 我的意思是平移或旋转,例如用鼠标移动立方体? 例如,在3ds max或blender编辑器中。 我不明白如何使用3d鼠标定位来实现这一点。我做到了。我的算法: Vector2 mouseDelta;//set this for your own Vector3 objectPosition;//and this Vector3 objectUpDir;//and this //Here Vector3 MoveY(){ Vector2 cente

这里有没有人编写了使用Gizmo移动对象的代码? 我的意思是平移或旋转,例如用鼠标移动立方体? 例如,在3ds max或blender编辑器中。
我不明白如何使用3d鼠标定位来实现这一点。

我做到了。我的算法:

Vector2 mouseDelta;//set this for your own
Vector3 objectPosition;//and this
Vector3 objectUpDir;//and this
//Here
Vector3 MoveY(){
Vector2 center = worldToScreen(objectPosition);//get center to screen
Vector2 up = worldToScreen(objectPosition+objectUpDir);//get up to screen
float ang = Vector2.CalculateAngle(mouseDelta,up-center);//get angle from up && mouse delta
ang = MathHelper.RadiansToDegrees(ang);//get degreees
ang = ang/90-1;//here :if perpendicular, then ang = 0
return objPosition + objUpDir * (ang/5);//5 - your speed
}

所以您可以为MoveX和MoveZ编写代码。