Jump to content

Axis dragging


ovmihai
 Share

Recommended Posts

Hello, i have a problem. This is my first intersection with babylon and i tried to create with code from playground and another topic i found here something like a independent axis dragging system. It works fine on X and Z, but i have no idea why on Y it's going crazy. I've attached my index.html. 

index.html

Link to comment
Share on other sites

Hi ovmihai and welcome to the forum!

 

Could you try to set that up in a playground? It's easier to try thing out and people can show you right way what to do to fix your problem. :)

 

Edit: nevermind, I did it: http://www.babylonjs-playground.com/#11AOBV :P

 

But... it seems to work... I can move the things along their Y-axis if I move carefully. Just When you move the mosue too far to the left or the right it somehow drops the current mesh under the ground.

Link to comment
Share on other sites

Hi ovmihai and welcome to the forum!

 

Could you try to set that up in a playground? It's easier to try thing out and people can show you right way what to do to fix your problem. :)

 

Edit: nevermind, I did it: http://www.babylonjs-playground.com/#11AOBV :P

 

But... it seems to work... I can move the things along their Y-axis if I move carefully. Just When you move the mosue too far to the left or the right it somehow drops the current mesh under the ground.

Exactly, that's the problem. Any idea how to solve this? Should i approach this problem in another way? 

Link to comment
Share on other sites

Sorry, I don't have an idea yet why this acts so weirdly on the Y axis...maybe somebody else know. Maybe you can do some debugging to find the difference between dragging along the Y axis and the other..something must be different, I guess. I assume it's just that you loose the focus on the "Y" because the mouse moves faster than the "Y" does. And if so you cant calculate the correct point in 3D space to do your calculations. Sorry, I know that doesn't help much, but I don't have time do look into it more at the moment :(

Link to comment
Share on other sites

Thank you for your time, iiceman and Deltakosh. Any suggestions how to achieve this? Just create another plane that is perpendicular with the one that i already have? But what if i am not looking at that plan when dragging on the Y axis, then should be 4 hidden "walls" ? Thank you. 

 

Edit: i've added some "walls" as DeltaKosh suggested. The Y axis seems to work a little bit better, but if you try to use the X or Z while the object is at some height, there will be some glitches, because of the height the ground point will be a little bit far(I don't know if i explained well this problem). Link: http://www.babylonjs-playground.com/#11AOBV#1

Link to comment
Share on other sites

Maybe you can rely on screen coordinates. since you only drag one axis X and Y value should be good enough and you wouldn't need extra walls since your wall is the screen :P

Sounds like a plan, i have to find out how to do this. Thank you.

Link to comment
Share on other sites

Cool, glad I could help. Don't forget to come back and show us what you created! :D

 

By the way: you can mark the thread as answered, too, if you like.

I will post a final result as soon as possible and yes i would mark the thread as answered. One more curiosity: if you rotate the camera, so let's say you are looking at the mesh from X axis(the red one)...the feedback it's a little weird because the axis does not rotate with the camera so you have the feeling to drag the X axis up or down but that's Y axis of the screen. Hope you understood what i mean :D 

Link to comment
Share on other sites

Not sure what you mean. I realized that if you look from another side, the directions are mirrored. You drag right but the mesh moves left. But that's only from the X and Z axis... I don't really know what could go wrong with the Y axis.

 

Maybe you could stick with the 3 dimensional coordinates based on the plane and use screen coordinates only for the Y axis?

Link to comment
Share on other sites

Not sure what you mean. I realized that if you look from another side, the directions are mirrored. You drag right but the mesh moves left. But that's only from the X and Z axis... I don't really know what could go wrong with the Y axis.

 

Maybe you could stick with the 3 dimensional coordinates based on the plane and use screen coordinates only for the Y axis?

Yes, that might be a solution.....but. There is always a but :D. If you go here: http://www.babylonjs-playground.com/#11AOBV#5 and pull the Y axis so the object is in the "air" and the zoom out a little bit...try to drag the X or Z axis. You will see that the "ground point" it's not correctly calculated because of the object's height. I think that some extra calculations might be needed to get the right ground point, like subtrating the distance according to the alpha angle of the camera when ray casting for picking the X or Z axis ? Z

 

I will attach an image made with my paint skills, maybe help you understand: http://postimg.org/image/zemm3uk3h/

Link to comment
Share on other sites

I think I know what you mean... what about not using your ground but an extra plane that only appears while dragging X or Z axis and has the same position as your object. You just add the plane when mouse down and dispose it on mouse up and calculate your point on this plane (the plane can be invisible).

Link to comment
Share on other sites

Hi Ovmihai,

 

I've got a similar problem as you but with stacked cubes here.

The issue you will run into shortly is if your object is looked on directly by the camera.  Your selection plane will be almost a sliver if not a line, and you won't be able to select to move the object.  This approach of using ground works if you are offset at looking at the ground plane.  So I am stuck trying to figure out how to unproject the screen coordinates via:

http://forum.unity3d.com/threads/unity-4-3-get-2d-mouse-coordinates-relative-to-the-scene.214091/

But I can't figure it out.

 

W

Link to comment
Share on other sites

Hello diamondage,

 

If i understood well, you are saying that there are cases when grabbing an axis the helper plane will be a line or even invisible so impossible to hit. Maybe a solution might be to always change the rotation of the helper plane to be perpendicular with the camera? so you will always cast a ray that will hit the plane under a 90 deg angle ? I am also a beginner so this is what i thought might be a possible approach. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...