Vector equation for dragging a Quad billboarding the Camera
I am trying to implement method which allows the user to click on a quad with the mouse, and drag it around. While being dragged, the quad should be facing / billboarding the camera.
After several tries at this method which worked out more or less good, I finally found out where my confusion came from. The correct center point position is needed, but obtaining it can only be done through an equation solving with the giving parameters. But this is where my math fails me. Any help finding this equation would be greatly appreciated.
Please see the picture below for illustration. It's a 3D world, but for the sake of simplicity the picture is in 2D.
The user clicks on the quad, which gives the 3D point where the quad was hit and the direction from the camera to it. Dragging the quad around should now orient it facing the camera, constantly billboarding it at the same distance while being dragged and using its center point (A) for pivoting.
This gives three values which can be used:
The direction from the cam to the quad point that was clicked on with the mouse
The distance between the camera and the center point of the quad, when it was clicked on.
The size of the quad (and the distance between its center point and the point where it was clicked)
The problem can probably be solved by finding the position where the quad center point is at the required distance and maintaining its offset to the drag point where the user clicked it. So basically, given the mousepointer direction and the quad size, the position of the quad center point is needed where it intersects the circle around the camera of the given distance.
Any help how to come up with that equation would be greatly appreciated.
Your answer
Follow this Question
Related Questions
Attempting to apply force to object, paralell to mouse drag. 2 Answers
iOS shader: 'Vector' syntax error (on gles) 1 Answer
Displaying a different sprite depending on which angle a character is viewed from 1 Answer
Draw an object at known angle and distance from camera 0 Answers
How do i rotate an object towards mouse? 2 Answers