Is there anybody here who wrote the code to move objects using Gizmo? I mean to translate or rotate, cube for example by mouse? For example like in 3ds max or blender editors. I can't understand how to use 3d mouse position for this.
Asked
Active
Viewed 502 times
1 Answers
1
I did it. My algoritm :
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
}

Akmal
- 23
- 3
-
So you can write code for MoveX and MoveZ. – Akmal Jul 16 '15 at 18:36