Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Problem moving object with mouse

Author
Message
Jediam
12
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 26th Apr 2012 03:59
Hello,

I'm having difficulty implementing some existing code from the help menu commands. I'm trying to use the code from the Pick Screen() command to move an object with a mouse. Here's a code snippet (which is essentially the same as the code in the help section)

I have the MouseControls() function within a Do..Loop. The only thing that seems to work is the updating of x#,y#,z#. The variables dx#,dy#,dz# don't update. I'm not sure why this is because when I run the code that comes from the help menu (which includes different objects), the cube that comes with it moves fine. If you need any additional information, just ask. Any help is appreciated. Thank you.
Jediam
12
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 26th Apr 2012 18:18
Update,

dx#,dy#,dz# aren't updating because x2#,y2#,z2# have the same initial value of x#,y#,z#(Which is 0). Pick screen MousePosX,MousePosY,d# updates both x#,y#,z# and x2#,y2#,z2# with the same value, but because they are the same, they are cancelling each other out and the object isn't moving, i.e. returning to 0. I'm going to try setting the second set of Get Pick Vectors() to x2# = Get Pick Vector X() + x#\x#. So if say x# = 1 the result would be 0 + 1\1 = 1. I'll let you know the result. Please let me know if you have any better ideas. Thank You
Jediam
12
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 26th Apr 2012 18:49
Hello Again,

After having tried the values in the above post, I wound up with the expected result. The object was shifting slightly but would still return to the same initial position (0,0,0) when I would let go of the mouse. So I changed the code to the following:

Now the object moves more acceptably, however it tends to return to 0,0,0 when I let go of the mouse button then reclick the object again. In the last few lines of code I'm trying to "reset" the objects position to a new value so it doesn't keep going to 0,0,0. Not successful yet. Please post any solutions you may have. Thank You.
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 2nd May 2012 00:17
I had a look at the example code in the DBP help files and it's a bit rubbish.

I don't know if this is what you're looking for:



but I hope it gives you some ideas.
Jediam
12
Years of Service
User Offline
Joined: 14th Apr 2012
Location:
Posted: 2nd May 2012 13:58
Hello 29 games,

Thanks for taking the time writing your code sample. It does the trick and is worth examining closer for future modification. I had more in mind the object moving along with the cursor while the mouse button is held down. There is an example in the sample section of the help menu which achieves this. The only problem with it however, is that the cursor veers off center from where the object is picked from when the mouse is moved. I don't know if the sensitivity of the mousemovex/y() commands can be modified so this doesn't happen, but that is why I am seeking an alternative. I like how in your code sample, the cube object jumps instantaneously to the desired positon. I can picture it being used for snapping objects together along their edges/vertices. Thanks again for your interest.

Login to post a reply

Server time is: 2024-11-23 20:48:44
Your offset time is: 2024-11-23 20:48:44