I need your help, because I have some problems with Math.
I'm very bad with concepts of Matrix3f and Quaternion…
So I would like to know how to create a ray between 2 nodes ?
What are math-operations needed to get a correct Ray.direction from one of node ?
I would like to know how to move the first node in the direction of the second node ?
What are math-operations needed to get a correct Quaternion rotation and a Vector3f translation ?
In others words, how to combine translation and orientation of the first node, if the second node is the aim ?
There are a number of classes that do similar things to what you are looking for.
Assuming you want to do this as a slow process over time - take a look at something like SpatialTransformer, or maybe one of the other classes that extend controller.
If you want to immediately move node1 towards node2 - calculate the distance between them (for each coordinate) and add a division of this distance to the one you want to move (oversimplifying - subtract node2.x from node1.x , divide it by a speed value (leave you to experiment here) then add that to node1's x - duplicate for y and z and repeat each frame). For the rotation, take a look at the "lookAt" method in the spatial class.
Thanks for your help!
I tried some methods and your algorithm stay the best way!
With a PolylineCurve, for example, the unit moves on a direct line, and don't fallow the terrain height (y), with just the 2 nodes coordinates. Otherwise it should be necessary to calculate in advance the correct path (on each significative changing height of the map and on each changing aim…) to reference the PolylineCurve points. It work well to create a 'laser' between 2 nodes.
But for moving, I tried your solution, and it work well, but if I divide directly the stored speed of the unit - mult by the delta time, cfr Controller.update(time)- the result speed is function of the distance and more the unit speed is high more the delta is little, cause by the division. But it stop at the correct point and the orientation is good! The next step is moving the unit with a constant speed. So I'm still working on (leave you to experiment). I stay open about advices.
Like you thank it, I use a Unit extends MD5Node (Node), and a UnitController extends MD5Controller, to process over time. I work with MD5 animations, and it is a obligation to synchronise moves between the real position (MD5Node) and the animated position (MD5Animation), cause the unit.getLocalTranslation doesn't change when the unit is animated. That strange because on the screen, the node moves?! The keyframe, I supposed ?
I found with the help of the FlagLesson (cfr: Vehicule.update):
unit.getIndicator().getLocalTranslation().addLocal(unit.getLocalRotation().getRotationColumn(2).multLocal(unit.getSpeed() * time));
where unit.getIndicator() is a child node uses to know the real position of the node.
got any result? I need to move units with a constant speed too and did not got any further since a couple of weeks.