C# Gizmo OpenTK(或OpenGL)
这里有没有人编写了使用Gizmo移动对象的代码? 我的意思是平移或旋转,例如用鼠标移动立方体? 例如,在3ds max或blender编辑器中。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
我不明白如何使用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编写代码。