If you are talking about the box that you are dragging with the mouse there are a couple of ways you can assign it's velocity. And you can also just use it's offset directly as you say.
If you use the offset between the last and new positions then you are skipping the velocity step for that object (and that's ok), by plugging the displacement vector of the mouse-driven object directly into the problem, you don't have to worry about the velocity, it's inherent to the movement. And you can just compute the displacement vector of the other object, from it's velocity (0 if it's stationary). It's then a geometric problem alone. But the velocity is actually v = s / t (where v = velocity, s = displacement, t = time). In this case you may still need to compute the velocity of the mouse-driven object if you want any kind of inertial response. But you don't have to if you're not worrying about inertia.
Another way that I've seen mouse movement done, such as in Farseer Physics is to use springs. So a spring between the mouse and the object is set up and it can be set to be quite rigid, then the object will fly to the mouse position as though it were tied to it with a tight rubber band. In this system, the mouse-driven object's velocity is used normally by the physics engine. And it looks just like any other object in the system. But it's movement will not fit to the mouse-movement curve quite as tightly. But it is an effective technique.
Gavin WilliamsMember Since 04 Dec 2010
Offline Last Active May 19 2016 02:54 AM
- Group Members
- Active Posts 323
- Profile Views 7,202
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
Studying Software Engineering at ANU. I started programming with XNA for a couple years on and off until 2012 when I changed to SlimDX and over the course of 2012 started building a game, and spending a lot more time programming. Come 2013, I have ported it to SharpDX/WinRT, as an exercise and also to use XAML. Progress has really slowed down for the porting process with all sorts of issues after ripping out a lot of code and needing to rewrite all the resource management stuff. But I think I'm nearly there. Soon I will be able to start work on the game editor in earnest using a XAML interface.
Oh and if you're a C#/DirectX programmer, please vote on MS UserVoice to have hlsl compilation added to C# projects.
- Yahoo firstname.lastname@example.org