Hi,
i'm newbie in 3D graphics...i'm programming application for showing medical data in WebGL. Everything works fine, but i would like to implement moving object with mouse (concrete moving with concrete object in x,y,z axis).
My idea is:
I have succesfully calculated the normal of cut (with i want moving). Then i calculate vector of clicked position and my current(mouse move) position (this is vector of new direction). Then i'm trying to calculate angle between normal and vector direction and get the real distance to move.

But it's not working. It seems to be good, but it reacts after about 1cm of dragging..(then it reacts good). But i need immediately reaction.

I might calculate direction vector wrong, because i'm not sure, how can i get point in 3D space. Point on object(where i catch object) is obvious. I'm using framework O3D, but i haven't found any amthod to moving object. I would like to write it in webgl. In O3D is function to pick object and get the position of click in object.

Is my method ok?Help please.

Thank you.
Sincerely,
Tomáš Sychra

03-14-2011, 11:11 PM

oak3d

Re: Moving object with mouse

How about don't move, just position the object in your desired new position. The new position can be calculated by get the intersecting point of the moving line and mouse pick ray.

Hi,
i haven't solved my problem yet.
I have made some progress, but it's still not OK. When i click, i get intersection point of mouse and object in 3D. Then i calculate normal of cut, which i collapse to screen. So i get two vectors
Normal of cut and mouse vector on screen. Then i calculate scalar product (dot) of these vectors and it should be a direction, where should i move cut. Cut is moving to right direction, but it all depend on zoom of scene. If zoom is 1 everthing is ok...but, if it's another, the cuts are moving to quick or too slow...(mouse is quickier or slower)..I think, it can be resolved by converting ratio between screen distance and scene distance...but i dont't know how...
I'm attaching screenshot of my app in hope to help you with understanding to my problem.
Thanks a lot.http://www.image-share.com/upload/580/111.png