Movement of node slow down by each frame

Hello. I`m have some trouble with model animation by simpleUpdate(). Here my code:

       // firstly we rotating by some angel
       // we store the rotating and movement vector in the user data
       val rotQuat: Quaternion = fish.getUserData(ROTATE_QUAT) 
       // in some situations we dont want to rotate
        if (!rotQuat.equals(Quaternion.ZERO)) { // may be it will be faster
            val rotFps = Quaternion()
            rotFps.slerp(Quaternion.IDENTITY, rotQuat.clone(), tpf)
            // fish is our node, that we rotating

        // then we move node base on its rotation

        var swimVec: Vector3f = fish.getUserData(SWIM_VEC)
        swimVec = fish.localRotation.mult(swimVec)

       //in this example swimVec = Vector3f(.05f, 0f, 0f)
       // and rotVec = Quaternion(floatArrayOf(0f, 100f * FastMath.DEG_TO_RAD, 0f))
       // in this place they always are constant

Im using kotlin in my project. If you`re need, i can to rewrite it to pure java.
Before some time my node stop to move, but continue to rotate in one place. Why?

So. I dont know how to solve this terrible problem. But can`t to stay in one place too long! I will change my game logic. I will make it with considering of my old bugs.

You might have better luck at getting an answer on this if it is just in straight up Java.

Anyways why are you cloning your rotQuat anyways? Just curious.

Okay. In all my next questions i will use both languages. I cloning rotQuat cuz … in the end of my searching i have tried some strange things, that, i think, can to change game behavior. Now i downloading new version of engine from 3.1 branche with last commits. May be it was a bug in engine…

Srsly. guys, what is wrong with java? Why you don’t use java instead of these crappy dialects? Why?? I mean… val rotQuat: Quaternion… really? And the semicolon? Where is my semicolon??

Rant apart, unless that for kotlin xyz.oskdij() means xyz=xyz.oskdij(),
is not storing the result anywhere, you should use normalizeLocal instead.


I will try it tomorrow. Thanks.

I have posted some info about Kotlin to contribution thread. Let`s go to discuss!

Also, double check this line

        swimVec = fish.localRotation.mult(swimVec)

if you want to store the result back in userData you have either to use multLocal or call setUserData(SWIM_VEC,swimVec) , always assuming that kotlin doesn’t do something weird internally that mess with references logic.

@tamtaradam Well your kind of hijacked the other post with that question btw. Best to do another topic on its own if you want to launch a debate.
But IMO, the simple fact that you are able to use Kotlin today with JME is already very nice. I know some people use it with Scala too.
I see no reason to rewrite the engine in <the new fancy language that is just syntactic sugar over java and that runs on a JVM>.

1 Like

I don’tunderstand

  1. Why Quaternion.IDENTITY and not the current rotation of the node if rotQuat is the target rotation for the node ?
  1. Why you mult localRotation by swimVec ? if fish.getUserData(SWIM_VEC) is the target position then it will failed, if it’s the speed, why normilize() it and why not use a value amplitude as amplitude of (1,0,0) (is fish front face to 1,0,0 in model space).

Thank you for your answer. Im not very familiar with quaternions and may be use it sometimes in wrong way. rotQuat is the rotation delta beetwen the current and target rotation: my models always rotating by one angel. Example with identity i have found on this forum, and work it very bad. But what do you mean by value amplitude? When im using a not normalized speed vec, im getting a freezed fishes that are rotating in one place.
Now im using another way: im storing a euler angels in userData of each object and make operations on it. And all works well. Quaternions collect error on each computation, and in end i got my problem. Now on each update i computing angel in euler angles and traslating it to quaternions.