Author Topic: Dragging objects using mouse  (Read 469 times)

Arun V   «   on: May 30, 2011, 04:11:46 AM »
Hi,
   I want to drag the flare3d objects in the scene using the mouse. That is the object need to follow the mouse while dragging until the mouse  button released.An example showing what I need is here
http://theflashstudioblog.blogspot.com/2010/10/drag-movie-clips-with-mouse.html
Thanks in advance
Arun V

Bruce Hammond   «   Reply #1 on: May 30, 2011, 08:48:30 AM »
Do you plan to have your camera fixed in one place, or do you want to be able to rotate the scene?

Arun V   «   Reply #2 on: May 30, 2011, 09:33:22 AM »
Hi Bruce,
    
           Ya camera is fixed at one place..Not actually rotating the scene.Did you check the example that I have shown in the previous post.In that example the image flash studio can be dragged to the desired location we want.The same way I need to drag the flare3D object to the desired position using mouse.
           

Arun V   «   Reply #3 on: May 31, 2011, 04:25:18 AM »
Still issue not Solved..:(

Arun V   «   Reply #4 on: June 02, 2011, 02:06:54 AM »
Hi Bruce,
             Don't u understand my issue...?please help me to solve this..:(

Bruce Hammond   «   Reply #5 on: June 02, 2011, 03:11:58 PM »
I'll get to it as soon as I can.  I've got a full-time jod to deal with.

Bruce Hammond   «   Reply #6 on: June 02, 2011, 04:44:47 PM »
OK, here's a demonstration... http://www.e-nimation.com/Flare/3dDrag/mouseDragging.html.
I personally don't think dragging works all that well in 3D; you can only move your object along the x- and y-axes.  I'd recommend using key commands instead.

You can download the source files here:
http://www.e-nimation.com/Flare/3dDrag/MouseDragging.zip

Bruce Hammond   «   Reply #7 on: June 02, 2011, 04:56:17 PM »
In the .as file I just posted for download, lines 26 and 27 read as follows:

obj.addEventListener(MouseEvent3D.MOUSE_DOWN, mouseDownEvent);
obj.addEventListener(MouseEvent3D.MOUSE_UP, mouseUpEvent);

I suggest adding one more event listener:

obj.addEventListener(MouseEvent3D.MOUSE_OUT, mouseDownEvent);

It calls the same function as the Mouse_Up listener.  In the current files the mouse can actually slip off of the obj, but the obj will still be dragging.  This addition will prevent that.

Bruce Hammond   «   Reply #8 on: June 02, 2011, 04:58:29 PM »
Damn.  The new event listener should read as follows:

obj.addEventListener(MouseEvent3D.MOUSE_OUT, mouseUpEvent);

You want it to call the MouseUpEvent function, not the MouseDownEvent function.

Arun V   «   Reply #9 on: June 03, 2011, 03:39:37 AM »
Hi Bruce,
             Thank you so much for giving me a solution even at your busy time..You helping me a lot.
once again thank you so much

Arun V   «   Reply #10 on: August 03, 2011, 03:45:10 AM »
Hi Bruce,
      
          This post is to clarify some doubts in dragging flare3D objects on the scene. I have attached a sample project created for this

http://dl.dropbox.com/u/36035559/Flare3DDragObject.rar

In the app, we can rotate the object using the mouse and can move by pressing and holding Spacebar and using mouse (both together) 
Logic to rotate:
selectedObject.rotateY( -Input3D.mouseXSpeed, true ); 
selectedObject.rotateAxis( -Input3D.mouseYSpeed, scene.camera.getRight(false) );

Logic to move:
selectedObject.setPosition(collisionInfo.point.x,collisionInfo.point.y,collisionInfo.point.z);

But the problem here is the virtual plane as you mentioned to move 3D objects in a 2D manner is not the plane of the screen(monitor), it is the plane of the object when it is loaded. So, because of this, the object gets zoomed in and out when the object is rotated first and then moved.

Can you please tell me how can I change the virtual plane and set it as the plane of the screen/monitor so that users can move the objects in 2D. Later we will incorporate rotating the camera also (to have top, rear or side views of the scene) and users can move it in a different plane.

Bruce Hammond   «   Reply #11 on: August 03, 2011, 10:06:03 AM »
Hi, Arun.  Check out the Pivot3D getScreenCoords() method.  I can't point you to an example offhand, but it translates 3D space coordinates to the 2D coordinates of the screen.

Arun V   «   Reply #12 on: August 04, 2011, 02:34:35 AM »
Hi Bruce,
             I am using Flare3D version 2.0.37.In that version Pivot3D getScreenCoords method is not presentmethod.

Bruce Hammond   «   Reply #13 on: August 04, 2011, 12:45:55 PM »
Aha.  Then I can't help you.  As you know, Flare v2 is still in the development stage, and so is FlashPlayer 11.  Even if you got your project successfully built in Flare v2, there'd be no way to distribute it, because FlashPlayer11 is only available as a beta.

If you need to get your project distributed as soon as possible, it'd have to be built in Flare V1, compatable with FlashPlayer10.

Ariel Nehmad   «   Reply #14 on: August 04, 2011, 01:16:08 PM »
seems that a lot op people want the getScreenCoords, we'll add it very soon. but in the meantime, check this