[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Thread Index]
[Monthly Archives] [List Home]

RE: [Virtools] Moving Objects using the mouse.



Title: Moving Objects using the mouse.

Christian provided the right equations.

 

Here is a ‘dirty way’ to bypass all the math:

-          when you pick an object with the mouse, move a hidden plane object to the picking position and orient it so that it’s perpendicular to the camera.

-          Then, while the mouse button is not released, raycast (Ray Intersection BB) on the plane from the camera position and through the current picking position. That gives you the position picked on the plane. Move your object to that position.

 

The nice thing about this solution is that it works for any plane (not only the screen plane). You can move objects constrained on a wall or a floor, and so on…

 

Francois

-----Original Message-----
From:
owner-virtools-user-group@lists.theswapmeet.com [mailto:owner-virtools-user-group@lists.theswapmeet.com] On Behalf Of ChrGarnier
Sent: mardi 9 avril 2002
13:06
To: Kam Memarzia; '
Virtools Mailing List'
Subject: RE: [Virtools] Moving Objects using the mouse.

 

Hello,

 

Please find the equations down there:

 

XYZ are 3D coords of a point IN CAMERA REF
xy are screen coords as per the near clipping plane.
WH are width and height of the screen
then we have:
X=Z*tan(fov/2)*(2*x/W-1);//1
Y=Z*tan(fov/2)*(H-2*y)/W;//2

 

You need the object Z  (picked position) and transform it into the camera ref.

Then you position the object on a plane perpendicular to the camera dir at Z,

using X,Y.

 

Best regards,

 

Christian Garnier.


 -----Message d'origine-----
De : owner-virtools-user-group@lists.theswapmeet.com [mailto:owner-virtools-user-group@lists.theswapmeet.com]De la part de Kam Memarzia
Envoyé : mardi 9 avril 2002 10:18
À : 'Virtools Mailing List'
Objet : [Virtools] Moving Objects using the mouse.

Greetings,

I'd like to replicate the Move function in Dev within a cmo using the mouse.

So that once the object is clicked on, it can be dragged around in a plane (say X,Z) - whilst staying underneath the mouse.

Its translating the screen co-ordinates into world space I think.

Any clues, thoughts, equations or solutions would be most appriciated.

Thanks

Kam Memarzia

 


References: